From 24b3839947607134b54484686f082b9a97fb37b8 Mon Sep 17 00:00:00 2001 From: Lan <50151341+Lannnnnnnnn@users.noreply.github.com> Date: Sun, 23 Feb 2020 22:51:46 +0200 Subject: [PATCH] work on fish command --- Kehyeedra3/Commands.cs | 50 ++++++---- .../20200223155743_morefishstuff.Designer.cs | 95 +++++++++++++++++++ .../20200223155743_morefishstuff.cs | 31 ++++++ .../ApplicationDbContextModelSnapshot.cs | 2 +- Kehyeedra3/Services/Models/Fishing.cs | 41 ++++---- 5 files changed, 174 insertions(+), 45 deletions(-) create mode 100644 Kehyeedra3/Migrations/20200223155743_morefishstuff.Designer.cs create mode 100644 Kehyeedra3/Migrations/20200223155743_morefishstuff.cs diff --git a/Kehyeedra3/Commands.cs b/Kehyeedra3/Commands.cs index be13ca5..c0333f1 100644 --- a/Kehyeedra3/Commands.cs +++ b/Kehyeedra3/Commands.cs @@ -250,7 +250,7 @@ namespace Kehyeedra3 var reminder = new Reminder { UserId = Context.User.Id, - Message = ($"At **UTC {time}** you wanted me to remind you: **'{r}'**"), + Message = ($"At **UTC {time}** you wanted me to remind you:\n**'{r}'**"), Created = yeedraStamp, Send = ((d * 86400) + (h * 3600) + (m * 60)) + yeedraStamp }; @@ -347,33 +347,26 @@ namespace Kehyeedra3 { FishSpecies.Doomfish, FishSpecies.Clownfish, - FishSpecies.GenericFish, - FishSpecies.Ultracrab, - FishSpecies.BlobFish, - FishSpecies.Psychedelica, + FishSpecies.Teracrab, + FishSpecies.Blobfish, + FishSpecies.Psychedelica }; readonly FishSpecies[] ufish = new FishSpecies[] { FishSpecies.Gigacrab, - FishSpecies.MantisShrimp, - FishSpecies.GoblinFish, - FishSpecies.BatFish, - FishSpecies.FrogFish, - FishSpecies.TigerFish, + FishSpecies.Frogfish, FishSpecies.Stargazer, FishSpecies.Isopod, - FishSpecies.SheepHead, + FishSpecies.Sheephead, }; readonly FishSpecies[] cfish = new FishSpecies[] { FishSpecies.Cod, FishSpecies.Salmon, - FishSpecies.Pike, FishSpecies.Bass, FishSpecies.Crayfish, FishSpecies.Betta, - FishSpecies.PufferFish, - FishSpecies.Tuna, + FishSpecies.Pufferfish, FishSpecies.Carp, FishSpecies.Megacrab }; @@ -479,6 +472,10 @@ namespace Kehyeedra3 { ulong time = ulong.Parse(DateTime.Now.ToString("yyyyMMddHHmm")); ulong lastfish; + ulong totalXp; + ulong xp; + ulong level; + ulong lvlXp; List inv = new List(); using (var Database = new ApplicationDbContextFactory().CreateDbContext()) { @@ -497,12 +494,19 @@ namespace Kehyeedra3 { inv = user.GetInventory(); } + level = user.Lvl; lastfish = user.LastFish; + totalXp = user.TXp; + lvlXp = user.Xp; await Database.SaveChangesAsync(); } + + + if (lastfish < time) { - int rarity = SRandom.Next(0, 201); + int rari = (SRandom.Next(0, 201)); + ulong rarity = level + (ulong)rari; FishRarity rarmult; string rar = ""; FishSpecies fish ; @@ -512,6 +516,7 @@ namespace Kehyeedra3 rarmult = FishRarity.Rare; int num = SRandom.Next(rfish.Length); fish = rfish[num]; + xp = 3; } else { @@ -521,14 +526,16 @@ namespace Kehyeedra3 rarmult = FishRarity.Uncommon; int num = SRandom.Next(ufish.Length); fish = ufish[num]; + xp = 2; } else { - if (rarity == 7) + if (rarity == 77) { rar = "***Legendary***"; - rarmult = FishRarity.Special; + rarmult = FishRarity.Legendary; fish = FishSpecies.LuckyCatfish; + xp = 7; } else { @@ -536,6 +543,7 @@ namespace Kehyeedra3 rarmult = FishRarity.Common; int num = SRandom.Next(cfish.Length); fish = cfish[num]; + xp = 1; } } } @@ -556,11 +564,11 @@ namespace Kehyeedra3 size = FishWeight.Small; } - if (weight >= 150 || rarmult == FishRarity.Special) + if (weight >= 150 || rarmult == FishRarity.Legendary) { size = FishWeight.Large; } - if (rarity > 40) + if (rarity > 20) { using (var Database = new ApplicationDbContextFactory().CreateDbContext()) { @@ -585,9 +593,11 @@ namespace Kehyeedra3 } user.SetInventory(inv); - + user.LastFish = time; + user.TXp += xp; + await Database.SaveChangesAsync().ConfigureAwait(false); // :] } diff --git a/Kehyeedra3/Migrations/20200223155743_morefishstuff.Designer.cs b/Kehyeedra3/Migrations/20200223155743_morefishstuff.Designer.cs new file mode 100644 index 0000000..0f8b093 --- /dev/null +++ b/Kehyeedra3/Migrations/20200223155743_morefishstuff.Designer.cs @@ -0,0 +1,95 @@ +// +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("20200223155743_morefishstuff")] + partial class morefishstuff + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.1") + .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("TXp") + .HasColumnType("bigint unsigned"); + + b.Property("Xp") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.ToTable("Fishing"); + }); + + 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.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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Kehyeedra3/Migrations/20200223155743_morefishstuff.cs b/Kehyeedra3/Migrations/20200223155743_morefishstuff.cs new file mode 100644 index 0000000..f179328 --- /dev/null +++ b/Kehyeedra3/Migrations/20200223155743_morefishstuff.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Kehyeedra3.Migrations +{ + public partial class morefishstuff : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Inventory", + table: "Fishing", + type: "LONGTEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "json", + oldNullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Inventory", + table: "Fishing", + type: "json", + nullable: true, + oldClrType: typeof(string), + oldType: "LONGTEXT", + oldNullable: true); + } + } +} diff --git a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs index e7ada2e..0835fb9 100644 --- a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs @@ -23,7 +23,7 @@ namespace Kehyeedra3.Migrations .HasColumnType("bigint unsigned"); b.Property("Inventory") - .HasColumnType("json"); + .HasColumnType("LONGTEXT"); b.Property("LastFish") .HasColumnType("bigint unsigned"); diff --git a/Kehyeedra3/Services/Models/Fishing.cs b/Kehyeedra3/Services/Models/Fishing.cs index 20d7332..22e3b50 100644 --- a/Kehyeedra3/Services/Models/Fishing.cs +++ b/Kehyeedra3/Services/Models/Fishing.cs @@ -44,31 +44,24 @@ namespace Kehyeedra3.Services.Models //rare Doomfish = 2, Clownfish = 3, - GenericFish = 4, - Ultracrab = 5, - BlobFish = 6, - Psychedelica = 7, + Teracrab = 4, + Blobfish = 5, + Psychedelica = 6, //uncommon - Gigacrab = 8, - MantisShrimp = 9, - GoblinFish = 10, - BatFish = 11, - FrogFish = 12, - TigerFish = 13, - Stargazer = 14, - Isopod = 15, - SheepHead = 16, + Gigacrab = 7, + Frogfish = 8, + Stargazer = 9, + Isopod = 10, + Sheephead = 11, //common - Cod = 17, - Salmon = 18, - Pike = 19, - Bass = 20, - Crayfish = 21, - Betta = 22, - PufferFish = 23, - Tuna = 24, - Carp = 25, - Megacrab = 26 + Cod = 12, + Salmon = 13, + Pufferfish = 14, + Bass = 15, + Crayfish = 16, + Betta = 17, + Carp = 18, + Megacrab = 19 } public enum FishWeight { @@ -81,7 +74,7 @@ namespace Kehyeedra3.Services.Models Common = 1, Uncommon = 2, Rare = 3, - Special = 4 + Legendary = 4 } public class FishingInventorySlot {