From 8b17cdf67717785c8b1330efba239b77aaaaa0c7 Mon Sep 17 00:00:00 2001 From: Lan <50151341+Lannnnnnnnn@users.noreply.github.com> Date: Thu, 2 Apr 2020 15:12:21 +0300 Subject: [PATCH] store progress and fishing fixes also some other stuff --- Kehyeedra3/ApplicationDbContext.cs | 1 + Kehyeedra3/Bot.cs | 12 +- Kehyeedra3/Command handler.cs | 4 +- Kehyeedra3/Commands.cs | 267 +++++++++++------- Kehyeedra3/Extensions.cs | 22 ++ Kehyeedra3/Kehyeedra3.csproj | 1 + .../20200330063400_store.Designer.cs | 145 ++++++++++ Kehyeedra3/Migrations/20200330063400_store.cs | 61 ++++ .../ApplicationDbContextModelSnapshot.cs | 50 ++++ .../Models/{StoreFront.cs => Store.cs} | 12 +- Kehyeedra3/Services/ReminderService.cs | 2 +- 11 files changed, 460 insertions(+), 117 deletions(-) create mode 100644 Kehyeedra3/Migrations/20200330063400_store.Designer.cs create mode 100644 Kehyeedra3/Migrations/20200330063400_store.cs rename Kehyeedra3/Services/Models/{StoreFront.cs => Store.cs} (85%) diff --git a/Kehyeedra3/ApplicationDbContext.cs b/Kehyeedra3/ApplicationDbContext.cs index 00d1fd0..c5bcf8a 100644 --- a/Kehyeedra3/ApplicationDbContext.cs +++ b/Kehyeedra3/ApplicationDbContext.cs @@ -11,5 +11,6 @@ namespace Kehyeedra3 public DbSet Users { get; set; } public DbSet Reminders { get; set; } public DbSet Fishing { get; set; } + public DbSet StoreFronts { get; set; } } } diff --git a/Kehyeedra3/Bot.cs b/Kehyeedra3/Bot.cs index d5fd29f..842c0f5 100644 --- a/Kehyeedra3/Bot.cs +++ b/Kehyeedra3/Bot.cs @@ -11,20 +11,20 @@ using System.Net; using System.Net.Http; using Kehyeedra3.Services; using System.Threading; +using Discord.Addons.Interactive; namespace Kehyeedra3 { public class Bot { /// Star Vars - public static DiscordShardedClient _bot; + public static DiscordSocketClient _bot; public static System.Timers.Timer Clockboy; public static CommandService commands; public static AudioService AudioService; public static CommandService _cmds; public static IServiceProvider _dmap; public static CommandServiceConfig _cmdsconfig; - public static int Shards = 0; public static Random _rnd = new Random(); public static AIMLbot.Bot ChatService; public static AIMLbot.User ChatUser; @@ -60,19 +60,16 @@ namespace Kehyeedra3 WeebClient = new WebClient(); - _bot = new DiscordShardedClient(new DiscordSocketConfig() + _bot = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Verbose, DefaultRetryMode = RetryMode.AlwaysRetry, HandlerTimeout = 10000, - ConnectionTimeout = 10000, - TotalShards = Config.Shards + ConnectionTimeout = 10000 }); AudioService = new AudioService(); - Shards = _bot.Shards.Count; - _cmds = new CommandService(); _cmdsconfig = new CommandServiceConfig @@ -84,6 +81,7 @@ namespace Kehyeedra3 .AddSingleton(_bot) .AddSingleton(_cmds) .AddSingleton(AudioService) + .AddSingleton(new InteractiveService(_bot, TimeSpan.FromSeconds(30))) .BuildServiceProvider(); await CommandHandler.InstallCommands(); diff --git a/Kehyeedra3/Command handler.cs b/Kehyeedra3/Command handler.cs index 1f1e30b..024362d 100644 --- a/Kehyeedra3/Command handler.cs +++ b/Kehyeedra3/Command handler.cs @@ -98,7 +98,7 @@ namespace Kehyeedra3 var message = arg as SocketUserMessage; if (message == null) return; int argPos = 0; - var context = new CommandContext(_bot, message); + var context = new SocketCommandContext(_bot, message); if (message.HasMentionPrefix(_bot.CurrentUser, ref argPos)) { await KizunaAi(context, message.Content); @@ -108,7 +108,7 @@ namespace Kehyeedra3 await context.Channel.SendMessageAsync($"B emoji detected. Proceed to kill yourself, {context.User.Mention}"); } var jrole = context.Guild.GetRole(375289794999091201); - var euser = await context.Guild.GetUserAsync(context.User.Id).ConfigureAwait(false); + var euser = context.Guild.GetUser(context.User.Id); //var jas = await context.Guild.GetUserAsync(236952555265982464).ConfigureAwait(false); //var cat = await context.Guild.GetUserAsync(194439970797256706).ConfigureAwait(false); //if (euser.RoleIds.Any(id => id == 682109241363922965)) diff --git a/Kehyeedra3/Commands.cs b/Kehyeedra3/Commands.cs index 9ef1750..7cef7fb 100644 --- a/Kehyeedra3/Commands.cs +++ b/Kehyeedra3/Commands.cs @@ -13,6 +13,7 @@ using MySql.Data.MySqlClient; using Kehyeedra3.Services.Models; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Internal; +using Discord.Addons.Interactive; namespace Kehyeedra3 { @@ -23,7 +24,7 @@ namespace Kehyeedra3 public async Task Pong() { await Context.Channel.TriggerTypingAsync(); - await ReplyAsync($"My current ping is {Bot._bot.GetShardFor(Context.Guild).Latency}ms"); + await ReplyAsync($"My current ping is {Bot._bot.Latency}ms"); } } [Group] @@ -158,7 +159,7 @@ namespace Kehyeedra3 // await Bot.AudioService.SendAudioAsync(Context.Guild, Context.Channel, song); // } //} - public class Stuff : ModuleBase /////////////////////////////////////////////// + public class Stuff : InteractiveBase /////////////////////////////////////////////// { [Command("delet")] @@ -276,9 +277,9 @@ namespace Kehyeedra3 [Command("grant")] public async Task Daycare(IGuildUser ouser) { - var user = await Context.Guild.GetUserAsync(Context.User.Id).ConfigureAwait(false); + var user = Context.Guild.GetUser(Context.User.Id); var drole = Context.Guild.GetRole(682109241363922965); - if (user.RoleIds.Any(id => id == 682109241363922965)) + if (user.Roles.Any(x => x.Id == 682109241363922965)) { await user.RemoveRoleAsync(drole); await ouser.AddRoleAsync(drole); @@ -303,7 +304,7 @@ namespace Kehyeedra3 } } - public class Economy : ModuleBase + public class Economy : InteractiveBase { readonly string[] ores = new string[] { @@ -543,8 +544,7 @@ namespace Kehyeedra3 { List possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList(); fish = possibleFishes[SRandom.Next(possibleFishes.Count)]; - weight = SRandom.Next(200, 4001); - xp = 100; + xp = 10; } else { @@ -576,6 +576,11 @@ namespace Kehyeedra3 FishSize size; + if (fish.Rarity == FishRarity.Legendary) + { + weight = 100; + } + if (weight >= 75) { size = FishSize.Medium; @@ -583,6 +588,17 @@ namespace Kehyeedra3 { weight = SRandom.Next(1, 201); } + + if (fish.Rarity == FishRarity.Legendary) + { + weight = SRandom.Next(200 + Convert.ToInt32(level*2), 4001); + } + + if (weight > 50) + { + double w = Convert.ToDouble(weight); + xp += Convert.ToUInt64(Math.Round((xp * w / 100), 0, MidpointRounding.ToEven)); + } } else { @@ -725,14 +741,14 @@ namespace Kehyeedra3 if (user.Id != Context.User.Id) { - await Context.Channel.SendMessageAsync($"FEESH INVENTOGleS of {user.Mention}"); + await Context.Channel.SendMessageAsync($"arr matey this be {user.Mention}'s locker"); } if(small.Any()) { EmbedBuilder embed = new EmbedBuilder { - Title = "SMONKL FEESH" + Title = "small mateys" }; foreach (var entry in small) @@ -754,7 +770,7 @@ namespace Kehyeedra3 { EmbedBuilder embed = new EmbedBuilder { - Title = "MED FEESH" + Title = "medium mateys" }; foreach (var entry in med) @@ -777,7 +793,7 @@ namespace Kehyeedra3 { EmbedBuilder embed = new EmbedBuilder { - Title = "LARG FEESH" + Title = "large mateys" }; foreach (var entry in large) @@ -800,98 +816,145 @@ namespace Kehyeedra3 await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false); } } - [Command("buy")] - public async Task TradingBuy(int amount, string itemtype, int price, [Remainder] string item) - { - string contents = "trade info"; - FishSize size = 0; - FishSpecies species = 0; - List fishes = Fishing.GetFishList(); - if (itemtype.ToLowerInvariant() == "fish") - { - if (item.ToLowerInvariant().Contains("large")) - { - size = FishSize.Large; - } - else if (item.ToLowerInvariant().Contains("medium")) - { - size = FishSize.Medium; - } - else if (item.ToLowerInvariant().Contains("small")) - { - size = FishSize.Small; - } - else - { - await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards."); - return; - } - if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant()))) - { - species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id; - } - else - { - await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish."); - return; - } - contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price/10000d}%\n"; - - await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to buy item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false); - - await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false); - } - else - { - await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false); - } - } - [Command("sell")] - public async Task TradingSell(int amount, string itemtype, int price, [Remainder] string item) - { - string contents = "trade info"; - FishSize size = 0; - FishSpecies species = 0; - List fishes = Fishing.GetFishList(); - if (itemtype.ToLowerInvariant() == "fish") - { - if (item.ToLowerInvariant().Contains("large")) - { - size = FishSize.Large; - } - else if (item.ToLowerInvariant().Contains("medium")) - { - size = FishSize.Medium; - } - else if (item.ToLowerInvariant().Contains("small")) - { - size = FishSize.Small; - } - else - { - await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards."); - return; - } - if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant()))) - { - species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id; - } - else - { - await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish."); - return; - } - contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price / 10000d}%\n"; - - await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to sell item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false); + //[Command("tradebuy", RunMode = RunMode.Async)] + //public async Task TradingBuy(int amount, string itemtype, int price, [Remainder] string item) + //{ + // using (var Database = new ApplicationDbContextFactory().CreateDbContext()) + // { + // var KehUser = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); + // if (itemtype.ToLowerInvariant() == "fish") + // { + // FishSize size = 0; + // FishSpecies species = 0; + // List fishes = Fishing.GetFishList(); + + // if (item.ToLowerInvariant().Contains("large")) + // { + // size = FishSize.Large; + // } + // else if (item.ToLowerInvariant().Contains("medium")) + // { + // size = FishSize.Medium; + // } + // else if (item.ToLowerInvariant().Contains("small")) + // { + // size = FishSize.Small; + // } + // else + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards."); + // return; + // } + + // if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant()))) + // { + // species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id; + // } + // else + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish."); + // return; + // } + + // if (Database.StoreFronts.Any(x=> x.StoreItemType == StoreItemType.Fish)) + // { + // var stores = Database.StoreFronts.Where(x => x.StoreItemType == StoreItemType.Fish).ToList(); + + // stores.Shuffle(); + + // var store = stores.FirstOrDefault(); + + // if(store.Items.Any(x=>x.Item.ToLowerInvariant() == item.ToLowerInvariant())) + // { + // var itm = store.Items.FirstOrDefault(x => x.Item.ToLowerInvariant() == item.ToLowerInvariant()); + + // if(itm.Price * amount <= KehUser.Money) + // { + // if (itm.Amount >= amount) + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to buy item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false); + // } + // else + // { + // await ReplyAsync("Whoa slow down there buckaroo, they ain't selling that much, go sit in the corner and think about what you've done").ConfigureAwait(false); + // } + // } + // else + // { + // await ReplyAsync("Nigger slow down, you aint got the cash monee to make that purchase smh frfr onjah").ConfigureAwait(false); + // } + // } + // } + // else + // { + // await ReplyAsync("No one is selling, so you can't buy lmao, big stinky"); + // } + // } + // else + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false); + // } + // } + //} + //[Command("tradesell")] + //public async Task TradingSell(int amount, string itemtype, int price, [Remainder] string item) + //{ + // string contents = "trade info"; + // FishSize size = 0; + // FishSpecies species = 0; + // List fishes = Fishing.GetFishList(); + // if (itemtype.ToLowerInvariant() == "fish") + // { + // if (item.ToLowerInvariant().Contains("large")) + // { + // size = FishSize.Large; + // } + // else if (item.ToLowerInvariant().Contains("medium")) + // { + // size = FishSize.Medium; + // } + // else if (item.ToLowerInvariant().Contains("small")) + // { + // size = FishSize.Small; + // } + // else + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards."); + // return; + // } + // if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant()))) + // { + // species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id; + // } + // else + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish."); + // return; + // } + // contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price / 10000d}%\n"; + + // await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to sell item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false); + + // await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false); + // } + // else + // { + // await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false); + // } + //} + //[Command("tradeoffers")] + //public async Task ShowOffers(bool localOffers = true) + //{ + // using (var database = new ApplicationDbContextFactory().CreateDbContext()) + // { + // string message = ""; + // if (localOffers) + // { + + // } + // } + //} - await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false); - } - else - { - await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false); - } - } [Command("balance"),Alias("bal","money")] public async Task Shekels([Remainder] IUser otherUser = null) { diff --git a/Kehyeedra3/Extensions.cs b/Kehyeedra3/Extensions.cs index b8c3868..cf15311 100644 --- a/Kehyeedra3/Extensions.cs +++ b/Kehyeedra3/Extensions.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Security.Cryptography; namespace Kehyeedra3 { @@ -11,5 +13,25 @@ namespace Kehyeedra3 public static DateTime FromYeedraStamp(this ulong time) => YeedraTime.AddSeconds(Convert.ToDouble(time)); + + //https://stackoverflow.com/a/1262619 + public static void Shuffle(this IList list) + { + using (RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider()) + { + int n = list.Count; + while (n > 1) + { + byte[] box = new byte[1]; + do provider.GetBytes(box); + while (!(box[0] < n * (byte.MaxValue / n))); + int k = (box[0] % n); + n--; + T value = list[k]; + list[k] = list[n]; + list[n] = value; + } + } + } } } \ No newline at end of file diff --git a/Kehyeedra3/Kehyeedra3.csproj b/Kehyeedra3/Kehyeedra3.csproj index 5025f2f..7be0c79 100644 --- a/Kehyeedra3/Kehyeedra3.csproj +++ b/Kehyeedra3/Kehyeedra3.csproj @@ -6,6 +6,7 @@ + diff --git a/Kehyeedra3/Migrations/20200330063400_store.Designer.cs b/Kehyeedra3/Migrations/20200330063400_store.Designer.cs new file mode 100644 index 0000000..0ae4b25 --- /dev/null +++ b/Kehyeedra3/Migrations/20200330063400_store.Designer.cs @@ -0,0 +1,145 @@ +// +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("20200330063400_store")] + partial class store + { + 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.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.StoreInventory", b => + { + b.HasOne("Kehyeedra3.Services.Models.StoreFront", null) + .WithMany("Items") + .HasForeignKey("StoreFrontId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Kehyeedra3/Migrations/20200330063400_store.cs b/Kehyeedra3/Migrations/20200330063400_store.cs new file mode 100644 index 0000000..fe175e4 --- /dev/null +++ b/Kehyeedra3/Migrations/20200330063400_store.cs @@ -0,0 +1,61 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Kehyeedra3.Migrations +{ + public partial class store : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "StoreFronts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + StoreItemType = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StoreFronts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "StoreInventory", + columns: table => new + { + InvId = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Item = table.Column(nullable: true), + Amount = table.Column(nullable: false), + Price = table.Column(nullable: false), + StoreFrontId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_StoreInventory", x => x.InvId); + table.ForeignKey( + name: "FK_StoreInventory_StoreFronts_StoreFrontId", + column: x => x.StoreFrontId, + principalTable: "StoreFronts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_StoreInventory_StoreFrontId", + table: "StoreInventory", + column: "StoreFrontId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "StoreInventory"); + + migrationBuilder.DropTable( + name: "StoreFronts"); + } + } +} diff --git a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs index 0835fb9..4f31998 100644 --- a/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using Kehyeedra3; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -65,6 +66,48 @@ namespace Kehyeedra3.Migrations 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") @@ -87,6 +130,13 @@ namespace Kehyeedra3.Migrations b.ToTable("Users"); }); + + 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/Services/Models/StoreFront.cs b/Kehyeedra3/Services/Models/Store.cs similarity index 85% rename from Kehyeedra3/Services/Models/StoreFront.cs rename to Kehyeedra3/Services/Models/Store.cs index e2fb5d2..31da265 100644 --- a/Kehyeedra3/Services/Models/StoreFront.cs +++ b/Kehyeedra3/Services/Models/Store.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; namespace Kehyeedra3.Services.Models { public class StoreFront { - public ulong Id { get; set; } = 0; + [Key] + public ulong Id { get; set; } public ulong UserId { get; set; } = 0; public StoreItemType StoreItemType { get; set; } = 0; @@ -20,9 +22,8 @@ namespace Kehyeedra3.Services.Models public class StoreInventory { - public ulong ItemId { get; set; } = 0; - public ulong UserId { get; set; } = 0; - public StoreItemType StoreItemType { get; set; } = 0; + [Key] + public ulong InvId { get; set; } public string Item { get; set; } = ""; public int Amount { get; set; } = 0; public int Price { get; set; } = 0; @@ -30,14 +31,15 @@ namespace Kehyeedra3.Services.Models public class ItemOffer { + [Key] public ulong OfferId { get; set; } public ulong BuyerId { get; set; } public ulong StoreId { get; set; } - public StoreItemType StoreType { get; set; } public ulong ItemId { get; set; } public int Amount { get; set; } public int OfferAmount { get; set; } public bool IsPurchaseFromStore { get; set; } + public bool IsSellOffer { get; set; } = false; } public static class StoreUtilities diff --git a/Kehyeedra3/Services/ReminderService.cs b/Kehyeedra3/Services/ReminderService.cs index 1ab2439..f15930b 100644 --- a/Kehyeedra3/Services/ReminderService.cs +++ b/Kehyeedra3/Services/ReminderService.cs @@ -20,7 +20,7 @@ namespace Kehyeedra3.Services List toRemove = new List(); while (true) { - if(Database.Reminders.Any() && Bot._bot != null && Bot._bot.Shards.All(x=>x.ConnectionState == Discord.ConnectionState.Connected)) + if(Database.Reminders.Any() && Bot._bot != null && Bot._bot.ConnectionState == Discord.ConnectionState.Connected) { foreach(var x in Database.Reminders) {