Exemplo 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);
        }
Exemplo n.º 2
0
        public static void Run()
        {
            Console.WriteLine("----- Pokémon Battle Engine - AI Battle Demo -----");
            try
            {
                _writer = new StreamWriter(new FileStream(LogFile, FileMode.Create, FileAccess.Write));
            }
            catch (Exception e)
            {
                Console.WriteLine($"Cannot open \"{LogFile}\" for writing.");
                Console.WriteLine(e.Message);
                return;
            }

            PBESettings settings = PBESettings.DefaultSettings;
            //var settings = new PBESettings { NumMoves = 8, MaxPartySize = 10 };
            //settings.MakeReadOnly();
            PBELegalPokemonCollection p0, p1;

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

            _battle = new PBEBattle(PBEBattleFormat.Double, settings, new PBETrainerInfo(p0, "Trainer 0"), new PBETrainerInfo(p1, "Trainer 1"),
                                    battleTerrain: PBEDataProvider.GlobalRandom.RandomBattleTerrain());
            _battle.OnNewEvent     += PBEBattle.ConsoleBattleEventHandler;
            _battle.OnNewEvent     += Battle_OnNewEvent;
            _battle.OnStateChanged += Battle_OnStateChanged;
            _oldWriter              = Console.Out;
            Console.SetOut(_writer);
            new Thread(() =>
            {
                try
                {
                    _battle.Begin();
                }
                catch (Exception e)
                {
                    CatchException(e);
                }
            })
            {
                Name = "Battle Thread"
            }.Start();
        }