Exemple #1
0
        public async Task Dice([Remainder] string Input = null)
        {
            try
            {
                SocketUser contUser = Context.User;
                UserData   ud       = ExtensionMethods.FindPerson(contUser.Id);
                if (Input == null)
                {
                    await Context.Channel.SendMessageAsync(string.Concat("You forgot to place a bet! Bet some pudding will ya? Minimum bet is 10. Maximum bet is (25 + amount of cards owned (from the nepbot card collection game!)) * your non-RP level which for you is: ", _math.TotalBet(ud.NonLevel, ud).ToString()));

                    return;
                }
                ulong betAmt = 0;
                if (!ulong.TryParse(Input, out betAmt))
                {
                    await Context.Channel.SendMessageAsync("Umm... you have to enter ONLY a number as a bet amount! !nep dice (bet amount).");

                    return;
                }
                if (!_math.CanBet(betAmt, ud.Pudding) || betAmt > _math.TotalBet(ud.NonLevel, ud))
                {
                    await Context.Channel.SendMessageAsync(string.Concat("Aww you only have ", ud.Pudding.ToString(), ". Minimum bet is 10. Maximum bet is (25 + amount of cards owned (from the nepbot card collection game!)) * your non-RP level which is: ", _math.TotalBet(ud.NonLevel, ud).ToString()));

                    return;
                }
                string[] diceStrings = new string[]
                {
                    "",
                    "<:1_:574108098424471572>",
                    "<:2_:574108098462089216>",
                    "<:3_:574108098508357632>",
                    "<:4_:574108098441248768>",
                    "<:5_:574108098353037312>",
                    "<:6_:574108098386460672>"
                };
                int           dealerTotal  = 0;
                int           playerTotal  = 0;
                StringBuilder dealerString = new StringBuilder();
                StringBuilder playerString = new StringBuilder();
                for (int i = 0; i < 5; i++)
                {
                    int dRand = UtilityClass.ReturnRandom(1, diceStrings.Length);
                    int pRand = UtilityClass.ReturnRandom(1, diceStrings.Length);
                    dealerTotal += dRand;
                    dealerString.Append(diceStrings[dRand]).Append(" ");
                    playerTotal += pRand;
                    playerString.Append(diceStrings[pRand]).Append(" ");
                }
                string msg = string.Empty;
                if (dealerTotal > playerTotal)
                {
                    ud.Pudding -= betAmt;
                    msg         = $"{ExtensionMethods.NeptuneEmojis(true)}**Neptune's Total: {dealerTotal}**\n{dealerString}\n**Your Total: {playerTotal}**\n{playerString}\nYou lost! Sorry pal, try again! You lost {betAmt} pudding! Your total pudding is now {ud.Pudding}.";
                }
                else if (playerTotal > dealerTotal)
                {
                    ud.Pudding += betAmt;
                    msg         = $"{ExtensionMethods.NeptuneEmojis(false)}**Neptune's Total: {dealerTotal}**\n{dealerString}\n**Your Total: {playerTotal}**\n{playerString}\nYou win! Congrats! You won {betAmt} pudding! Your total pudding is now {ud.Pudding}.";
                }
                else if (playerTotal == dealerTotal)
                {
                    msg = $"{ExtensionMethods.NeptuneEmojis(false)}**Neptune's Total: {dealerTotal}**\n{dealerString}\n**Your Total: {playerTotal}**\n{playerString}\nIt was a tie... welp! Nothing lost, nothing gained! Your bet of {betAmt} pudding was returnd to you!";
                }
                await Context.Channel.SendMessageAsync(msg);
            }
            catch (Exception i)
            {
                Console.WriteLine(string.Format(">>> {0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}", new object[]
                {
                    i.Message,
                    i.TargetSite,
                    i.Source,
                    i.InnerException,
                    i.StackTrace,
                    i.HResult,
                    i.Data,
                    i.HelpLink
                }), false, null, null);
            }
        }