diff --git a/Kehyeedra3/ApplicationDbContext.cs b/Kehyeedra3/ApplicationDbContext.cs index f215f9d..a1f6bb3 100644 --- a/Kehyeedra3/ApplicationDbContext.cs +++ b/Kehyeedra3/ApplicationDbContext.cs @@ -14,5 +14,6 @@ namespace Kehyeedra3 public DbSet StoreFronts { get; set; } public DbSet Battlefish { get; set; } public DbSet Mining { get; set; } + public DbSet Farming { get; set; } } } diff --git a/Kehyeedra3/Bot.cs b/Kehyeedra3/Bot.cs index c3aceb6..f3d2b37 100644 --- a/Kehyeedra3/Bot.cs +++ b/Kehyeedra3/Bot.cs @@ -12,6 +12,7 @@ using Kehyeedra3.Services; using System.Threading; using Discord.Addons.Interactive; using dotenv.net; +using Kehyeedra3.Buttons; namespace Kehyeedra3 { @@ -138,6 +139,8 @@ namespace Kehyeedra3 try { _bot.Ready += _bot_Ready; + ButtonService.RegisterCumButtons(_bot); // button testing + ButtonService.RegisterFarmButtons(_bot); await _bot.LoginAsync(TokenType.Bot, Configuration.Load().Token); await _bot.StartAsync(); //Clockboy.Start(); @@ -160,7 +163,7 @@ namespace Kehyeedra3 } } - private async Task _bot_Ready() + private async Task _bot_Ready() { IsReady = true; } diff --git a/Kehyeedra3/Commands/Admin.cs b/Kehyeedra3/Commands/Admin.cs index ea6a930..034a201 100644 --- a/Kehyeedra3/Commands/Admin.cs +++ b/Kehyeedra3/Commands/Admin.cs @@ -99,6 +99,14 @@ namespace Kehyeedra3.Commands var message = await NextMessageAsync(); if (message != null && message.Content.ToLowerInvariant() == "yes") { + foreach (User u in users) + { + if (u.Money < 0) + { + u.Money = 0; + u.Money -= difference; + } + } bank.Money += difference; await Database.SaveChangesAsync(); if (difference > 0) @@ -330,6 +338,14 @@ namespace Kehyeedra3.Commands } } + [RequireRolePrecondition(AccessLevel.ServerAdmin)] + [Command("buttontest")] + public async Task ButtonTest() // button testing + { + var components = new ComponentBuilder().WithButton("cum", "cum").WithButton("piss", "piss"); + await Context.Channel.SendMessageAsync($"Greetings traveler, I've potions for you to purchase, what'd you like to have?",component:components.Build()); + } + [RequireRolePrecondition(AccessLevel.ServerAdmin)] [Command("makeimag")] public async Task MakeImage() diff --git a/Kehyeedra3/Commands/Economy.cs b/Kehyeedra3/Commands/Economy.cs index 550daac..794560c 100644 --- a/Kehyeedra3/Commands/Economy.cs +++ b/Kehyeedra3/Commands/Economy.cs @@ -15,17 +15,17 @@ using Kehyeedra3.Preconditions; using System.IO; namespace Kehyeedra3.Commands -{ +{ public class Economy : InteractiveBase { readonly string[] ores = new string[] { "**Gold**,", "**Platinum**,", - "**Plastids**,", + "a **Windows Update**,", "a ticking **Time Bomb**,", "an **Amethyst**,", - "**Germanium**,", + "the **Bone Stone**,", "a **Hotdog**,", "**Corundum**,", "**Quartz**,", @@ -35,11 +35,11 @@ namespace Kehyeedra3.Commands "**Beryllium**,", "**Gallium**,", "an **Amber**,", - "**Bismuth**", + "**Bismuth**,", "an **Emerald**,", "a lost **Sock**,", "**Tellurium**,", - "**Ferrite**,", + "**Bad Apple**,", "a **Glass of Water**,", "**Redstone**,", "**Racism**,", @@ -64,7 +64,7 @@ namespace Kehyeedra3.Commands "a **Viet Cong Tunnel**,", "a single unit of several **Trees**,", "**1,000,000₩**,", - "**Jas's Love**,", + "a **Cunny Rabbit**,", "a **Rock Golem**,", "a piece of **Toast**,", "**Luminite**,", @@ -178,15 +178,7 @@ namespace Kehyeedra3.Commands if (muser.TXp >= muser.Xp) { muser.Lvl += 1; - ulong leXp = 50; - for (ulong i = 0; i < muser.Lvl; i++) - { - if (i <= muser.Lvl) - { - leXp += Convert.ToUInt64(Math.Round((leXp * 0.05d + 50d), 0, MidpointRounding.ToEven)); - } - } - muser.Xp = leXp; + muser.Xp = muser.Lvl.GetLevelXp()[0]; levelup += $"You leveled up. You are now **Lvl {muser.Lvl}**"; } else @@ -635,32 +627,17 @@ namespace Kehyeedra3.Commands int times = 0; if (user.TXp > 50 && user.FXp == 0) { - lvlXp = 50; - for (ulong i = 0; i < user.Lvl; i++) - { - - if (i <= user.Lvl) - { - lvlXp += Convert.ToUInt64(Math.Round((lvlXp * 0.05d + 50d), 0, MidpointRounding.ToEven)); - } - if (i == user.Lvl - 2) - { - user.FXp = lvlXp; - } - - } + ulong[] result = user.Lvl.GetLevelXp(); + lvlXp = result[0]; + user.FXp = result[1]; } if (user.TXp >= user.Xp) { - ulong leXp = 50; + ulong[] result = user.Lvl.GetLevelXp(); + + ulong leXp = result[0]; bool leTrig = false; - for (ulong i = 0; i < user.Lvl; i++) - { - if (i <= user.Lvl) - { - leXp += Convert.ToUInt64(Math.Round((leXp * 0.05d + 50d), 0, MidpointRounding.ToEven)); - } - } + if (leXp != user.Xp) { user.Lvl = 0; @@ -672,27 +649,19 @@ namespace Kehyeedra3.Commands user.Lvl += 1; times += 1; lvlXp = 50; - - for (ulong i = 0; i < user.Lvl; i++) - { - - if (i <= user.Lvl) - { - lvlXp += Convert.ToUInt64(Math.Round((lvlXp * 0.05d + 50d), 0, MidpointRounding.ToEven)); - } - if (i == user.Lvl - 2) - { - user.FXp = lvlXp; - } - } + result = user.Lvl.GetLevelXp(); + lvlXp = result[0]; + user.FXp = result[1]; + user.Xp = lvlXp; } + toNextLvl = user.Xp - user.TXp; level = user.Lvl; if (leTrig) { - lvlUp = $"**Your level was recalculated\n to match your xp.** \nYou are now **Level {level}**"; + lvlUp = $"**Your level was recalculated to match \nyour xp.** You are now **Level {level}**"; } else if (times > 1) { @@ -970,7 +939,7 @@ namespace Kehyeedra3.Commands } } - [Command("fishinventory"), Alias("finv", "fishinv"), Summary("Shows the fish you have currently. Variables: fish tier")] + [Command("fishinventory"), Alias("finv", "fishinv"), Summary("Shows your fish inventory. Variables: fish tier")] public async Task FishInventory(int? tier = null, IGuildUser user = null) { if (user == null) @@ -1152,7 +1121,7 @@ namespace Kehyeedra3.Commands await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false); } } - [Command("generalinventory"),Alias("ginv", "geninv"), Summary("Shows the items you have excluding fish.")] + [Command("generalinventory"),Alias("ginv", "geninv"), Summary("Shows your general items inventory.")] public async Task GeneralInventory() { User user; @@ -1163,7 +1132,21 @@ namespace Kehyeedra3.Commands using (var Database = new ApplicationDbContextFactory().CreateDbContext()) { user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); - inv = user.GetGenInve(); + if (user == null) + { + user = new User + { + Id = Context.User.Id + }; + + Database.Users.Add(user); + message += "You have no items."; + } + else + { + inv = user.GetGenInve(); + } + foreach (var entry in inv) { if (entry.Value[0] > 0) @@ -1175,6 +1158,42 @@ namespace Kehyeedra3.Commands await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n{message}"); } } + [Command("farminventory"),Alias("fainv","farminv"),Summary("Shows your farm inventory, including seeds and crops.")] + public async Task FarmInventory() + { + string message = ""; + List crops = Farming.ListCrops(); + Dictionary inv = new Dictionary(); + FCrop crop; + using (var Database = new ApplicationDbContextFactory().CreateDbContext()) + { + var user = Database.Farming.FirstOrDefault(x => x.Id == Context.User.Id); + if (user == null) + { + user = new Farming + { + Id = Context.User.Id + }; + + Database.Farming.Add(user); + message += "You have no items."; + } + else + { + inv = user.GetCropInventory(); + } + + foreach (var entry in inv) + { + if (entry.Value[0] > 0) + { + crop = crops.FirstOrDefault(x => x.Id == entry.Key); + message += $"**{crop.Name}** : **{entry.Value[0]}** Seeds, **{entry.Value[1]}** Crops\n"; + } + } + await ReplyAsync($"{Context.User.Mention}\n{message}"); + } + } [RequireRolePrecondition(AccessLevel.ServerAdmin)] [Command("tradebuy", RunMode = RunMode.Async), Summary("Unfinished command")] public async Task TradingBuy(int amount, string itemtype, int price, [Remainder] string item) @@ -1662,19 +1681,10 @@ namespace Kehyeedra3.Commands user.TXp -= presXp; user.Xp = 0; user.Lvl = 0; - ulong lvlXp = 0; while (user.TXp >= user.Xp) { user.Lvl += 1; - lvlXp = 50; - for (ulong i = 0; i < user.Lvl; i++) - { - if (i <= user.Lvl) - { - lvlXp += Convert.ToUInt64(Math.Round((lvlXp * 0.05d + 50d), 0, MidpointRounding.ToEven)); - } - } - user.Xp = lvlXp; + user.Xp = user.Lvl.GetLevelXp()[0]; } await Database.SaveChangesAsync(); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou've successfully upgraded to **P{user.Prestige}**.\nReadjusting level."); diff --git a/Kehyeedra3/Commands/Interactive.cs b/Kehyeedra3/Commands/Interactive.cs index 1c98687..b47c0e6 100644 --- a/Kehyeedra3/Commands/Interactive.cs +++ b/Kehyeedra3/Commands/Interactive.cs @@ -1059,10 +1059,149 @@ namespace Kehyeedra3.Commands } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } + [Command("farming", RunMode = RunMode.Async), Alias("farm"), Summary("arguments: m/manage")] + public async Task FarmCommand(string input = null) + { + Dictionary items = new Dictionary(); + List crops = Farming.ListCrops(); + List plots = Farming.ListFarmLand(); + + + using (var Database = new ApplicationDbContextFactory().CreateDbContext()) + { + var user = Database.Farming.FirstOrDefault(i => i.Id == Context.User.Id); + var buser = Database.Users.FirstOrDefault(i => i.Id == Context.User.Id); + if (user == null) + { + user = new Farming + { + Id = Context.User.Id + }; + Database.Farming.Add(user); + await Database.SaveChangesAsync(); + } + var plotinv = user.GetPlotInventory(); + var cropinv = user.GetCropInventory(); + + string cropitemtxt = ""; + string plotitemtxt = ""; + + FarmTier tier = (FarmTier)user.Tier; + foreach (FCrop i in crops) + { + if (i.Price != 0 && (int)tier >= (int)i.Tier) + { + cropitemtxt += $"{(int)i.Id} : {i.Name} Seed for {((long)i.Price).ToYeedraDisplay()}%\n"; + } + } + foreach (FLand i in plots) + { + if (i.Price != 0 && (int)tier >= (int)i.Tier) + { + plotitemtxt += $"{(int)i.Id} : {i.Name} for {((long)i.Price).ToYeedraDisplay()}%\n"; + } + } + + input = input.ToLowerInvariant(); + if (input == "manage" || input == "m") + { + await ReplyAsync($"{Context.User.Mention}\nSelect a farm"); + var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); + var inpsep = inp.Content.Split(" "); + + + } + else if (input == "seedmarket" || input == "sm") + { + await ReplyAsync($"{Context.User.Mention}\nSelect what you want to buy (id, amount).\n{cropitemtxt}"); + var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); + var inpsep = inp.Content.Split(" "); + FCrop crop = crops.FirstOrDefault(i => (int)i.Id == int.Parse(inpsep[0])); + + items = user.GetCropInventory(); + + int[] amount = { 0 , 0 }; + + if (!items.TryGetValue(crop.Id, out amount)) + { + amount = new int[] { 0, 0 }; + items.Add(crop.Id, amount); + } + + if (int.Parse(inpsep[1]) * crop.Price <= buser.Money) + { + amount[0] += int.Parse(inpsep[1]); + int count = int.Parse(inpsep[1]); + + await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nThis will cost you {((long)(count * crop.Price)).ToYeedraDisplay()}.\nType 'ok' to confirm."); + + inp = await NextMessageAsync(); + if (inp.Content.ToLowerInvariant() == "ok") + { + if (!buser.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), -(count * crop.Price))) + { + await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBank has no money, buy more bait."); + return; + } + user.SetCropInventory(items); + await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBought {count} of {crop.Name}."); + await Database.SaveChangesAsync(); + } + else + { + await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nPlease come back when you feel like spending."); + } + } + else + { + await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nCome back when you're a little, MMMMMMmmmm, richer."); + } + } + else if (input == "propertymarket" || input == "pm") + { + FLand plot; + await ReplyAsync($"{Context.User.Mention}\nHere's a list of property you can buy right now.\n{plotitemtxt}"); + var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); + var inpsep = inp.Content.Split(" "); + } + else if (input == "hire" || input == "h") + { + string add = ""; + int cap = (int)tier * 2 - user.EmployeeCount; + if ( cap > 0) + { + add += $"You can currently hire {cap} more farmer{(cap>1?"s":"")}."; + } + await ReplyAsync($"{Context.User.Mention}\nYou currently employ **{user.EmployeeCount} / {(int)tier*2}** farmers.\n{add}\nHow many farmers do you want to hire? (0-{(int)tier*2-user.EmployeeCount})"); + var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); + int numbie = int.Parse(inp.Content); + if (numbie > 0 && numbie * 100 + numbie * 100 * user.Tier < buser.Money) + { + + } + else if (numbie * 100 + numbie * 100 * user.Tier > buser.Money) + { + await ReplyAsync($"{Context.User.Mention}\nCome back when you're a little, MMMMMMmmmm, richer."); + } + else + { + await ReplyAsync($"{Context.User.Mention}\nYou're poor haha loser haha"); + } + } + else + { + await ReplyAsync($"Here's a list of arguments you can use:" + + $"\nmanage | m : manage a farm you own" + + $"\nseedmarket | sm : purchase seeds to use at your farm" + + $"\npropertymarket | pm : purchase new property to grow crops on" + + $"\nhire | h : hire workers for your farms"); + } + } + } } } diff --git a/Kehyeedra3/Commands/Stuff.cs b/Kehyeedra3/Commands/Stuff.cs index e90175f..86c99cf 100644 --- a/Kehyeedra3/Commands/Stuff.cs +++ b/Kehyeedra3/Commands/Stuff.cs @@ -246,7 +246,7 @@ namespace Kehyeedra3.Commands } else { - var dmchannel = await Bot._bot.GetUser(Context.User.Id).GetOrCreateDMChannelAsync(); + var dmchannel = await Bot._bot.GetUser(Context.User.Id).CreateDMChannelAsync(); await dmchannel.SendMessageAsync($"**You literally just told me to DM you:**\n\n{r}"); } } @@ -381,7 +381,7 @@ namespace Kehyeedra3.Commands [Command("changenick")] public async Task ChangeNickname(IGuildUser usr = null, [Remainder]string name = null) { - if (Context.Guild.Id != 691361760300761139) + if (Context.Guild.Id != 691361760300761139 && Context.Guild.Id != 912778610300039198) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nWrong server retard"); return; diff --git a/Kehyeedra3/Discord.Addons.Interactive.dll b/Kehyeedra3/Discord.Addons.Interactive.dll new file mode 100644 index 0000000..c61c39f Binary files /dev/null and b/Kehyeedra3/Discord.Addons.Interactive.dll differ diff --git a/Kehyeedra3/Extensions.cs b/Kehyeedra3/Extensions.cs index e8ed187..aa280ae 100644 --- a/Kehyeedra3/Extensions.cs +++ b/Kehyeedra3/Extensions.cs @@ -26,6 +26,33 @@ namespace Kehyeedra3 return numb.ToString("N4"); } + public static ulong[] GetLevelXp(this ulong lvl) + { + using (var Database = new ApplicationDbContextFactory().CreateDbContext()) + { + lvl += 1; + ulong lvlXp = 50; + ulong lvlFloor = 0; + for (ulong i = 0; i < lvl; i++) + { + if (i <= lvl) + { + lvlXp += Convert.ToUInt64(Math.Round((lvlXp * 0.05d + 50d), 0, MidpointRounding.ToEven)); + } + if (i == lvl - 2) + { + lvlFloor = lvlXp; + } + } + ulong[] numbies = new ulong[] + { + lvlXp, + lvlFloor + }; + return numbies; + } + } + public static double Remap(this int value, double min1, double max1, double min2, double max2) => ((double)value).Remap(min1, max1, min2, max2); diff --git a/Kehyeedra3/Kehyeedra3.csproj b/Kehyeedra3/Kehyeedra3.csproj index 08a6e2e..5eb8cf1 100644 --- a/Kehyeedra3/Kehyeedra3.csproj +++ b/Kehyeedra3/Kehyeedra3.csproj @@ -2,14 +2,17 @@ Exe - netcoreapp3.1 + net5.0 2020.5.2.0 2020.5.2.0 - - + + + + + @@ -19,6 +22,12 @@ + + + Discord.Addons.Interactive.dll + + + Always diff --git a/Kehyeedra3/Migrations/20210806204446_FarmingA.Designer.cs b/Kehyeedra3/Migrations/20210806204446_FarmingA.Designer.cs new file mode 100644 index 0000000..fbaf54d --- /dev/null +++ b/Kehyeedra3/Migrations/20210806204446_FarmingA.Designer.cs @@ -0,0 +1,294 @@ +// +using System; +using Kehyeedra3; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Kehyeedra3.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20210806204446_FarmingA")] + partial class FarmingA + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Kehyeedra3.Services.Models.Farming", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("CropInventory") + .HasColumnType("LONGTEXT"); + + b.Property("EmployeeCount") + .HasColumnType("int"); + + b.Property("FXp") + .HasColumnType("bigint unsigned"); + + b.Property("Lvl") + .HasColumnType("bigint unsigned"); + + b.Property("PlotInventory") + .HasColumnType("LONGTEXT"); + + b.Property("TXp") + .HasColumnType("bigint unsigned"); + + b.Property("Tier") + .HasColumnType("int"); + + b.Property("Xp") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("Farming"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("FXp") + .HasColumnType("bigint unsigned"); + + b.Property("Inventory") + .HasColumnType("LONGTEXT"); + + b.Property("LastFish") + .HasColumnType("bigint unsigned"); + + b.Property("Lvl") + .HasColumnType("bigint unsigned"); + + b.Property("Prestige") + .HasColumnType("int"); + + b.Property("RodOwned") + .HasColumnType("tinyint unsigned"); + + b.Property("RodUsed") + .HasColumnType("tinyint unsigned"); + + b.Property("TXp") + .HasColumnType("bigint unsigned"); + + b.Property("Xp") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("Fishing"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b => + { + b.Property("OfferId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("BuyerId") + .HasColumnType("bigint unsigned"); + + b.Property("IsPurchaseFromStore") + .HasColumnType("tinyint(1)"); + + b.Property("IsSellOffer") + .HasColumnType("tinyint(1)"); + + b.Property("ItemId") + .HasColumnType("bigint unsigned"); + + b.Property("OfferAmount") + .HasColumnType("int"); + + b.Property("StoreFrontId") + .HasColumnType("bigint unsigned"); + + b.Property("StoreId") + .HasColumnType("bigint unsigned"); + + b.HasKey("OfferId"); + + b.HasIndex("StoreFrontId"); + + b.ToTable("ItemOffer"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.Mining", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("LastMine") + .HasColumnType("bigint unsigned"); + + b.Property("Lvl") + .HasColumnType("bigint unsigned"); + + b.Property("TXp") + .HasColumnType("bigint unsigned"); + + b.Property("Xp") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("Mining"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.Reminder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("Created") + .HasColumnType("bigint unsigned"); + + b.Property("Message") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("Send") + .HasColumnType("bigint unsigned"); + + b.Property("UserId") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("Reminders"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.StoreFront", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("StoreItemType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("StoreFronts"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b => + { + b.Property("InvId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("Item") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("Price") + .HasColumnType("int"); + + b.Property("StoreFrontId") + .HasColumnType("bigint unsigned"); + + b.HasKey("InvId"); + + b.HasIndex("StoreFrontId"); + + b.ToTable("StoreInventory"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("Avatar") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("CurrentBattlefish") + .HasColumnType("TINYINT"); + + b.Property("GeneralInventory") + .HasColumnType("LONGTEXT"); + + b.Property("Money") + .HasColumnType("bigint"); + + b.Property("OwnerId") + .HasColumnType("bigint unsigned"); + + b.Property("Username") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.User+BattleFishObject", b => + { + b.Property("FishId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("FishType") + .HasColumnType("TINYINT"); + + b.Property("Lvl") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("NextXp") + .HasColumnType("bigint unsigned"); + + b.Property("UserId") + .HasColumnType("bigint unsigned"); + + b.Property("Xp") + .HasColumnType("bigint unsigned"); + + b.HasKey("FishId"); + + b.ToTable("Battlefish"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b => + { + b.HasOne("Kehyeedra3.Services.Models.StoreFront", null) + .WithMany("Offers") + .HasForeignKey("StoreFrontId"); + }); + + modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b => + { + b.HasOne("Kehyeedra3.Services.Models.StoreFront", null) + .WithMany("Items") + .HasForeignKey("StoreFrontId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Kehyeedra3/Migrations/20210806204446_FarmingA.cs b/Kehyeedra3/Migrations/20210806204446_FarmingA.cs new file mode 100644 index 0000000..95680b4 --- /dev/null +++ b/Kehyeedra3/Migrations/20210806204446_FarmingA.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Kehyeedra3.Migrations +{ + public partial class FarmingA : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "OwnerId", + table: "Users", + nullable: false, + defaultValue: 0ul); + + migrationBuilder.CreateTable( + name: "Farming", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Tier = table.Column(nullable: false), + EmployeeCount = table.Column(nullable: false), + Lvl = table.Column(nullable: false), + Xp = table.Column(nullable: false), + FXp = table.Column(nullable: false), + TXp = table.Column(nullable: false), + CropInventory = table.Column(type: "LONGTEXT", nullable: true), + PlotInventory = table.Column(type: "LONGTEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Farming", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Farming"); + + migrationBuilder.DropColumn( + name: "OwnerId", + table: "Users"); + } + } +} diff --git a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs index c529103..2c855d3 100644 --- a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs @@ -17,6 +17,41 @@ namespace Kehyeedra3.Migrations .HasAnnotation("ProductVersion", "3.1.11") .HasAnnotation("Relational:MaxIdentifierLength", 64); + modelBuilder.Entity("Kehyeedra3.Services.Models.Farming", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("CropInventory") + .HasColumnType("LONGTEXT"); + + b.Property("EmployeeCount") + .HasColumnType("int"); + + b.Property("FXp") + .HasColumnType("bigint unsigned"); + + b.Property("Lvl") + .HasColumnType("bigint unsigned"); + + b.Property("PlotInventory") + .HasColumnType("LONGTEXT"); + + b.Property("TXp") + .HasColumnType("bigint unsigned"); + + b.Property("Tier") + .HasColumnType("int"); + + b.Property("Xp") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("Farming"); + }); + modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b => { b.Property("Id") @@ -198,6 +233,9 @@ namespace Kehyeedra3.Migrations b.Property("Money") .HasColumnType("bigint"); + b.Property("OwnerId") + .HasColumnType("bigint unsigned"); + b.Property("Username") .HasColumnType("longtext CHARACTER SET utf8mb4"); diff --git a/Kehyeedra3/Services/ButtonService.cs b/Kehyeedra3/Services/ButtonService.cs new file mode 100644 index 0000000..45fd487 --- /dev/null +++ b/Kehyeedra3/Services/ButtonService.cs @@ -0,0 +1,115 @@ +using Discord; +using Discord.Addons.Interactive; +using Discord.Commands; +using Discord.WebSocket; +using Kehyeedra3.Services.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Kehyeedra3.Buttons +{ + public static class ButtonService // button testing + { + public static void RegisterCumButtons(DiscordSocketClient client) + { + client.InteractionCreated += HandleCumButtons; + } + + private static async Task HandleCumButtons(SocketInteraction arg) + { + if (arg.Type == InteractionType.MessageComponent) + { + var parsedArg = (SocketMessageComponent)arg; + + switch (parsedArg.Data.CustomId) + { + case "cum": + { + await parsedArg.Message.ModifyAsync(z => { z.Components = null; }); + + + await parsedArg.FollowupAsync("You have selected cum, prepare to die"); + } + break; + case "piss": + { + await parsedArg.Message.ModifyAsync(z => { z.Components = null; }); + + await parsedArg.FollowupAsync("You have selected piss, prepare to shit"); + } + break; + } + } + } + + public static void RegisterFarmButtons(DiscordSocketClient client) + { + client.InteractionCreated += HandleFarmButtons; + } + + private static async Task HandleFarmButtons(SocketInteraction arg) + { + if (arg.Type == InteractionType.MessageComponent) + { + var parsedArg = (SocketMessageComponent)arg; + Dictionary items = new Dictionary(); + List crops = Farming.ListCrops(); + List plots = Farming.ListFarmLand(); + FarmTier tier = FarmTier.T0; + + string cropitemtxt = ""; + string plotitemtxt = ""; + + switch (parsedArg.Data.CustomId) + { + //case "crop": + // { + // foreach (FCrop i in crops) + // { + // if (i.Price > 0 && (int)tier >= (int)i.Tier) + // { + // cropitemtxt += $"{(int)i.Id} : {i.Name} Seed for {((long)i.Price).ToYeedraDisplay()}%\n"; + // } + // } + // await parsedArg.Message.ModifyAsync(z => { z.Components = null; }); + // if (cropitemtxt != "") + // { + // await parsedArg.FollowupAsync($"Select an item\n{cropitemtxt}"); + // } + // else + // { + // await parsedArg.FollowupAsync($"There is nothing you can buy right now."); + // } + + // } + // break; + //case "plot": + // { + // foreach (FLand i in plots) + // { + // if (i.Price > 0 && (int)tier >= (int)i.Tier) + // { + // plotitemtxt += $"{(int)i.Id} : {i.Name} for {((long)i.Price).ToYeedraDisplay()}%\n"; + // } + // } + // await parsedArg.Message.ModifyAsync(z => { z.Components = null; }); + + // if (plotitemtxt != "") + // { + // await parsedArg.FollowupAsync($"Select an item\n{plotitemtxt}"); + // } + // else + // { + // await parsedArg.FollowupAsync($"There is nothing you can buy right now."); + // } + + // } + // break; + } + } + } + } +} diff --git a/Kehyeedra3/Services/Models/Farming.cs b/Kehyeedra3/Services/Models/Farming.cs new file mode 100644 index 0000000..854c987 --- /dev/null +++ b/Kehyeedra3/Services/Models/Farming.cs @@ -0,0 +1,240 @@ +using System; +using System.Text; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace Kehyeedra3.Services.Models +{ + public class Farming + { + [Key] + public ulong Id { get; set; } = 0; + public int Tier { get; set; } = 0; + public int EmployeeCount { get; set; } = 0; + public ulong Lvl { get; set; } = 0; + public ulong Xp { get; set; } = 50; + public ulong FXp { get; set; } = 0; + public ulong TXp { get; set; } = 0; + + [Column(TypeName = "LONGTEXT")] + public string CropInventory { get; set; } = "{}"; + [Column(TypeName = "LONGTEXT")] + public string PlotInventory { get; set; } = "{}"; + + public Dictionary GetCropInventory() + { + return JsonConvert.DeserializeObject>(CropInventory); + } + public Dictionary GetPlotInventory() + { + return JsonConvert.DeserializeObject>(PlotInventory); + } + public void SetCropInventory(Dictionary inv) + { + Dictionary temp = new Dictionary(); + foreach (var entry in inv) + { + temp.Add((int)entry.Key, entry.Value); + } + CropInventory = JsonConvert.SerializeObject(temp); + } + public void SetPlotInventory(Dictionary inv) + { + Dictionary temp = new Dictionary(); + foreach (var entry in inv) + { + temp.Add((int)entry.Key, entry.Value); + } + PlotInventory = JsonConvert.SerializeObject(temp); + } + public static List ListCrops() + { + return new List + { + new FCrop() + { + Id = FarmCrop.Wheat, + Name = "Wheat", + Description = "Common wheat, 'Triticum aestivum' is the most widely grown cereal grain, you should get in on it before we reach peak wheat.", + Type = FarmType.Plant, + Tier = FarmTier.T0, + GrowTime = 10, + Price = 100, + }, + new FCrop() + { + Id = FarmCrop.Rye, + Name = "Rye", + Description = "Rye, 'Secale cereale' is a hardy cereal grain, grows slower than wheat, but also tastes better.", + Type = FarmType.Plant, + Tier = FarmTier.T1, + GrowTime = 15, + Price = 150, + }, + new FCrop() + { + Id = FarmCrop.Lettuce, + Name = "Lettuce", + Description = "Lettuce, 'Lactuca sativa' is an annual daisy plant first cultivated in ancient Egypt, worshipped as ancient viagra. Incidentally, it can be harvested very often.", + Type = FarmType.Plant, + Tier = FarmTier.T2, + GrowTime = 5, + Price = 200, + }, + new FCrop() + { + Id = FarmCrop.Leek, + Name = "Leek", + Description = "Leek, 'Allium ampeloprasum' is an onion, the word leek is derived from the old english word 'leac', it has a medium growth time. I know what you're thinking about doing and I want you to stop right now.", + Type = FarmType.Plant, + Tier = FarmTier.T3, + GrowTime = 13, + Price = 250, + }, + new FCrop() + { + Id = FarmCrop.Bookweed, + Name = "Bookweed", + Description = "Bookweed, 'Lactuca liber' is an enchanted variant of lettuce used for special crafting. Eating it by itself is said to give you diarrhea.", + Type = FarmType.Plant, + Tier = FarmTier.T4, + GrowTime = 50, + Price = 0, + }, + new FCrop() + { + Id = FarmCrop.LuckyLeek, + Name = "Polkka", + Description = "Polkka, 'Allium dexter' is an enchanted variant of leek used for special crafting. It contains a natural power to spin, and can be used as a green energy source. If you're a huge faggot.", + Type = FarmType.Plant, + Tier = FarmTier.T5, + GrowTime = 50, + Price = 0, + }, + }; + } + public static List ListFarmLand() + { + return new List + { + new FLand() + { + Id = FarmLand.Backyard, + Name = "Backyard", + Type = FarmType.Plant, + Tier = FarmTier.T0, + WorkerMax = 1, + Price = 0 + }, + new FLand() + { + Id = FarmLand.SPlot, + Name = "Small Plot", + Type = FarmType.Plant, + Tier = FarmTier.T1, + WorkerMax = 2, + Price = 600 + }, + new FLand() + { + Id = FarmLand.MPlot, + Name = "Medium Plot", + Type = FarmType.Plant, + Tier = FarmTier.T3, + WorkerMax = 4, + Price = 1000 + }, + new FLand() + { + Id = FarmLand.LPlot, + Name = "Large Plot", + Type = FarmType.Plant, + Tier = FarmTier.T5, + WorkerMax = 6, + Price = 1400 + }, + }; + } + } + public enum FarmLand + { + Backyard = 0, + Bathtub = 1, + SPlot = 2, + MPlot = 3, + LPlot = 4, + } + public enum FarmType + { + Plant = 0, + Fish = 1, + } + public enum FarmCrop + { + Wheat = 0, + Rye = 1, + Lettuce = 2, + Leek = 3, + + LuckyLeek = 100, + Bookweed = 101, + } + public enum FarmTier + { + T0 = 0, + T1 = 1, + T2 = 2, + T3 = 3, + T4 = 4, + T5 = 5, + } + public class FLand + { + public FarmLand Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public FarmType Type { get; set; } + public FarmTier Tier { get; set; } + public int WorkerMax { get; set; } + public int Price { get; set; } + + } + + public class FCrop + { + public FarmCrop Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public FarmType Type { get; set; } + public FarmTier Tier { get; set; } + public int GrowTime { get; set; } + public int Price { get; set; } + } + + public class PlotObject + { + [Key] + public ulong PlotId { get; set; } = 0; + [Required] + public ulong UserId { get; set; } = 0; + public ulong Planted { get; set; } = 0; + public ulong Grown { get; set; } = 0; + public int FarmType { get; set; } = 0; + public int WorkerAmount { get; set; } = 0; + + } + public class FCropSlot + { + public int Id; + public int Seeds; + public int Produce; + } + public class FPlotSlot + { + public int Id; + public int Amount; + } + +} diff --git a/Kehyeedra3/Services/Models/Fishing.cs b/Kehyeedra3/Services/Models/Fishing.cs index 641c4d4..815af0e 100644 --- a/Kehyeedra3/Services/Models/Fishing.cs +++ b/Kehyeedra3/Services/Models/Fishing.cs @@ -276,6 +276,14 @@ namespace Kehyeedra3.Services.Models Tier = FishTier.T2 }, new Fish() + { + Id = FishSpecies.Wololo, + Name = "Wololo", + + Rarity = FishRarity.Rare, + Tier = FishTier.T2 + }, + new Fish() { Id = FishSpecies.Gunfish, Name = "Gunfish", @@ -444,6 +452,7 @@ namespace Kehyeedra3.Services.Models //T2 Rare Swolefish = 21, Dogfish = 22, + Wololo = 23, //T2 Uncommon Gunfish = 30, Dingus = 31, diff --git a/Kehyeedra3/Services/Models/User.cs b/Kehyeedra3/Services/Models/User.cs index b86a386..cb43b1b 100644 --- a/Kehyeedra3/Services/Models/User.cs +++ b/Kehyeedra3/Services/Models/User.cs @@ -16,6 +16,7 @@ namespace Kehyeedra3.Services.Models public string GeneralInventory { get; set; } = "{}"; [Column(TypeName = "TINYINT")] public BattleFish CurrentBattlefish { get; set; } = 0; + public ulong OwnerId { get; set; } = 0; @@ -152,6 +153,7 @@ namespace Kehyeedra3.Services.Models UpgradeT2 = 200, UpgradeT3 = 201, UpgradeT4 = 202, + } public class ItemSlot { diff --git a/Kehyeedra3/Services/ReminderService.cs b/Kehyeedra3/Services/ReminderService.cs index d4f0a36..d7feef4 100644 --- a/Kehyeedra3/Services/ReminderService.cs +++ b/Kehyeedra3/Services/ReminderService.cs @@ -14,7 +14,7 @@ namespace Kehyeedra3.Services private static async Task SendReminderAsync(Reminder reminder) { try { - var dmchannel = await Bot._bot.GetUser(reminder.UserId).GetOrCreateDMChannelAsync(); + var dmchannel = await Bot._bot.GetUser(reminder.UserId).CreateDMChannelAsync(); if (dmchannel != null) { ulong m = (reminder.Send - reminder.Created) / 60; @@ -61,7 +61,7 @@ namespace Kehyeedra3.Services catch { if (LanChannel is null) { IUser Lan = Bot._bot.GetUser(242040333309837327); - LanChannel = await Lan.GetOrCreateDMChannelAsync(); + LanChannel = await Lan.CreateDMChannelAsync(); } await LanChannel.SendMessageAsync($"Time of error ^\n" +