using Discord; using Discord.Addons.Interactive; using Discord.Commands; using Kehyeedra3.Preconditions; using Kehyeedra3.Services.Models; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO.Enumeration; using System.IO.IsolatedStorage; using System.Linq; using System.Reflection.Metadata; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Channels; using System.Threading.Tasks; using ImageMagick; namespace Kehyeedra3.Commands { public class Interactive : InteractiveBase { readonly string[] attacks = new string[] { "", "" }; [RequireRolePrecondition(AccessLevel.BotOwner)] [Command("battlefish", RunMode = RunMode.Async),Alias("bf"),Summary("Type **bf help** or **bf h** for help with this command.")] public async Task BattleFish(string option = null, [Remainder]string sec = null) { using (var Database = new ApplicationDbContextFactory().CreateDbContext()) { var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); var userfish = Database.Battlefish.AsQueryable().Where(x => x.UserId == Context.User.Id); int attb = 0; int defb = 0; int hpb = 0; int apb = 0; int dgb = 0; if (!userfish.Any() && option == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou don't have any battlefish."); return; } else { var ufish = userfish.FirstOrDefault(x => x.FishType == user.CurrentBattlefish); if (ufish == null) { ufish = userfish.FirstOrDefault(); } switch (ufish.FishType) { case Services.Models.BattleFish.Herring: { attb = 9; defb = 9; hpb = 9; apb = 3; dgb = 2; } break; case Services.Models.BattleFish.Birgus: { attb = 10; defb = 6; hpb = 5; apb = 9; dgb = 4; } break; case Services.Models.BattleFish.Abama: { attb = 4; defb = 3; hpb = 5; apb = 18; dgb = 8; } break; case Services.Models.BattleFish.Pistashrimp: { attb = 15; defb = 4; hpb = 5; apb = 6; dgb = 6; } break; } } string opt = ""; BattleFish type = 0; if (option != null) { opt = option.ToLowerInvariant(); } string bfishlist = ""; var fish = userfish.FirstOrDefault(x => x.FishType == user.CurrentBattlefish); if (fish == null) { fish = userfish.FirstOrDefault(); } StringBuilder message = new StringBuilder($"{Context.User.Mention}\n"); string species = $""; string attacks = $""; double lvm = 20; double lvmhp = 100; for (int i = 0; i < fish.Lvl; i++) { lvm += Math.Round((Convert.ToDouble(lvm) * 0.01d), 0, MidpointRounding.ToEven) + 5; lvmhp += Math.Round((Convert.ToDouble(lvmhp) * 0.01d), 0, MidpointRounding.ToEven) + 10; } int lvlm = Convert.ToInt32(lvm) / 10; int lvlmhp = Convert.ToInt32(lvmhp) / 10; int att = lvlm * attb; int def = 5 * defb; int hp = lvlmhp * hpb; int ap = lvlmhp * apb; int dg = dgb; string prefix = "Hatchling"; string stats = ""; if (fish.Lvl >= 15) { prefix = "Young"; } if (fish.Lvl >= 30) { prefix = "Adolescent"; } if (fish.Lvl >= 50) { prefix = "Adult"; } switch ((int)fish.FishType) { case 0: { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou don't have a battlefish."); } return; case 1: { species = "Herring"; if (fish.Lvl >= 100) { species += $"ton"; prefix = $"Authentic Masculine"; } attacks += $"1 : **Slap** - {species} slaps the opponent."; if (fish.Lvl >= 5) { attacks += $"\n2 : **Kick** - {species} kicks the opponent with his muscular fin."; } if (fish.Lvl >= 15) { attacks += $"\n3 : **Flex** - {species} flexes his fin muscles, stunning the opponent."; } if (fish.Lvl >= 30) { attacks += $"\n4 : **Restoration Wand** - {species} spins his wand to recover some health."; } if (fish.Lvl >= 50) { attacks += $"\n5 : **Fairy Nightmare** - {species} executes a devastating ultimate attack."; } } break; case 2: { species = "Birgus"; if (fish.Lvl >= 100) { species += $""; prefix = $"Great Sage"; } attacks += $"1 : **Staff Slam** - {species} hits the enemy with its staff."; if (fish.Lvl >= 5) { attacks += $"\n2 : **Chitin Shards** - {species} summons a blast of magical shards at your opponent."; } if (fish.Lvl >= 15) { attacks += $"\n3 : **Iron Shell** - {species} materializes a hard shell, increasing defense."; } if (fish.Lvl >= 30) { attacks += $"\n4 : **Siphon Gaze** - {species} absorbs the enemy's life force with an enigmatic gaze."; } if (fish.Lvl >= 50) { attacks += $"\n5 : **Ecletic Rift** - {species} summons portals to alternate dimensions to call forth an army of raving crabs."; } } break; case 3: { species = "Abama"; if (fish.Lvl >= 100) { species += $""; prefix = $"President"; } attacks += $"1 : **Tentacle Slap** - {species} slaps the opponent with its tentacle."; if (fish.Lvl >= 5) { attacks += $"\n2 : **Squirt Ink** - {species} shoots ink at the opponent, blinding them temporarily."; } if (fish.Lvl >= 15) { attacks += $"\n3 : **Bind** - {species} holds down the opponent with its tentacles."; } if (fish.Lvl >= 30) { attacks += $"\n4 : **Metabolism** - {species} increases metabolism to instantly remove all ailments."; } if (fish.Lvl >= 50) { attacks += $"\n5 : **Ancestral Wrath** - {species} calls into the depths to unleash its true potential."; } } break; case 4: { species = "Pistashrimp"; if (fish.Lvl >= 100) { species += $" XTREME"; prefix = $"Hardboiled"; } attacks += $"1 : **Pistolwhip** - {species} swings at the enemy with the back of its pistol."; if (fish.Lvl >= 5) { attacks += $"\n2 : **Fire** - {species} shoots a round from its pistol."; } if (fish.Lvl >= 15) { attacks += $"\n3 : **Fedora Tip** - {species} tips its charming headwear, seducing the enemy."; } if (fish.Lvl >= 30) { attacks += $"\n4 : **Water Jet** - {species} tosses aside its silly weapon and snaps with its real claw."; } if (fish.Lvl >= 50) { attacks += $"\n5 : **Dual Jet** - {species} vaporizes the surrounding with its machine gun claws."; } } break; } stats = $"LVL {fish.Lvl} **{prefix} {species}**\nName: **{fish.Name}**\nStats: **ATK : {att} DEF : {def}% HP : {hp} AP : {ap}**\nActions:\n{attacks}\n\n"; if (opt == "") { message.AppendLine(stats); await Context.Channel.SendMessageAsync(message.ToString()); return; } if (opt == "change" || opt == "c") { string bfishlistname = ""; foreach (var fesh in userfish) { prefix = "Hatchling"; string suffix = ""; if (fesh.Lvl >= 15) { prefix = "Young"; } if (fesh.Lvl >= 30) { prefix = "Adolescent"; } if (fesh.Lvl >= 50) { prefix = "Adult"; } switch ((int)fesh.FishType) { case 1: { if (fesh.Lvl >= 100) { bfishlistname += $"ton"; suffix = $"Authentic Masculine"; } bfishlistname = $"{prefix} Herring{suffix}"; } break; case 2: { if (fesh.Lvl >= 100) { prefix = $"Great Sage"; } bfishlistname = $"{prefix} Birgus"; } break; case 3: { if (fesh.Lvl >= 100) { prefix = $"President"; } bfishlistname = $"{prefix} Abama"; } break; case 4: { if (fesh.Lvl >= 100) { suffix += $" XTREME"; prefix = $"Hardboiled"; } bfishlistname = $"{prefix} Pistashrimp{suffix}"; } break; } bfishlist += $"{(byte)fesh.FishType} : LVL {fesh.Lvl} {bfishlistname}\n"; } } if (option == "name" && sec != null || option == "n" && sec != null) { if (fish == null) { fish = userfish.FirstOrDefault(); } if (fish == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou can't name a fish you don't own!"); return; } if (sec.Length > 16) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nThe maximum name length is 16 characters. \nStop jassing."); return; } else if (fish.FishType != 0) { fish.Name = sec; await Database.SaveChangesAsync(); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou have changed the name of your battlefish to **{sec}**."); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou can't manage a fish if you don't have one."); } } else if (option == "buy" || option == "b") { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nHere is a list of available battlefish. Please choose one by its respective number. All battlefish cost 0.05%." + $"\n1 : **Herring** - An unarmed melee fighter with well balanced stats. It is not very agile.\nModifiers: **ATK 9, DEF 9, HP 9, AP 2**" + $"\n2 : **Birgus** - A crustacean mage with a focus on AP and DMG. It is slightly agile.\nModifiers: **ATK 10, DEF 6, HP 5, AP 9**" + $"\n3 : **Abama** - A cephalopod rogue with a heavy focus on debuffs. It is very agile.\nModifiers: **ATK 4, DEF 3, HP 5, AP 18**" + $"\n4 : **Pistashrimp** - A crustacean ranger with a heavy focus on DPS. It is somewhat agile.\nModifiers: **ATK 15, DEF 4, HP 5, AP 6**"); var reply = await NextMessageAsync(); BattleFish rep = (BattleFish)byte.Parse(reply.Content); if (userfish.Any(x => x.FishType == rep)) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou already have one of those, please don't neglect it and make it sad."); return; } if ((int)rep > 4 || (int)rep < 1) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nWhat you're looking for does not exist."); return; } else if (user.Money < 500) { await Context.Channel.SendMessageAsync($"Sorry **{Context.User.Mention}**, I can't give credit.\nCome back when you're a little, ***mmmmm***, richer.\n*You're missing {(500 - user.Money)/10000d}%.*"); return; } switch ((int)rep) { case 1: { species = "a Herring"; } break; case 2: { species = "a Birgus"; } break; case 3: { species = "an Abama"; } break; case 4: { species = "a Pistashrimp"; } break; } await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou want **{species}**? It's yours my friend, as long as you have enough **%**.\n *This cannot be reverted. Type 'confirm' to confirm.*"); reply = await NextMessageAsync(); if (reply.Content.ToLowerInvariant() == "confirm") { if (!user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), -500)) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBank has no money, buy more bait."); return; } var bfish = new User.BattleFishObject { FishType = rep, UserId = Context.User.Id }; Database.Battlefish.Add(bfish); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nThank you for your purchase."); await Database.SaveChangesAsync(); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYour purchase is cancelled."); } } else if (option == "info" || option == "i") { string info = ""; if (sec.ToLowerInvariant() == "herring") { info = "Equipment type: Enhancing clothing.\nBonus info: Only males of this species exist. I don't know how they reproduce, and I might not want to know."; } else if (sec.ToLowerInvariant() == "birgus") { info = "Equipment type: Staves.\nBonus info: Exceptional Birguses may live for centuries, their powers increasing with age. While breeding, they part with much of their potential power, so few of them actually do so."; } else if (sec.ToLowerInvariant() == "abama") { info = "Equipment type: Enhancing clothing.\nBonus info: The tentacles are not just for show. Being highly agile and stealthy, Abamas are experts at grabbing things unnoticed."; } else if (sec.ToLowerInvariant() == "pistashrimp") { info = "Equipment type: Firearms.\nBonus info: Despite making up only 13% of the underwater wildlife, Pistashrimps account for 100% of the unarmed firearm robberies. Few of them are righteous, but the ones that are make for great detectives."; } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nNot a valid fish."); return; } await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n{info}"); } else if (option == "help" || option == "h") { await Context.Channel.SendMessageAsync($"{Context.User.Mention}" + $"\n**name or n** to name your fish." + $"\n**buy or b** to buy a fish." + $"\n**info or i** along with **name of bf** to get further info on a battlefish." + $"\n**help or h** to view this." + $"\n**change or c** to change battlefish to any owned fish." + $"\nSpecify **no option** to view your battlefish stats."); } else if (option == "change" || option == "c") { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nPlease select your battlefish\n{bfishlist}"); var fens = await NextMessageAsync(); type = (BattleFish)byte.Parse(fens.Content); if (userfish.Any(x => x.FishType == type)) { user.CurrentBattlefish = type; await Database.SaveChangesAsync(); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBattlefish changed."); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou don't own that."); } } else if (option == "combat" || option == "cb") { int eatt = 10; int edf = 0; int edg = 5; int a1 = 0; int d1 = 0; int d2 = 0; bool eturn = false; if (sec == "enemy") { eturn = true; } if (eturn) { a1 = eatt; d1 = def; d2 = dg; } else { a1 = att; d1 = edf; d2 = edg; } int dmg = CalculateDamage(a1, d1, d2); await Context.Channel.SendMessageAsync($"Damage is **{dmg}**"); //await Context.Channel.SendMessageAsync($"*Combat test yeah baby*\nYour stats:\n**ATK : {att} DEF : {def}% HP : {hp} AP : {ap}**\nActions:\n{attacks}\n"); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nAre you confused? Try **bf help** if you are having trouble with your bf."); } } } public static int CalculateDamage(int a1, int d1, int d2) { int roll = SRandom.Next(5, 11); int rolldg = SRandom.Next(0, 11); if (roll == 10) { a1 *= 2; } if (rolldg * d2 >= 50) { return 0; } else { return ((a1 * roll) / 10 - (a1 * d1 / 100)); } } [Command("gstore", RunMode = RunMode.Async),Alias("gs"),Summary("General store: gstore or gs. Secondary variables s/sell to sell, b/buy to buy.")] public async Task GeneralStore(string input = null, string sec = null, string ter = null, [Remainder]string quar = null) { using (var Database = new ApplicationDbContextFactory().CreateDbContext()) { Dictionary items = new Dictionary(); Dictionary fishinv = new Dictionary(); List itemlist = User.ListItems(); List fishes = Fishing.GetFishList(); List legfish = fishes.ToList(); List rarfish = fishes.ToList(); List uncfish = fishes.ToList(); List comfish = fishes.ToList(); User.Item item; Fish fish; List fishTiers = fishes.ToList(); var fuser = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id); var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); if (fuser == null) { fuser = new Fishing { Id = user.Id }; Database.Fishing.Add(fuser); await Database.SaveChangesAsync(); } else { fishinv = fuser.GetInventory(); } if (user.GeneralInventory == null || user.GeneralInventory.Length < 3 ) { user.GeneralInventory = "{}"; await Database.SaveChangesAsync(); } string itemtxt = ""; foreach (User.Item i in itemlist) { if ((int)i.Id < 200) { itemtxt += $"{(int)i.Id} : {i.Name} for {((long)i.Price).ToYeedraDisplay()}%\n"; } } if (input != null) { input = input.ToLowerInvariant(); } if (input == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nPlease specify 'b / buy' to buy items, or 's / sell' to sell items."); } else if (input == "b" || input == "buy") { int itemid = 0; int itemnum = 0; if (!itemlist.Any(i => (int)i.Id == (int.Parse(sec)))) { sec = null; } if (sec == null || ter == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nSpecify the item and amount (ID num)\n{itemtxt}"); var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); var inpsep = inp.Content.Split(" "); itemid = int.Parse(inpsep[0]); itemnum = int.Parse(inpsep[1]); } else { itemid = int.Parse(sec); itemnum = int.Parse(ter); } item = itemlist.FirstOrDefault(i => (int)i.Id == itemid); items = user.GetGenInve(); int[] amount = { 0 }; if (!items.TryGetValue(item.Id, out amount)) { amount = new int[] { 0 }; items.Add(item.Id, amount); } if (itemnum * item.Price <= user.Money) { amount[0] += itemnum; int count = itemnum; await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou are about to buy {item.Name} for {((long)(count * item.Price)).ToYeedraDisplay()}%.\nType 'ok' to confirm."); var inp = await NextMessageAsync(); if (inp.Content.ToLowerInvariant() == "ok") { if (!user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), -(count * item.Price))) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBank has no money, buy more bait."); return; } user.SetGenInve(items); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBought {count} of {item.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 == "s" || input == "sell") { int value = 0; FishSize size; if (fuser.Inventory.Length < 3) { await Context.Channel.SendMessageAsync($"Your inventory is empty. Try fishing more."); return; } int tier = 0; if (sec == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nSpecify the tier.\n"); var inpu = await NextMessageAsync(); tier = int.Parse(inpu.Content); } else { tier = int.Parse(sec); } if (tier > 0 && tier < 5) { switch (tier) { case 1: { fishTiers = fishes.Where(f => (int)f.Tier == (int)FishTier.T1).ToList(); } break; case 2: { fishTiers = fishes.Where(f => (int)f.Tier == (int)FishTier.T2).ToList(); } break; case 3: { fishTiers = fishes.Where(f => (int)f.Tier == (int)FishTier.T3).ToList(); } break; case 4: { fishTiers = fishes.Where(f => (int)f.Tier == (int)FishTier.T4).ToList(); } break; } legfish = fishTiers.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList(); rarfish = fishTiers.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList(); uncfish = fishTiers.Where(f => (int)f.Rarity == (int)FishRarity.Uncommon).ToList(); comfish = fishTiers.Where(f => (int)f.Rarity == (int)FishRarity.Common).ToList(); } else if (tier < 1 || tier > 4) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTier not available."); return; } string legendary = ""; string rare = ""; string uncommon = ""; string common = ""; string fishtext = ""; if (sec != null && ter != null && quar != null) { foreach (var entry in fishinv) { fishtext = $"{(int)entry.Key} : {entry.Key} ["; if (entry.Value[0] > 0) { fishtext += $" **S**-{entry.Value[0]}"; } if (entry.Value[1] > 0) { fishtext += $" **M**-{entry.Value[1]}"; } if (entry.Value[2] > 0) { fishtext += $" **L**-{entry.Value[2]}"; } fishtext += $" ]\n"; if (legfish.Any(f => f.Id == entry.Key)) { legendary += $"{fishtext}"; } if (rarfish.Any(f => f.Id == entry.Key)) { rare += $"{fishtext}"; } if (uncfish.Any(f => f.Id == entry.Key)) { uncommon += $"{fishtext}"; } if (comfish.Any(f => f.Id == entry.Key)) { common += $"{fishtext}"; } } } string locker = ""; if (legendary != "") { locker += $"{legendary}\n"; } if (rare != "") { locker += $"{rare}\n"; } if (uncommon != "") { locker += $"{uncommon}\n"; } locker += $"{common}"; if (locker == "") { await Context.Channel.SendMessageAsync($"You don't have anything to sell in this tier."); return; } int itemid = 0; string itemsize = ""; int itemnum = 0; if (sec == null || ter == null || quar == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nSpecify the item, size, and amount. (ID size amount)\n\n{locker}"); var inpu = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); var inpsep = inpu.Content.Split(" "); itemid = int.Parse(inpsep[0]); itemsize = inpsep[1].ToString().ToLowerInvariant(); itemnum = int.Parse(inpsep[2]); } else { itemid = int.Parse(sec); itemsize = ter.ToLowerInvariant(); itemnum = int.Parse(quar); } int siz = 0; switch (itemsize) { case "s": { siz = 0; } break; case "m": { siz = 1; } break; case "l": { siz = 2; } break; } fish = fishes.FirstOrDefault(i => (int)i.Id == itemid); size = (FishSize)siz; int amount = itemnum; int amountcheck = fishinv.FirstOrDefault(f => f.Key == fish.Id).Value[(int)size]; if (amountcheck < amount) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou don't have that many.\n"); return; } siz += 1; switch (fish.Rarity) { case FishRarity.Common: { value = (int)fish.Tier * siz * 1; } break; case FishRarity.Uncommon: { value = (int)fish.Tier * siz * 3; } break; case FishRarity.Rare: { value = (int)fish.Tier * siz * 6; } break; case FishRarity.Legendary: { value = (int)fish.Tier * 100 + 600; } break; } value *= amount; await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou're about to sell **{amount} {fish.Name}** for **{((long)value).ToYeedraDisplay()}%**.\nType 'ok' to confirm."); var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); if (inp.Content.ToLowerInvariant() == "ok") { int[] amounts; if (!fishinv.TryGetValue(fish.Id, out amounts)) { amounts = new int[] { 0, 0, 0 }; fishinv.Add(fish.Id, amounts); } int sizeIndex = (int)size; amounts[sizeIndex] -= amount; fuser.SetInventory(fishinv); if (!user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), value)) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBank has no money, buy more bait."); return; } await Database.SaveChangesAsync(); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nThanks, seaman, enjoy your moolah."); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nI guess I'm starving tonight. :["); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// else if (input == "bulksell" || input == "bs") { int value = 0; int count = 0; FishTier ftier = FishTier.T1; if (fuser.Inventory.Length < 3) { await Context.Channel.SendMessageAsync($"Your inventory is empty. Try fishing more."); return; } int tier = 0; if (sec == null) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nSpecify the tier.\n"); var inptier = await NextMessageAsync(); tier = int.Parse(inptier.Content); } else { tier = int.Parse(sec); } if (tier > 0 && tier < 5) { switch (tier) { case 1: { ftier = FishTier.T1; } break; case 2: { ftier = FishTier.T2; } break; case 3: { ftier = FishTier.T3; } break; case 4: { ftier = FishTier.T4; } break; } } else if (tier < 1 || tier > 4) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTier not available."); return; } foreach (var f in fishinv) { int[] amounts; if (!fishinv.TryGetValue(f.Key, out amounts)) { amounts = new int[] { 0, 0, 0 }; fishinv.Add(f.Key, amounts); } if (f.Value[0] < 0) { f.Value[0] = 0; } if (f.Value[1] < 0) { f.Value[1] = 0; } if (f.Value[2] < 0) { f.Value[2] = 0; } fish = fishes.FirstOrDefault(i => i.Id == f.Key); if (fish != null && fish.Tier == ftier && fish.Rarity != FishRarity.Unreasonable && fish.Rarity != FishRarity.Legendary) { if (f.Value[0] > 0) { switch (fish.Rarity) { case FishRarity.Common: { value += (int)fish.Tier * 1 * 1 * f.Value[0]; } break; case FishRarity.Uncommon: { value += (int)fish.Tier * 1 * 3 * f.Value[0]; } break; case FishRarity.Rare: { value += (int)fish.Tier * 1 * 6 * f.Value[0]; } break; } count += f.Value[0]; f.Value[0] = 0; } if (f.Value[1] > 0) { switch (fish.Rarity) { case FishRarity.Common: { value += (int)fish.Tier * 2 * 1 * f.Value[1]; } break; case FishRarity.Uncommon: { value += (int)fish.Tier * 2 * 3 * f.Value[1]; } break; case FishRarity.Rare: { value += (int)fish.Tier * 2 * 6 * f.Value[1]; } break; } count += f.Value[1]; f.Value[1] = 0; } if (f.Value[2] > 0) { switch (fish.Rarity) { case FishRarity.Common: { value += (int)fish.Tier * 3 * 1 * f.Value[2]; } break; case FishRarity.Uncommon: { value += (int)fish.Tier * 3 * 3 * f.Value[2]; } break; case FishRarity.Rare: { value += (int)fish.Tier * 3 * 6 * f.Value[2]; } break; } count += f.Value[2]; f.Value[2] = 0; } } } if (count < 1) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou have nothing to sell in this tier. Try ;finv."); return; } await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYou're about to sell **{count} Fish** for **{((long)value).ToYeedraDisplay()}%**.\nType 'ok' to confirm."); var inp = await NextMessageAsync(timeout: TimeSpan.FromMinutes(2)); if (inp.Content.ToLowerInvariant() == "ok") { fuser.SetInventory(fishinv); if (!user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), value)) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nBank has no money, buy more bait."); return; } await Database.SaveChangesAsync(); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nThanks, seaman, enjoy your moolah."); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nI guess I'm starving tonight. :["); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } [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"); } } } } }