Example #1
0
 public async Task RandomizeShop()
 {
     ItemDatabase.RandomizeShop();
     await Shop();
 }
Example #2
0
        private async Task OpenChestAsync(SocketCommandContext Context, ChestQuality cq, uint bonusCount = 0)
        {
            var user = UserAccounts.GetAccount(Context.User);
            var inv  = user.Inv;

            if (inv.IsFull)
            {
                var emb = new EmbedBuilder();
                emb.WithDescription(":x: Inventory capacity reached!");
                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            if (!inv.RemoveBalance(bonusCount))
            {
                var emb = new EmbedBuilder();
                emb.WithDescription(":x: Not enough Funds!");
                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            if (!inv.OpenChest(cq))
            {
                var emb = new EmbedBuilder();

                if (cq == ChestQuality.Daily)
                {
                    emb.WithDescription($":x: No {cq} Chests remaining! Next Daily Chest in: {DateTime.Today.AddDays(1).Subtract(DateTime.Now).ToString(@"hh\h\ mm\m")}");
                }
                else
                {
                    emb.WithDescription($":x: No {cq} Chests remaining!");
                }

                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            double bonus = (bonusCount > 0 ? Math.Log(bonusCount) / Math.Log(5) : 0);
            var    value = user.LevelNumber;

            if (cq != ChestQuality.Daily)
            {
                value = (((uint)cq) + 1) * 11;
            }

            var itemName = ItemDatabase.GetRandomItem(value, bonus, (int)cq == 3 || (int)cq == 4 || ((int)cq == 5 && value >= 40) ? ItemDatabase.RandomItemType.Artifact : ItemDatabase.RandomItemType.Any);
            var item     = ItemDatabase.GetItem(itemName);

            var embed = new EmbedBuilder();

            embed.WithDescription($"Opening {cq} Chest {Inventory.ChestIcons[cq]}...");
            embed.WithColor(Colors.Get("Iodem"));
            var msg = await Context.Channel.SendMessageAsync("", false, embed.Build());

            embed = new EmbedBuilder();
            embed.WithColor(item.Color);
            embed.WithDescription($"{Inventory.ChestIcons[cq]} You found a {item.Name} {item.IconDisplay}");
            await Task.Delay((int)cq * 700);

            _ = msg.ModifyAsync(m => m.Embed = embed.Build());
            inv.Add(item.Name);
        }
Example #3
0
        private async Task OpenChestAsync(SocketCommandContext Context, ChestQuality cq)
        {
            var user = EntityConverter.ConvertUser(Context.User);
            var inv  = user.Inv;

            if (inv.IsFull)
            {
                var emb = new EmbedBuilder();
                emb.WithDescription(":x: Inventory capacity reached!");
                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }

            if (!inv.OpenChest(cq))
            {
                var emb = new EmbedBuilder();

                if (cq == ChestQuality.Daily)
                {
                    emb.WithDescription($":x: No {cq} Chests remaining! Next Daily Chest in: {DateTime.Today.AddDays(1).Subtract(DateTime.Now):hh\\h\\ mm\\m}");
                }
                else
                {
                    emb.WithDescription($":x: No {cq} Chests remaining!");
                }

                emb.WithColor(Colors.Get("Error"));
                await Context.Channel.SendMessageAsync("", false, emb.Build());

                return;
            }
            var itemName     = "";
            var dailyRewards = new[] { 0, 0, 1, 1, 2 };

            if (cq == ChestQuality.Daily)
            {
                var value = user.LevelNumber;
                itemName = ItemDatabase.GetRandomItem((ItemRarity)(dailyRewards[inv.DailiesInARow % dailyRewards.Length] + Math.Min(2, value / 33)));
            }
            else
            {
                var rarity = ItemDatabase.ChestValues[cq].GenerateReward();
                itemName = ItemDatabase.GetRandomItem(rarity);
            }

            var item = ItemDatabase.GetItem(itemName);

            inv.Add(item.Name);
            UserAccountProvider.StoreUser(user);

            var embed = new EmbedBuilder();

            embed.WithDescription($"Opening {cq} Chest {Inventory.ChestIcons[cq]}...");

            embed.WithColor(Colors.Get("Iodem"));
            var msg = await Context.Channel.SendMessageAsync("", false, embed.Build());

            embed = new EmbedBuilder();
            embed.WithColor(item.Color);
            if (cq == ChestQuality.Daily)
            {
                embed.WithFooter($"Current Reward: {inv.DailiesInARow % dailyRewards.Length + 1}/{dailyRewards.Length} | Overall Streak: {inv.DailiesInARow + 1}");
            }
            embed.WithDescription($"{Inventory.ChestIcons[cq]} You found a {item.Name} {item.IconDisplay}");

            await Task.Delay((int)cq * 700);

            _ = msg.ModifyAsync(m => m.Embed = embed.Build());

            var message = await Context.Channel.AwaitMessage(m => m.Author == Context.User);

            if (message != null && message.Content.Equals("Sell", StringComparison.OrdinalIgnoreCase))
            {
                _ = SellItem(item.Name);
            }
        }