コード例 #1
0
ファイル: AnimalRacing.cs プロジェクト: xheres/NadekoBot
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Prefix + "race")
            .Description($"Starts a new animal race. | `{Prefix}race`")
            .Do(e =>
            {
                var ar = new AnimalRace(e.Server.Id, e.Channel);
                if (ar.Fail)
                {
                    return;
                }
            });


            cgb.CreateCommand(Prefix + "joinrace")
            .Alias(Prefix + "jr")
            .Description($"Joins a new race. You can specify an amount of flowers for betting (optional). You will get YourBet*(participants-1) back if you win. | `{Prefix}jr` or `{Prefix}jr 5`")
            .Parameter("amount", ParameterType.Optional)
            .Do(async e =>
            {
                int amount;
                if (!int.TryParse(e.GetArg("amount"), out amount) || amount < 0)
                {
                    amount = 0;
                }

                var userFlowers = GamblingModule.GetUserFlowers(e.User.Id);

                if (userFlowers < amount)
                {
                    await e.Channel.SendMessage($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
                    return;
                }

                if (amount > 0)
                {
                    await FlowersHandler.RemoveFlowers(e.User, "BetRace", (int)amount, true).ConfigureAwait(false);
                }

                AnimalRace ar;
                if (!AnimalRaces.TryGetValue(e.Server.Id, out ar))
                {
                    await e.Channel.SendMessage("No race exists on this server");
                    return;
                }
                await ar.JoinRace(e.User, amount);
            });
        }
コード例 #2
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Prefix + "race")
            .Description($"Startet ein neues Tier-Rennen. | `{Prefix}race`")
            .Do(e =>
            {
                var ar = new AnimalRace(e.Server.Id, e.Channel);
                if (ar.Fail)
                {
                    return;
                }
            });

            cgb.CreateCommand(Prefix + "joinrace")
            .Alias(Prefix + "jr")
            .Description($"Tritt einem Rennen bei. Du kannst eine Anzahl an {MidnightBot.Config.CurrencyName} zum Wetten setzen (Optional). Du bekommst deine Wette*(Teilnehmer-1) zurück, wenn du gewinnst. | `{Prefix}jr` oder `{Prefix}jr 5`")
            .Parameter("amount", ParameterType.Optional)
            .Do(async e =>
            {
                int amount;
                if (!int.TryParse(e.GetArg("amount"), out amount) || amount < 0)
                {
                    amount = 0;
                }

                var userFlowers = GamblingModule.GetUserFlowers(e.User.Id);

                if (userFlowers < amount)
                {
                    await e.Channel.SendMessage($"{e.User.Mention} Du hast nicht genug {MidnightBot.Config.CurrencyName}. Du hast nur {userFlowers}{MidnightBot.Config.CurrencySign}.").ConfigureAwait(false);
                    return;
                }

                if (amount > 0)
                {
                    await FlowersHandler.RemoveFlowers(e.User, "BetRace", (int)amount, true).ConfigureAwait(false);
                }

                AnimalRace ar;

                if (!AnimalRaces.TryGetValue(e.Server.Id, out ar))
                {
                    await e.Channel.SendMessage("Es existiert kein Rennen auf diesem Server.");
                    return;
                }
                await ar.JoinRace(e.User, amount);
            });
        }