コード例 #1
0
            public async Task Challenge(SocketUser battler1)
            {
                if (battler1.Id == Context.User.Id)
                {
                    //
                }
                else if (BattleContext.GetBattleContext(Context.User) != null)
                {
                    await Context.Channel.SendMessageAsync($"{Context.User.Username} is already participating in a battle.");
                }
                else if (BattleContext.GetBattleContext(battler1) != null)
                {
                    await Context.Channel.SendMessageAsync($"{battler1.Username} is already participating in a battle.");
                }
                else
                {
                    PBESettings       settings = PBESettings.DefaultSettings;
                    PBEPokemonShell[] team0Party, team1Party;
                    // Completely Randomized Pokémon
                    team0Party = PBEUtils.CreateCompletelyRandomTeam(settings, true);
                    team1Party = PBEUtils.CreateCompletelyRandomTeam(settings, true);

                    var battle = new PBEBattle(PBEBattleFormat.Single, settings, 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);
                }
            }
コード例 #2
0
        public static void Test()
        {
            Console.WriteLine("----- Pokémon Battle Engine Test -----");

            var settings = new PBESettings {
                NumMoves = 12
            };

            PBEPokemonShell[] team0Party, team1Party;

            // Completely Randomized Pokémon
            team0Party = PBEUtils.CreateCompletelyRandomTeam(settings, true);
            team1Party = PBEUtils.CreateCompletelyRandomTeam(settings, true);

            // Predefined Pokémon

            /*team0Party = new PBEPokemonShell[]
             * {
             *  PBECompetitivePokemonShells.Zoroark_VGC,
             *  PBECompetitivePokemonShells.Volcarona_VGC,
             *  PBECompetitivePokemonShells.Vaporeon_VGC,
             *  PBECompetitivePokemonShells.Thundurus_VGC,
             *  PBECompetitivePokemonShells.Vanilluxe_VGC,
             *  PBECompetitivePokemonShells.Chandelure_VGC
             * };
             * team1Party = new PBEPokemonShell[]
             * {
             *  PBECompetitivePokemonShells.Arceus_Uber,
             *  PBECompetitivePokemonShells.Darkrai_Uber,
             *  PBECompetitivePokemonShells.Kyurem_White_Uber,
             *  PBECompetitivePokemonShells.Latias_VGC,
             *  PBECompetitivePokemonShells.Metagross_VGC,
             *  PBECompetitivePokemonShells.Victini_Uber
             * };*/

            var battle = new PBEBattle(PBEBattleFormat.Double, settings, team0Party, team1Party);

            battle.Teams[0].TrainerName = "Team 1";
            battle.Teams[1].TrainerName = "Team 2";
            battle.OnNewEvent          += PBEBattle.ConsoleBattleEventHandler;
            battle.OnStateChanged      += Battle_OnStateChanged;
            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;
            }
            oldWriter = Console.Out;
            Console.SetOut(writer);
            battle.Begin();
        }