Ejemplo n.º 1
0
        public async Task Rps(RpsPick pick, long amount = 0)
        {
            long oldAmount = amount;

            if (!await CheckBetOptional(amount) || (amount == 1))
            {
                return;
            }

            Func <RpsPick, string> getRpsPick = (p) =>
            {
                switch (p)
                {
                case RpsPick.R:
                    return("🚀");

                case RpsPick.P:
                    return("📎");

                default:
                    return("✂️");
                }
            };
            var embed = new EmbedBuilder();

            var    nadekoPick = (RpsPick) new NadekoRandom().Next(0, 3);
            string msg;

            if (pick == nadekoPick)
            {
                embed.WithOkColor();
                msg = GetText("rps_draw", getRpsPick(pick));
            }
            else if ((pick == RpsPick.Paper && nadekoPick == RpsPick.Rock) ||
                     (pick == RpsPick.Rock && nadekoPick == RpsPick.Scissors) ||
                     (pick == RpsPick.Scissors && nadekoPick == RpsPick.Paper))
            {
                embed.WithOkColor();
                amount = (long)(amount * _bc.BotConfig.BetflipMultiplier);
                msg    = GetText("rps_win", Context.Client.CurrentUser.Mention,
                                 getRpsPick(nadekoPick), getRpsPick(pick));
            }
            else
            {
                embed.WithErrorColor();
                amount = 0;
                msg    = GetText("rps_win", Context.User.Mention, getRpsPick(pick),
                                 getRpsPick(nadekoPick));
            }

            embed
            .WithDescription(msg);

            if (oldAmount > 0)
            {
                embed.AddField(GetText("won"), amount);
            }

            await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
        public async Task Rps(RpsPick pick, ShmartNumber amount = default)
        {
            long oldAmount = amount;

            if (!await CheckBetOptional(amount) || (amount == 1))
            {
                return;
            }

            string getRpsPick(RpsPick p)
            {
                switch (p)
                {
                case RpsPick.R:
                    return("🚀");

                case RpsPick.P:
                    return("📎");

                default:
                    return("✂️");
                }
            }

            var embed = new EmbedBuilder();

            var KotocornPick = (RpsPick) new KotocornRandom().Next(0, 3);

            if (amount > 0)
            {
                if (!await _cs.RemoveAsync(Context.User.Id,
                                           "Rps-bet", amount, gamble: true))
                {
                    await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);

                    return;
                }
            }

            string msg;

            if (pick == KotocornPick)
            {
                await _cs.AddAsync(Context.User.Id,
                                   "Rps-draw", amount, gamble : true);

                embed.WithOkColor();
                msg = GetText("rps_draw", getRpsPick(pick));
            }
            else if ((pick == RpsPick.Paper && KotocornPick == RpsPick.Rock) ||
                     (pick == RpsPick.Rock && KotocornPick == RpsPick.Scissors) ||
                     (pick == RpsPick.Scissors && KotocornPick == RpsPick.Paper))
            {
                amount = (long)(amount * _bc.BotConfig.BetflipMultiplier);
                await _cs.AddAsync(Context.User.Id,
                                   "Rps-win", amount, gamble : true);

                embed.WithOkColor();
                embed.AddField(GetText("won"), amount);
                msg = GetText("rps_win", Context.User.Mention,
                              getRpsPick(pick), getRpsPick(KotocornPick));
            }
            else
            {
                embed.WithErrorColor();
                amount = 0;
                msg    = GetText("rps_win", Context.Client.CurrentUser.Mention, getRpsPick(KotocornPick),
                                 getRpsPick(pick));
            }

            embed
            .WithDescription(msg);

            await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
        }