Esempio n. 1
0
        private static async Task StartBattle(IGuild guild, SocketUser battler0, SocketUser battler1, string team0Name, string team1Name, string team0Mention, string team1Mention)
        {
            PBELegalPokemonCollection p0, p1;

            // Competitively Randomized Pokémon
            p0 = PBERandomTeamGenerator.CreateRandomTeam(3);
            p1 = PBERandomTeamGenerator.CreateRandomTeam(3);

            var battle = new PBEBattle(PBEBattleFormat.Single, PBESettings.DefaultSettings, new PBETrainerInfo(p0, team0Name), new PBETrainerInfo(p1, team1Name));

            var          bc      = new BattleContext(battle, battler0, battler1);
            ITextChannel channel = await ChannelHandler.CreateChannel(guild, $"battle-{bc.BattleId}");

            await channel.SendMessageAsync($"**Battle #{bc.BattleId} ― {team0Mention} vs {team1Mention}**");

            await bc.Begin(channel);
        }
Esempio n. 2
0
 public async Task Challenge(SocketUser battler1)
 {
     if (BattleContext.ActiveBattles.Any(b => b.Battlers.Contains(battler1)))
     {
         await Context.Channel.SendMessageAsync($"{battler1.Username} is already participating in a battle.");
     }
     else if (BattleContext.ActiveBattles.Any(b => b.Battlers.Contains(Context.User)))
     {
         await Context.Channel.SendMessageAsync($"{Context.User.Username} is already participating in a battle.");
     }
     else
     {
         PBEPokemonShell[] team0Party = PBECompetitivePokemonShells.CreateRandomTeam(PBESettings.DefaultSettings.MaxPartySize).ToArray();
         PBEPokemonShell[] team1Party = PBECompetitivePokemonShells.CreateRandomTeam(PBESettings.DefaultSettings.MaxPartySize).ToArray();
         PBEBattle         battle     = new PBEBattle(PBEBattleFormat.Single, PBESettings.DefaultSettings, team0Party, team1Party);
         battle.Teams[0].TrainerName = Context.User.Username;
         battle.Teams[1].TrainerName = battler1.Username;
         var battleContext = new BattleContext(battle, Context.User, battler1, Context.Channel);
     }
 }
Esempio n. 3
0
        public static Task AcceptChallenge(SocketCommandContext ctx)
        {
            async Task Do()
            {
                RemoveOldChallenges();

                SocketUser challengee = ctx.User;

                if (!(BattleContext.GetBattleContext(challengee) == null))
                {
                    return;
                }
                else
                {
                    Challenge c = GetChallenge(challengee);
                    if (c == null)
                    {
                        await ctx.Channel.SendMessageAsync($"{challengee.Mention} ― You have no pending challenges.");
                    }
                    else
                    {
                        SocketUser challenger = c.Challenger;
                        if (!(BattleContext.GetBattleContext(challenger) == null))
                        {
                            await PrintParticipating(challengee, challenger, ctx.Channel);
                        }
                        else
                        {
                            await StartBattle(c);
                        }
                    }
                }
            }

            lock (_matchmakingLockObj)
            {
                return(Do());
            }
        }
Esempio n. 4
0
 private Task OnGuildMemberUpdated(SocketGuildUser arg1, SocketGuildUser arg2)
 {
     BattleContext.OnGuildMemberUpdated(arg2);
     return(Task.CompletedTask);
 }
Esempio n. 5
0
 private async Task OnUserLeft(SocketGuildUser arg)
 {
     Matchmaking.OnUserLeft(arg);
     await BattleContext.OnUserLeft(arg);
 }