Exemplo n.º 1
0
        public async Task TradeAsync([Summary("Showdown Set")][Remainder] string content)
        {
            const int gen = 8;

            content = ReusableActions.StripCodeBlock(content);
            var set = new ShowdownSet(content);
            var sav = AutoLegalityExtensions.GetTrainerInfo(gen);

            var pkm  = sav.GetLegal(set, out var result);
            var la   = new LegalityAnalysis(pkm);
            var spec = GameInfo.Strings.Species[set.Species];
            var msg  = la.Valid
                ? $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!"
                : $"Oops! I wasn't able to create something from that. Here's my best attempt for that {spec}!";

            if (!la.Valid || !(pkm is PK8 pk8))
            {
                await ReplyAsync(msg).ConfigureAwait(false);

                return;
            }

            pk8.ResetPartyStats();

            var code = Info.GetRandomTradeCode();
            var sudo = Context.User.GetIsSudo();

            await AddTradeToQueueAsync(code, Context.User.Username, pk8, sudo).ConfigureAwait(false);
        }
Exemplo n.º 2
0
 public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel channel, string content)
 {
     content = ReusableActions.StripCodeBlock(content);
     var set = new ShowdownSet(content);
     var sav = AutoLegalityExtensions.GetTrainerInfo(set.Format);
     await channel.ReplyWithLegalizedSetAsync(sav, set).ConfigureAwait(false);
 }
Exemplo n.º 3
0
        public async Task TradeAsync([Summary("Showdown Set")][Remainder] string content)
        {
            var cfg     = Info.Hub.Config;
            var sudo    = Context.GetIsSudo(cfg);
            var allowed = sudo || (Context.GetHasRole(cfg.DiscordRoleCanTrade) && Info.CanQueue);

            if (!sudo && !Info.CanQueue)
            {
                await ReplyAsync("Sorry, I am not currently accepting queue requests!").ConfigureAwait(false);

                return;
            }

            if (!allowed)
            {
                await ReplyAsync("Sorry, you are not permitted to use this command!").ConfigureAwait(false);

                return;
            }

            const int gen = 8;

            content = ReusableActions.StripCodeBlock(content);
            var set = new ShowdownSet(content);
            var sav = AutoLegalityExtensions.GetTrainerInfo(gen);

            var pkm  = sav.GetLegal(set, out var result);
            var la   = new LegalityAnalysis(pkm);
            var spec = GameInfo.Strings.Species[set.Species];
            var msg  = la.Valid
                ? $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!"
                : $"Oops! I wasn't able to create something from that. Here's my best attempt for that {spec}!";

            if (!la.Valid || !(pkm is PK8 pk8))
            {
                await ReplyAsync(msg).ConfigureAwait(false);

                return;
            }

            pk8.ResetPartyStats();

            var code = Info.GetRandomTradeCode();

            await AddTradeToQueueAsync(code, Context.User.Username, pk8, sudo).ConfigureAwait(false);
        }