Beispiel #1
0
        private static void TestBoxNames(
            PKMN.PokemonPC PC
            )
        {
            int generation = Util.GameToGeneration(PC.Game);

            if (generation == 1)
            {
                Assert.AreEqual(PC.BoxNames.Count, 0);

                Assert.Throws <ApplicationException>(
                    delegate
                {
                    PC[0].Name = "ABCDEFGH";
                }
                    );
            }
            else
            {
                for (int i = 0; i < PC.Length; ++i)
                {
                    string boxName = String.Format("BOX{0}", i + 1);
                    PC[i].Name = boxName;
                }

                for (int i = 0; i < PC.BoxNames.Count; ++i)
                {
                    string expectedBoxName = String.Format("BOX{0}", i + 1);
                    Assert.AreEqual(PC.BoxNames[i], expectedBoxName);
                }
            }
        }
Beispiel #2
0
        private static void RandomizePokemon(
            PKMN.GameSave gameSave,
            PKMN.ItemEnumList itemList
            )
        {
            PKMN.Game game = gameSave.Game;

            PKMN.MoveEnumList    moveList    = PKMN.Database.Lists.MoveList(game);
            PKMN.SpeciesEnumList pokemonList = PKMN.Database.Lists.PokemonList(1, true);

            PKMN.PokemonParty party = gameSave.PokemonParty;
            for (int i = 0; i < 6; ++i)
            {
                party[i] = Util.GetRandomPokemon(game, itemList, moveList, pokemonList);
            }

            PKMN.PokemonPC PC = gameSave.PokemonPC;
            for (int i = 0; i < PC.Length; ++i)
            {
                PKMN.PokemonBox box = PC[i];
                for (int j = 0; j < box.Length; ++j)
                {
                    box[j] = Util.GetRandomPokemon(game, itemList, moveList, pokemonList);
                }
            }
        }
Beispiel #3
0
 public static void TestPokemonPC(
     PKMN.PokemonPC PC,
     PKMN.Game[] validOtherGames,
     PKMN.Game invalidOtherGame
     )
 {
     TestEmptyPokemonPC(PC);
     TestBoxNames(PC);
     TestSettingPokemonInBoxes(PC, validOtherGames, invalidOtherGame);
 }
Beispiel #4
0
 private static void TestEmptyPokemonPC(
     PKMN.PokemonPC PC
     )
 {
     for (int i = 0; i < PC.Length; ++i)
     {
         Assert.AreEqual(PC[i].Game, PC.Game);
         TestEmptyPokemonBox(PC[i]);
     }
 }
Beispiel #5
0
 private static void TestSettingPokemonInBoxes(
     PKMN.PokemonPC PC,
     PKMN.Game[] validOtherGames,
     PKMN.Game invalidOtherGame
     )
 {
     for (int i = 0; i < PC.Length; ++i)
     {
         TestSettingPokemon(PC[i], validOtherGames, invalidOtherGame);
         Assert.AreEqual(PC[i][0].Species, PKMN.Species.SQUIRTLE);
         Assert.AreEqual(PC[i][1].Species, PKMN.Species.CHARMANDER);
     }
 }
Beispiel #6
0
        public static void CompareGameSaves(
            PKMN.GameSave save1,
            PKMN.GameSave save2
            )
        {
            PKMN.Game game       = save1.Game;
            int       generation = Util.GameToGeneration(game);

            Assert.AreEqual(save1.Game, save2.Game);
            Assert.AreEqual(save1.TrainerName, save2.TrainerName);
            Assert.AreEqual(save1.TrainerID, save2.TrainerID);
            Assert.AreEqual(save1.TrainerPublicID, save2.TrainerPublicID);

            if (!IsGBGame(game))
            {
                Assert.AreEqual(save1.TrainerSecretID, save2.TrainerSecretID);
            }
            if (!IsMaleOnly(game))
            {
                Assert.AreEqual(save1.TrainerGender, save2.TrainerGender);
            }
            if (!IsRivalNameSet(game))
            {
                Assert.AreEqual(save1.RivalName, save2.RivalName);
            }

            Assert.AreEqual(save1.Money, save2.Money);

            Assert.AreEqual(save1.ItemBag.Count, save2.ItemBag.Count);
            foreach (string pocketName in save1.ItemBag.PocketNames)
            {
                CompareItemLists(
                    save1.ItemBag[pocketName],
                    save2.ItemBag[pocketName]
                    );
            }

            if (generation <= 3)
            {
                CompareItemLists(
                    save1.ItemPC,
                    save2.ItemPC
                    );
            }

            Assert.AreEqual(save1.PokemonParty.NumPokemon, save2.PokemonParty.NumPokemon);
            for (int i = 0; i < 6; ++i)
            {
                Util.ComparePokemon(
                    save1.PokemonParty[i],
                    save2.PokemonParty[i]
                    );
            }

            PKMN.PokemonPC pokemonPC1 = save1.PokemonPC;
            PKMN.PokemonPC pokemonPC2 = save2.PokemonPC;

            if (generation >= 2)
            {
                Assert.AreEqual(pokemonPC1.BoxNames.Count, pokemonPC2.BoxNames.Count);
                for (int i = 0; i < pokemonPC1.BoxNames.Count; ++i)
                {
                    Assert.AreEqual(pokemonPC1.BoxNames[i], pokemonPC2.BoxNames[i]);
                }
            }
            for (int i = 0; i < pokemonPC1.Length; ++i)
            {
                PKMN.PokemonBox pokemonBox1 = pokemonPC1[i];
                PKMN.PokemonBox pokemonBox2 = pokemonPC2[i];

                if (generation >= 2)
                {
                    Assert.AreEqual(pokemonBox1.Name, pokemonBox2.Name);
                }
                Assert.AreEqual(pokemonBox1.NumPokemon, pokemonBox2.NumPokemon);
                for (int j = 0; j < pokemonBox1.NumPokemon; ++j)
                {
                    Util.ComparePokemon(
                        pokemonBox1[j],
                        pokemonBox2[j]
                        );
                }
            }
            if (!IsGameGamecube(game))
            {
                ComparePokedexes(
                    save1.Pokedex,
                    save2.Pokedex
                    );
            }

            Assert.AreEqual(save1.NumericAttributes.Names, save2.NumericAttributes.Names);
            foreach (string attributeName in save1.NumericAttributes.Names)
            {
                Assert.AreEqual(
                    save1.NumericAttributes[attributeName],
                    save2.NumericAttributes[attributeName]
                    );
            }
            Assert.AreEqual(save1.StringAttributes.Names, save2.StringAttributes.Names);
            foreach (string attributeName in save1.StringAttributes.Names)
            {
                Assert.AreEqual(
                    save1.StringAttributes[attributeName],
                    save2.StringAttributes[attributeName]
                    );
            }
            Assert.AreEqual(save1.BooleanAttributes.Names, save2.BooleanAttributes.Names);
            foreach (string attributeName in save1.BooleanAttributes.Names)
            {
                Assert.AreEqual(
                    save1.BooleanAttributes[attributeName],
                    save2.BooleanAttributes[attributeName]
                    );
            }
        }
Beispiel #7
0
        private static void TestCommonFields(
            PKMN.GameSave gameSave
            )
        {
            PKMN.Game game = gameSave.Game;

            // Trainer name
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate
            {
                gameSave.TrainerName = "";
            }
                );
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate
            {
                gameSave.TrainerName = "LibPKMNLibPKMN";
            }
                );
            gameSave.TrainerName = "LibPKMN";
            Assert.AreEqual(gameSave.TrainerName, "LibPKMN");

            // Trainer ID
            gameSave.TrainerID = IsGBGame(game) ? DEFAULT_TRAINER_PID : PKMN.Pokemon.DefaultTrainerID;
            TestTrainerID(gameSave);
            gameSave.TrainerPublicID = DEFAULT_TRAINER_PID;
            TestTrainerID(gameSave);
            if (IsGBGame(game))
            {
                Assert.Throws <ApplicationException>(
                    delegate
                {
                    gameSave.TrainerSecretID = DEFAULT_TRAINER_SID;
                }
                    );
            }
            else
            {
                gameSave.TrainerSecretID = DEFAULT_TRAINER_SID;
                TestTrainerID(gameSave);
            }

            // Rival Name
            if (IsRivalNameSet(game))
            {
                Assert.Throws <ApplicationException>(
                    delegate
                {
                    gameSave.RivalName = PKMN.Pokemon.DefaultTrainerName;
                }
                    );
            }
            else
            {
                gameSave.RivalName = PKMN.Pokemon.DefaultTrainerName;
                Assert.AreEqual(gameSave.RivalName, PKMN.Pokemon.DefaultTrainerName);
            }

            // Trainer Gender
            if (IsMaleOnly(game))
            {
                Assert.AreEqual(gameSave.TrainerGender, PKMN.Gender.MALE);
                Assert.Throws <ApplicationException>(
                    delegate
                {
                    gameSave.TrainerGender = PKMN.Gender.MALE;
                }
                    );
                Assert.Throws <ApplicationException>(
                    delegate
                {
                    gameSave.TrainerGender = PKMN.Gender.FEMALE;
                }
                    );
            }
            else
            {
                gameSave.TrainerGender = PKMN.Gender.MALE;
                Assert.AreEqual(gameSave.TrainerGender, PKMN.Gender.MALE);
                gameSave.TrainerGender = PKMN.Gender.FEMALE;
                Assert.AreEqual(gameSave.TrainerGender, PKMN.Gender.FEMALE);
                Assert.Throws <ArgumentOutOfRangeException>(
                    delegate
                {
                    gameSave.TrainerGender = PKMN.Gender.GENDERLESS;
                }
                    );
            }

            // Money
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                gameSave.Money = -1;
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                gameSave.Money = MONEY_MAX + 1;
            }
                );
            gameSave.Money = 123456;
            Assert.AreEqual(gameSave.Money, 123456);

            // Pokémon Party
            PKMN.PokemonParty party = gameSave.PokemonParty;
            int numPokemon          = party.NumPokemon;

            Assert.AreEqual(party.Length, 6);

            Assert.Greater(numPokemon, 0);
            Assert.LessOrEqual(numPokemon, 6);
            for (int i = 0; i < 6; ++i)
            {
                if (i < numPokemon)
                {
                    Assert.AreNotEqual(party[i].Species, PKMN.Species.NONE);
                }
                else
                {
                    Assert.AreEqual(party[i].Species, PKMN.Species.NONE);
                }
            }

            // Pokémon PC
            PKMN.PokemonPC pokemonPC = gameSave.PokemonPC;
            for (int i = 0; i < pokemonPC.Length; ++i)
            {
                PKMN.PokemonBox box = pokemonPC[i];

                Assert.LessOrEqual(box.NumPokemon, box.Length);

                // Boxes are only contiguous in Game Boy games.
                if (IsGBGame(game))
                {
                    numPokemon = box.NumPokemon;
                    for (int j = 0; j < box.Length; ++j)
                    {
                        if (j < numPokemon)
                        {
                            Assert.AreNotEqual(box[j].Species, PKMN.Species.NONE);
                        }
                        else
                        {
                            Assert.AreEqual(box[j].Species, PKMN.Species.NONE);
                        }
                    }
                }
            }

            // Pokédex
            if (!IsGameGamecube(game))
            {
                PKMN.Pokedex pokedex = gameSave.Pokedex;
                Assert.GreaterOrEqual(pokedex.NumSeen, pokedex.NumCaught);

                for (int partyIndex = 0; partyIndex < party.Length; ++partyIndex)
                {
                    PKMN.Species species = party[partyIndex].Species;
                    if ((species != PKMN.Species.NONE) && !party[partyIndex].IsEgg)
                    {
                        Assert.IsTrue(pokedex.SeenPokemonMap[species]);
                        Assert.IsTrue(pokedex.CaughtPokemonMap[species]);
                    }
                }

                for (int PCIndex = 0; PCIndex < pokemonPC.Length; ++PCIndex)
                {
                    PKMN.PokemonBox box = pokemonPC[PCIndex];
                    for (int boxIndex = 0; boxIndex < box.Length; ++boxIndex)
                    {
                        PKMN.Species species = box[boxIndex].Species;
                        if ((species != PKMN.Species.NONE) && !box[boxIndex].IsEgg)
                        {
                            Assert.IsTrue(pokedex.SeenPokemonMap[species]);
                            Assert.IsTrue(pokedex.CaughtPokemonMap[species]);
                        }
                    }
                }

                // Make sure that when a Pokémon is added to the party or PC, it's
                // added to the Pokédex. Manually remove the test species from the
                // Pokédex to confirm this behavior.

                PKMN.Species testSpecies1 = PKMN.Species.BULBASAUR;
                PKMN.Species testSpecies2 = PKMN.Species.CHARMANDER;

                pokedex.SeenPokemonMap[testSpecies1] = false;
                Assert.IsFalse(pokedex.SeenPokemonMap[testSpecies1]);
                Assert.IsFalse(pokedex.CaughtPokemonMap[testSpecies1]);

                pokedex.SeenPokemonMap[testSpecies2] = false;
                Assert.IsFalse(pokedex.SeenPokemonMap[testSpecies1]);
                Assert.IsFalse(pokedex.CaughtPokemonMap[testSpecies1]);

                PKMN.Pokemon testPokemon1 = new PKMN.Pokemon(
                    testSpecies1,
                    game,
                    "",
                    5
                    );
                PKMN.Pokemon testPokemon2 = new PKMN.Pokemon(
                    testSpecies2,
                    game,
                    "",
                    5
                    );


                party[0] = testPokemon1;
                Assert.IsTrue(pokedex.SeenPokemonMap[testSpecies1]);
                Assert.IsTrue(pokedex.CaughtPokemonMap[testSpecies1]);

                pokemonPC[0][0] = testPokemon2;
                Assert.IsTrue(pokedex.SeenPokemonMap[testSpecies2]);
                Assert.IsTrue(pokedex.CaughtPokemonMap[testSpecies2]);
            }

            TestTimePlayed(gameSave);
        }