Ejemplo n.º 1
0
        public static async Task<WaifuShop> CreateNewShop(ulong guildId, ShopType type)
        {
            var date = System.DateTime.Now.Date;
            if (DateTime.Now.Hour >= 12)
                date = date.AddHours(12);

            WaifuShop shop = new WaifuShop
            {
                GeneratedDate = date,
                GuildId = guildId,
                Type = type
            };

            List<ShopWaifu> waifus = null;

            switch (type)
            {
                case ShopType.Waifu:
                    waifus = await GenerateWaifuShopList(guildId);
                    break;
                case ShopType.Gacha:
                    waifus = await GenerateGachaShopList(guildId);
                    break;
                default:
                    return null;
            }

            shop.ShopWaifus = waifus;
            return shop;
        }
Ejemplo n.º 2
0
        public async Task ModShop([Remainder] string str = "")
        {
            WaifuShop shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Mod);

            int              count  = Constants.shoplimitedamount + Constants.shopt1amount + Constants.shopt2amount + Constants.shopt3amount;
            string           prefix = Program.GetPrefix(Context);
            List <ShopWaifu> waifus = new List <ShopWaifu>();

            if (shop != null)
            {
                waifus = shop.ShopWaifus;
            }

            waifus = waifus.OrderBy(x => x.Waifu.Tier).ThenBy(x => x.Waifu.Source).ThenBy(x => x.Waifu.Name).ToList();

            if (waifus.Count <= count)
            {
                var eb = WaifuUtil.NewShopEmbed(waifus, prefix, Context.Guild.Id, ShopType.Mod);
                await Context.Channel.SendMessageAsync("", false, eb.Build());

                return;
            }

            await PagedReplyAsync(WaifuUtil.PaginatedShopMessage(waifus, count, prefix, Context.Guild.Id, ShopType.Mod));
        }
Ejemplo n.º 3
0
        public async Task GachaShop([Remainder] string str = "")
        {
            WaifuShop shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Gacha);

            string prefix = Program.GetPrefix(Context);
            var    waifus = shop.ShopWaifus.OrderByDescending(x => x.Limited).ThenBy(x => x.Waifu.Tier).ThenBy(x => x.Waifu.Source).ToList();

            var eb = WaifuUtil.NewShopEmbed(waifus, prefix, Context.Guild.Id, ShopType.Gacha);
            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }
Ejemplo n.º 4
0
        // Waifus Read/Write
        public static async Task<WaifuShop> GetShop(ulong guildId, ShopType type, bool overrideNew = false)
        {
            WaifuShop shop = null;
            try
            {
                shop = await WaifuShopDb.GetWaifuShop(guildId, type);
            }
            catch { }

            if (type == ShopType.Mod)
            {
                // Create mod shop if doesn't exist
                if (shop == null)
                {
                    shop = new WaifuShop
                    {
                        GeneratedDate = DateTime.Now,
                        GuildId = guildId,
                        Type = type,
                        ShopWaifus = new List<ShopWaifu>()
                    };
                    shop = await WaifuShopDb.AddShop(shop);
                }
                return shop;
            }

            if (overrideNew || shop == null || shop.GeneratedDate.AddHours(12) < DateTime.Now)
            {
                var newShop = await CreateNewShop(guildId, type);
                await WaifuShopDb.DeleteShop(guildId, type);
                await WaifuShopDb.AddShop(newShop);
                if (Program.Development == false)
                    _ = Task.Run(() => NotifyWishlist(newShop.ShopWaifus.Select(x => x.Waifu), guildId));
                return newShop;
            }

            return shop;
        }
Ejemplo n.º 5
0
 public static WaifuShop OrderWaifuShop(this WaifuShop shop)
 {
     shop.ShopWaifus = OrderWaifuShop(shop.ShopWaifus, shop.Type);
     return shop;
 }