public static async Task<List<ShopWaifu>> GenerateWaifuShopList(ulong guildId) { int limitedamount = Constants.shoplimitedamount; int t1amount = Constants.shopt1amount; int t2amount = Constants.shopt2amount; int t3amount = Constants.shopt3amount; int pages = 1; if (PremiumDb.IsPremium(guildId, ProType.GuildPlus) || PremiumDb.IsPremium(guildId, ProType.Guild)) pages = 3; int randomizerMultiplier = 7 - pages; var gachaSource = GetGachaSources(); var tier0 = await WaifuDb.GetWaifusByTier(0); var tier1 = await WaifuDb.RandomWaifus(1, (limitedamount + t1amount) * pages * randomizerMultiplier, excludeSource: gachaSource); var tier2 = await WaifuDb.RandomWaifus(2, t2amount * pages * randomizerMultiplier, excludeSource: gachaSource); var tier3 = await WaifuDb.RandomWaifus(3, t3amount * pages * randomizerMultiplier, excludeSource: gachaSource); var wishlists = await WaifuWishlistDb.GetAllPremiumWishlists(guildId, ProType.Pro); wishlists.RemoveAll(x => gachaSource.Contains(x.Waifu.Source)); var ids = wishlists.Select(x => x.UserId).Distinct().ToArray(); var guild = Program.GetClient().GetGuild(guildId); foreach (var id in ids) { SocketGuildUser user = null; try { user = guild.GetUser(id); } catch { wishlists.RemoveAll(x => x.UserId == id); } if (user == null) wishlists.RemoveAll(x => x.UserId == id); } tier1.AddRange(wishlists.Where(x => x.Waifu.Tier == 1).Select(x => x.Waifu)); tier2.AddRange(wishlists.Where(x => x.Waifu.Tier == 2).Select(x => x.Waifu)); tier3.AddRange(wishlists.Where(x => x.Waifu.Tier == 3).Select(x => x.Waifu)); ShopWaifu item = null; List<ShopWaifu> waifus = new List<ShopWaifu>(); var rnd = new Random(); int r = 0; for (int k = 0; k < pages; k++) { // LIMITED WAIFU for (int i = 0; i < limitedamount; i++) { r = rnd.Next(0, tier1.Count); item = new ShopWaifu { Waifu = tier1.ElementAt(r), Discount = GenerateDiscount(), Limited = 1, BoughtBy = 0 }; waifus.Add(item); tier1.RemoveAll(x => x.Name.Equals(tier1[r].Name)); } // TIER 0 AND 1 WAIFUS for (int i = 0; i < t1amount; i++) { r = rnd.Next(0, tier1.Count + tier0.Count); if (r < tier1.Count) { item = new ShopWaifu { Waifu = tier1.ElementAt(r), Limited = -1, BoughtBy = 0 }; tier1.RemoveAll(x => x.Name.Equals(tier1[r].Name)); } else { r -= tier1.Count; item = new ShopWaifu { Waifu = tier0[r], Limited = -1, BoughtBy = 0 }; tier0.RemoveAll(x => x.Name.Equals(tier0[r].Name)); } waifus.Add(item); } // TIER 2 WAIFUS for (int i = 0; i < t2amount; i++) { r = rnd.Next(0, tier2.Count); item = new ShopWaifu { Waifu = tier2.ElementAt(r), Limited = -1, BoughtBy = 0 }; waifus.Add(item); tier2.RemoveAll(x => x.Name.Equals(tier2[r].Name)); } // TIER 3 WAIFUS for (int i = 0; i < t3amount; i++) { r = rnd.Next(0, tier3.Count); item = new ShopWaifu { Waifu = tier3.ElementAt(r), Limited = -1, BoughtBy = 0 }; waifus.Add(item); tier3.RemoveAll(x => x.Name.Equals(tier3[r].Name)); } } return waifus; }