public static async Task<List<ShopWaifu>> GenerateGachaShopList(ulong guildId) { int t1amount = Constants.gachat1amount; int t2amount = Constants.gachat2amount; int t3amount = Constants.gachat3amount; int pages = 1; if (PremiumDb.IsPremium(guildId, ProType.GuildPlus) || PremiumDb.IsPremium(guildId, ProType.Guild)) pages = 3; int randomizerMultiplier = 7 - pages; var waifus = new List<Waifu>(); var gachaSource = GetGachaSources(); waifus.AddRange(await WaifuDb.RandomWaifus(1, t1amount * pages * randomizerMultiplier, includeSource: gachaSource)); waifus.AddRange(await WaifuDb.RandomWaifus(2, t2amount * pages * randomizerMultiplier, includeSource: gachaSource)); waifus.AddRange(await WaifuDb.RandomWaifus(3, t3amount * pages * randomizerMultiplier, includeSource: 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); } waifus.AddRange(wishlists.Select(x => x.Waifu)); ShopWaifu item = null; List<ShopWaifu> finalWaifus = new List<ShopWaifu>(); var rnd = new Random(); int r = 0; for (int k = 0; k < Constants.gachatotal * pages; k++) { r = rnd.Next(0, waifus.Count); item = new ShopWaifu { Waifu = waifus.ElementAt(r), Limited = -1, BoughtBy = 0 }; finalWaifus.Add(item); waifus.RemoveAll(x => x.Name.Equals(waifus[r].Name)); } return finalWaifus.OrderBy(x => x.Waifu.Tier).ToList(); }
// LOOTBOX public static async Task <Waifu> UnboxWaifu(LootboxStat box, bool isPremium = false, ulong userId = 0, ulong guildId = 0) { var rnd = new Random(); List <Waifu> waifus = new List <Waifu>(); int randomizerAmount = 7; int tier = box.GetRandomTier(); waifus.AddRange(await WaifuDb.RandomWaifus(tier, randomizerAmount)); if (isPremium) { waifus.AddRange((await WaifuWishlistDb.GetWishlist(userId, guildId)).Where(x => x.Tier == tier)); } return(waifus[rnd.Next(waifus.Count)]); }
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; }