diff --git a/Kehyeedra3/Commands/Admin.cs b/Kehyeedra3/Commands/Admin.cs index f27e62e..8ec49c2 100644 --- a/Kehyeedra3/Commands/Admin.cs +++ b/Kehyeedra3/Commands/Admin.cs @@ -80,10 +80,7 @@ namespace Kehyeedra3.Commands User bank = Database.Users.FirstOrDefault(x => x.Id == 0); int existing = 0; - for (int i = 0; i < 10; i++) - { - existing += Convert.ToInt32(users[i].Money); - } + users.ForEach(x => existing += Convert.ToInt32(x.Money)); int difference = 1000000 - existing; string content = ""; if (difference >= 0) @@ -109,7 +106,7 @@ namespace Kehyeedra3.Commands } else { - await Context.Channel.SendMessageAsync($"Economy has been stabilized by removing {difference / 10000d} from bank"); + await Context.Channel.SendMessageAsync($"Economy has been stabilized by removing {0-difference / 10000d} from bank"); } } } diff --git a/Kehyeedra3/Commands/Economy.cs b/Kehyeedra3/Commands/Economy.cs index fa7e5f8..1701455 100644 --- a/Kehyeedra3/Commands/Economy.cs +++ b/Kehyeedra3/Commands/Economy.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading.Channels; using System.Threading.Tasks; namespace Kehyeedra3.Commands @@ -104,6 +105,7 @@ namespace Kehyeedra3.Commands var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); lastmine = user.LastMine; user.LastMine = time; + user.Username = Context.User.Username; await Database.SaveChangesAsync(); } if (lastmine < time) @@ -196,6 +198,7 @@ namespace Kehyeedra3.Commands ulong xp; ulong level; ulong lvlXp; + int rod; Dictionary inv = new Dictionary(); List fishes = Fishing.GetFishList(); @@ -220,6 +223,7 @@ namespace Kehyeedra3.Commands lastfish = user.LastFish; totalXp = user.TXp; lvlXp = user.Xp; + rod = user.RodUsed; await Database.SaveChangesAsync(); } @@ -245,9 +249,24 @@ namespace Kehyeedra3.Commands if (rarity == 777 || (rarity > 2060 && rarity <= 2070) || (rarity > 2760 && rarity <= 2770)) { - List possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList(); - fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; - xp = 10; + if (rod == 1) + { + List possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T2Legendary).ToList(); + fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; + xp = 15; + } + else if (rod == 1) + { + List possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T3Legendary).ToList(); + fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; + xp = 20; + } + else + { + List possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList(); + fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; + xp = 10; + } if (rarity == 777) { xp = 77; @@ -262,10 +281,26 @@ namespace Kehyeedra3.Commands xp = 10; if (rarity > 2600) { - possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList(); - fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; - xp = 20; + if (rod == 1) + { + possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T2Rare).ToList(); + fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; + xp = 25; + } + else if (rod == 2) + { + possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T3Rare).ToList(); + fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; + xp = 30; + } + else + { + possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList(); + fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; + xp = 20; + } } + } else { @@ -276,7 +311,7 @@ namespace Kehyeedra3.Commands FishSize size; - if (fish.Rarity == FishRarity.Legendary) + if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary) { weight = 1000; } @@ -297,7 +332,7 @@ namespace Kehyeedra3.Commands if (weight >= 1000) { xp = Convert.ToUInt64(Math.Round((xp * w / 1000), 0, MidpointRounding.ToEven)); - if (fish.Rarity == FishRarity.Legendary) + if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary) { if (xp < 100) { @@ -386,6 +421,51 @@ namespace Kehyeedra3.Commands } } + [Command("checkrod"),Summary("Displays what fishing rods you can use, as well as your currently equipped fishing rod")] + public async Task CheckRod() + { + using (var Database = new ApplicationDbContextFactory().CreateDbContext()) + { + var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id); + await Context.Channel.SendMessageAsync($"You have unlocked fishing rods up to **T{user.RodOwned+1}**\nYou have currently equipped a **T{user.RodUsed+1}** rod"); + } + } + [Command("setrod"),Summary("Set your fishing rod to the desired tier (for example: 'setrod 1' to set to default rod)")] + public async Task SetRod(byte tier) + { + using (var Database = new ApplicationDbContextFactory().CreateDbContext()) + { + var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id); + if (tier - 1 <= user.RodOwned) + { + user.RodUsed = Convert.ToByte(tier - 1); + string rodtype = ""; + if (tier == 1) + { + rodtype = "Basic"; + } + else if (tier == 2) + { + rodtype = "Reinforced"; + } + else if (tier == 3) + { + rodtype = "Spectral"; + } + else + { + rodtype = "Currently unobtainable"; + } + await Context.Channel.SendMessageAsync($"You are now using a **{rodtype} (T{tier})** rod"); + } + else + { + await Context.Channel.SendMessageAsync($"You don't have that rod. You own rods up to **T{user.RodOwned+1}**"); + } + await Database.SaveChangesAsync().ConfigureAwait(false); + + } + } [Command("inventory"), Alias("inv", "fishinv"), Summary("Shows the fish you have currently. Might show other things in the distant future.")] public async Task FishInventory([Remainder]IGuildUser user = null) { @@ -672,6 +752,7 @@ namespace Kehyeedra3.Commands message.AppendLine($"**{store.StoreItemType} Store** has no offers currently"); } } + await Context.Channel.SendMessageAsync($"{message}"); } } } @@ -855,6 +936,7 @@ namespace Kehyeedra3.Commands using (var Database = new ApplicationDbContextFactory().CreateDbContext()) { var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); + var pers = Database.Users.FirstOrDefault(x => x.Id == person.Id); if (user.Money < amount) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} You don't have that much money??"); @@ -867,12 +949,14 @@ namespace Kehyeedra3.Commands } else { - var transfer = amount - (amount * 2); - if (!user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == person.Id), transfer)) + if (pers.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), amount) && user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), -amount)) + { + await Context.Channel.SendMessageAsync($"{Context.User.Mention} **{amount / 10000d}%** has been transferred from your account."); + } + else { await Context.Channel.SendMessageAsync($"{Context.User.Mention} You can't afford that, go back to the mines."); } - await Context.Channel.SendMessageAsync($"{Context.User.Mention} **{amount / 10000d}%** has been transferred from your account."); await Database.SaveChangesAsync(); } } diff --git a/Kehyeedra3/Migrations/20200408192800_RodUpdate.Designer.cs b/Kehyeedra3/Migrations/20200408192800_RodUpdate.Designer.cs new file mode 100644 index 0000000..20e64e9 --- /dev/null +++ b/Kehyeedra3/Migrations/20200408192800_RodUpdate.Designer.cs @@ -0,0 +1,195 @@ +// +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("20200408192800_RodUpdate")] + partial class RodUpdate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + b.Property("Inventory") + .HasColumnType("LONGTEXT"); + + b.Property("LastFish") + .HasColumnType("bigint unsigned"); + + b.Property("Lvl") + .HasColumnType("bigint unsigned"); + + 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.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("LastMine") + .HasColumnType("bigint unsigned"); + + b.Property("Money") + .HasColumnType("bigint"); + + b.Property("Username") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + 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/20200408192800_RodUpdate.cs b/Kehyeedra3/Migrations/20200408192800_RodUpdate.cs new file mode 100644 index 0000000..431085f --- /dev/null +++ b/Kehyeedra3/Migrations/20200408192800_RodUpdate.cs @@ -0,0 +1,68 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Kehyeedra3.Migrations +{ + public partial class RodUpdate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "RodOwned", + table: "Fishing", + nullable: false, + defaultValue: (byte)0); + + migrationBuilder.AddColumn( + name: "RodUsed", + table: "Fishing", + nullable: false, + defaultValue: (byte)0); + + migrationBuilder.CreateTable( + name: "ItemOffer", + columns: table => new + { + OfferId = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + BuyerId = table.Column(nullable: false), + StoreId = table.Column(nullable: false), + ItemId = table.Column(nullable: false), + Amount = table.Column(nullable: false), + OfferAmount = table.Column(nullable: false), + IsPurchaseFromStore = table.Column(nullable: false), + IsSellOffer = table.Column(nullable: false), + StoreFrontId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ItemOffer", x => x.OfferId); + table.ForeignKey( + name: "FK_ItemOffer_StoreFronts_StoreFrontId", + column: x => x.StoreFrontId, + principalTable: "StoreFronts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_ItemOffer_StoreFrontId", + table: "ItemOffer", + column: "StoreFrontId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ItemOffer"); + + migrationBuilder.DropColumn( + name: "RodOwned", + table: "Fishing"); + + migrationBuilder.DropColumn( + name: "RodUsed", + table: "Fishing"); + } + } +} diff --git a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs index 4f31998..20c25a4 100644 --- a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace Kehyeedra3.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.1.1") + .HasAnnotation("ProductVersion", "3.1.2") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b => @@ -32,6 +32,12 @@ namespace Kehyeedra3.Migrations b.Property("Lvl") .HasColumnType("bigint unsigned"); + b.Property("RodOwned") + .HasColumnType("tinyint unsigned"); + + b.Property("RodUsed") + .HasColumnType("tinyint unsigned"); + b.Property("TXp") .HasColumnType("bigint unsigned"); @@ -43,6 +49,43 @@ namespace Kehyeedra3.Migrations 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.Reminder", b => { b.Property("Id") @@ -131,6 +174,13 @@ namespace Kehyeedra3.Migrations b.ToTable("Users"); }); + 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) diff --git a/Kehyeedra3/Services/Models/Fishing.cs b/Kehyeedra3/Services/Models/Fishing.cs index eb9146a..133ca93 100644 --- a/Kehyeedra3/Services/Models/Fishing.cs +++ b/Kehyeedra3/Services/Models/Fishing.cs @@ -12,7 +12,9 @@ namespace Kehyeedra3.Services.Models } public enum FishRarity { - Common, Uncommon, Rare, Legendary + Common, Uncommon, Rare, Legendary, + T2Rare, T2Legendary, + T3Rare, T3Legendary } public class Fish { @@ -30,6 +32,8 @@ namespace Kehyeedra3.Services.Models public ulong Xp { get; set; } = 50; public ulong TXp { get; set; } = 0; public ulong Lvl { get; set; } = 0; + public byte RodOwned { get; set; } = 0; + public byte RodUsed { get; set; } = 0; [Column(TypeName="LONGTEXT")] public string Inventory { get; set; } = "{}"; @@ -184,22 +188,40 @@ namespace Kehyeedra3.Services.Models Name = "Megacrab", Emote = "<:megacrab:681871426319286302>", Rarity = FishRarity.Common + }, + + new Fish() + { + Id = FishSpecies.T2Circusfish, + Name = "Circusfish", + Emote = "<:missingLeg:682586847830081551>", + Rarity = FishRarity.T2Legendary + }, + new Fish() + { + Id = FishSpecies.T2Swolefish, + Name = "Pumped Up Swolefish", + Emote = "<:missingLeg:682586847830081551>", + Rarity = FishRarity.T2Rare + }, + new Fish() + { + Id = FishSpecies.T3Doomfish, + Name = "Spectral Doomfish", + Emote = "<:missingLeg:682586847830081551>", + Rarity = FishRarity.T3Legendary + }, + new Fish() + { + Id = FishSpecies.T3Crab, + Name = "Revenant Crab", + Emote = "<:missingLeg:682586847830081551>", + Rarity = FishRarity.T3Rare } + }; } - } - //public class FishObject - //{ - // public FishSpecies Species; - // public FishSize Weight; - // public FishRarity Rarity; - - // public override string ToString() - // { - // return $"{Weight.ToString()} {Rarity.ToString()} {Species.ToString()}"; - // } - //} public enum FishSpecies { @@ -225,7 +247,20 @@ namespace Kehyeedra3.Services.Models Crayfish = 16, Betta = 17, Carp = 18, - Megacrab = 19 + Megacrab = 19, + //T2 Legendary + T2Circusfish = 20, + //T2 Rare + T2Swolefish = 21, + //T3 Legendary + T3Doomfish = 22, + //T3 Rare + T3Crab = 23, + //T4 Legendary + + //T4 Rare + + } public class FishingInventorySlot { diff --git a/Kehyeedra3/Services/Models/User.cs b/Kehyeedra3/Services/Models/User.cs index eeeccd0..b26225e 100644 --- a/Kehyeedra3/Services/Models/User.cs +++ b/Kehyeedra3/Services/Models/User.cs @@ -12,7 +12,7 @@ { if(bank.Money > amount) { - Money += amount % bank.Money; + Money += amount; bank.Money -= amount; return true; }