Beispiel #1
0
        public async Task Skins(IUser u, int page = 1)
        {
            UserData user  = GetUserData(u.Id);
            string   inv   = "";
            int      total = 0;
            int      pages = (int)Math.Ceiling(user.skins.Count / (float)configs.item_displayed_per_page);

            if (page > pages)
            {
                await QuickEmbed($"{u.Mention} only has {pages} pages of skins!");

                return;
            }

            for (int i = configs.item_displayed_per_page * page - configs.item_displayed_per_page;
                 i < user.skins.Count && i < configs.item_displayed_per_page * page;
                 i++)
            {
                SkinInstance item = user.skins[i];
                inv   += $"[{i}] - **${item.worth}** ``{item.ToString()}`` \n";
                total += item.worth;
            }

            var e = new EmbedBuilder();

            e.WithDescription($"{u.Mention}'s skins")
            .AddField("---------------", inv)
            .AddField("Inventory Worth:", $"**${total}**")
            .WithFooter(x => x.Text = $"Displaying page {page} / {pages}");

            await ReplyAsync(embed : e.Build());
        }
Beispiel #2
0
        public async Task SellSkinNo(int index)
        {
            UserData user = GetUserData(Context.Message.Author.Id);

            if (index < 0)
            {
                await EnterNonNegativeValue();

                return;
            }
            if (user.skins.Count == 0)
            {
                await QuickEmbed("You have no skins to sell!");

                return;
            }
            if (user.skins.Count <= index)
            {
                await QuickEmbed($"Please enter a number between 0 and {user.skins.Count - 1}");

                return;
            }

            SkinInstance skin = user.skins[index];

            user.skins.RemoveAt(index);
            user.cash += skin.worth;
            ChangeUserData(Context.Message.Author.Id, user);

            await QuickEmbed($"{Context.Message.Author.Mention} just sold a {skin.ToString()} for **${skin.worth}**");
        }
Beispiel #3
0
        public async Task BuyCase(int n)
        {
            UserData user = GetUserData(Context.Message.Author.Id);

            if (CSGOConfigs.config.caseprice > user.cash)
            {
                await QuickEmbed($"Insufficient funds! A case costs ``${CSGOConfigs.config.caseprice}``");

                return;
            }
            if (n >= Cases.cases.Length || n < 0)
            {
                await QuickEmbed($"Please enter a number between 0 and {Cases.cases.Length - 1}");

                return;
            }

            Console.WriteLine($"There are {Cases.cases.Length} cases aval");

            user.cash -= CSGOConfigs.config.caseprice;
            SkinInstance skin = Cases.cases[n].OpenCase();

            user.skins.Add(skin);

            ChangeUserData(Context.Message.Author.Id, user);

            var embed = new EmbedBuilder();

            embed.WithDescription($"{Context.Message.Author.Mention} just unboxed a")
            .AddField("---------------", $"**{skin.ToString()}** \n" +
                      $"from a {Cases.cases[n].name}!\n" +
                      $"Value **${skin.worth}**")
            .WithColor(CSGOConfigs.GetColor(skin.skinData.rarity));

            if (skin.skinData.imageURL != "")
            {
                embed.WithImageUrl(skin.skinData.imageURL);
            }


            await ReplyAsync(embed : embed.Build());
        }