Exemplo n.º 1
0
        private static void TestEmptyPokemonBox(
            PKMN.PokemonBox box
            )
        {
            for (int i = 0; i < box.Length; ++i)
            {
                Assert.AreEqual(box[i].Species, PKMN.Species.NONE);
                Assert.AreEqual(box[i].Game, box.Game);

                for (int j = 0; j < box[i].Moves.Count; ++j)
                {
                    Assert.AreEqual(box[i].Moves[j].Move, PKMN.Move.NONE);
                    Assert.AreEqual(box[i].Moves[j].PP, 0);
                }
            }

            // Make sure trying to get a Pokémon at an invalid index fails.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                PKMN.Pokemon pokemon = box[-1];
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                PKMN.Pokemon pokemon = box[box.Length];
            }
                );
        }
Exemplo n.º 2
0
        private static void TestLoadingAndSaving(
            PKMN.Game game,
            string extension
            )
        {
            string tmpPath = System.IO.Path.Combine(
                TmpDir,
                String.Format("{0}_{1}.{2}",
                              game,
                              rng.Next(),
                              extension
                              )
                );

            PKMN.ItemEnumList    itemList    = PKMN.Database.Lists.ItemList(game);
            PKMN.MoveEnumList    moveList    = PKMN.Database.Lists.MoveList(game);
            PKMN.SpeciesEnumList pokemonList = PKMN.Database.Lists.PokemonList(
                Util.GameToGeneration(game),
                true
                );

            PKMN.Pokemon randomPokemon = Util.GetRandomPokemon(game, itemList, moveList, pokemonList);
            randomPokemon.ExportToFile(tmpPath);

            PKMN.Pokemon importedPokemon = new PKMN.Pokemon(tmpPath);
            Util.ComparePokemon(randomPokemon, importedPokemon);

            System.IO.File.Delete(tmpPath);
        }
Exemplo n.º 3
0
        public static void PokemonTest(
            PKMN.Game game,
            PKMN.Species species
            )
        {
            PKMN.Pokemon pokemon = new PKMN.Pokemon(species, game, "", 30);

            PokemonTestParams testParams = new PokemonTestParams(
                PKMN.Ball.GREAT_BALL,
                new PKMN.Ball[] { PKMN.Ball.GREAT_BALL },
                PKMN.Item.POTION,
                new PKMN.Item[] { PKMN.Item.POTION },
                "Special",
                new string[] { "Route 1" },
                new string[] { "Route 1" },
                new PKMN.Move[] {
                PKMN.Move.SLASH,
                PKMN.Move.FLAMETHROWER,
                PKMN.Move.TAIL_WHIP,
                PKMN.Move.FIRE_BLAST
            },
                new PKMN.Move[] { PKMN.Move.RETURN },
                new PKMN.Game[] { PKMN.Game.RED },
                new PKMN.Game[] { PKMN.Game.RED }
                );

            PokemonTestCommon.TestCommon(pokemon, testParams);

            // Test attributes.

            Assert.AreEqual(pokemon.NumericAttributes["Catch rate"], 45);
        }
Exemplo n.º 4
0
        private static void TestEmptyPokemonParty(
            PKMN.PokemonParty party
            )
        {
            Assert.AreEqual(6, party.Length);

            for (int i = 0; i < party.Length; ++i)
            {
                Assert.AreEqual(PKMN.Species.NONE, party[i].Species);
                Assert.AreEqual(party.Game, party[i].Game);

                for (int j = 0; j < party[i].Moves.Count; ++j)
                {
                    Assert.AreEqual(PKMN.Move.NONE, party[i].Moves[j].Move);
                    Assert.AreEqual(0, party[i].Moves[j].PP);
                }
            }

            // Make sure trying to get a Pokémon at an invalid index fails.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                PKMN.Pokemon pokemon = party[-1];
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                PKMN.Pokemon pokemon = party[party.Length];
            }
                );
        }
Exemplo n.º 5
0
    public void testEmptyDaycare(
        PKMN.Daycare daycare
        )
    {
        // Levelup Pokémon

        for (int levelupPokemonIndex = 0;
             levelupPokemonIndex < daycare.LevelupPokemon.Length;
             ++levelupPokemonIndex)
        {
            Assert.AreEqual(
                PKMN.Species.NONE,
                daycare.LevelupPokemon[levelupPokemonIndex].Species
                );
        }

        // Test invalid indices.
        Assert.Throws <IndexOutOfRangeException>(
            delegate
        {
            PKMN.Pokemon pokemon = daycare.LevelupPokemon[-1];
        }
            );
        Assert.Throws <IndexOutOfRangeException>(
            delegate
        {
            PKMN.Pokemon pokemon = daycare.LevelupPokemon[daycare.LevelupPokemon.Length];
        }
            );

        // Breeding Pokémon
        // TODO: test egg

        if (daycare.CanBreedPokemon)
        {
            for (int breedingPokemonIndex = 0;
                 breedingPokemonIndex < daycare.BreedingPokemon.Length;
                 ++breedingPokemonIndex)
            {
                Assert.AreEqual(PKMN.Species.NONE, daycare.BreedingPokemon[breedingPokemonIndex].Species);
            }

            // Test invalid indices.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                PKMN.Pokemon pokemon = daycare.BreedingPokemon[-1];
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                PKMN.Pokemon pokemon = daycare.BreedingPokemon[daycare.BreedingPokemon.Length];
            }
                );
        }
    }
Exemplo n.º 6
0
    public void PokemonImageTest()
    {
        PKMN.Pokemon pokemon = new PKMN.Pokemon(PKMN.Species.BULBASAUR, PKMN.Game.RED, "", 5);

        // These calls succeeding is enough to show that the image (or the image
        // generated for Mono) was loaded successfully.
        Image pokemonIcon   = pokemon.Icon;
        Image pokemonSprite = pokemon.Sprite;
    }
Exemplo n.º 7
0
        public static void Gen2UnownTest(
            PKMN.Game game
            )
        {
            PKMN.Database.PokemonEntry unownEntry = new PKMN.Database.PokemonEntry(
                PKMN.Species.UNOWN,
                game,
                ""
                );
            PKMN.Pokemon unown;

            foreach (string form in unownEntry.Forms)
            {
                unown = new PKMN.Pokemon(PKMN.Species.UNOWN, game, form, 5);
                Assert.AreEqual(unown.Form, form);

                // Make sure IVs are properly set.
                string formFromIVs = PKMN.Calculations.Gen2UnownForm(
                    unown.IVs[PKMN.Stat.ATTACK],
                    unown.IVs[PKMN.Stat.DEFENSE],
                    unown.IVs[PKMN.Stat.SPEED],
                    unown.IVs[PKMN.Stat.SPECIAL]
                    );
                Assert.AreEqual(unown.Form, formFromIVs);

                Assert.IsTrue(System.IO.File.Exists(unown.IconFilepath));
                Assert.IsTrue(System.IO.File.Exists(unown.SpriteFilepath));
            }

            unown = new PKMN.Pokemon(PKMN.Species.UNOWN, game, "A", 5);

            // Make sure setting the form properly changes the IVs.
            foreach (string form in unownEntry.Forms)
            {
                unown.Form = form;
                Assert.AreEqual(unown.Form, form);

                string formFromIVs = PKMN.Calculations.Gen2UnownForm(
                    unown.IVs[PKMN.Stat.ATTACK],
                    unown.IVs[PKMN.Stat.DEFENSE],
                    unown.IVs[PKMN.Stat.SPEED],
                    unown.IVs[PKMN.Stat.SPECIAL]
                    );
                Assert.AreEqual(unown.Form, formFromIVs);

                Assert.IsTrue(System.IO.File.Exists(unown.IconFilepath));
                Assert.IsTrue(System.IO.File.Exists(unown.SpriteFilepath));
            }

            // Make sure setting IVs properly changes the form.
            unown.IVs[PKMN.Stat.ATTACK]  = 10;
            unown.IVs[PKMN.Stat.DEFENSE] = 9;
            unown.IVs[PKMN.Stat.SPEED]   = 1;
            unown.IVs[PKMN.Stat.SPECIAL] = 14;
            Assert.AreEqual(unown.Form, "G");
        }
Exemplo n.º 8
0
 static private void TestRibbons(
     PKMN.Pokemon pokemon
     )
 {
     foreach (string ribbon in Ribbons)
     {
         pokemon.Ribbons[ribbon] = true;
         Assert.IsTrue(pokemon.Ribbons[ribbon]);
     }
 }
Exemplo n.º 9
0
        public static void PokemonTest(
            PKMN.Game game,
            PKMN.Species species
            )
        {
            PKMN.Pokemon pokemon = new PKMN.Pokemon(species, game, "", 30);

            PokemonTestParams testParams = new PokemonTestParams(
                PKMN.Ball.GREAT_BALL,
                new PKMN.Ball[] { PKMN.Ball.GREAT_BALL },
                PKMN.Item.BERRY,
                new PKMN.Item[] { PKMN.Item.RAZZ_BERRY, PKMN.Item.BICYCLE },
                "Special",
                new string[] { "Sprout Tower", "Tohjo Falls" },
                new string[] { "Littleroot Town", "Petalburg Woods" },
                new PKMN.Move[] {
                PKMN.Move.SLASH,
                PKMN.Move.FLAMETHROWER,
                PKMN.Move.RETURN,
                PKMN.Move.FIRE_BLAST
            },
                new PKMN.Move[] {
                PKMN.Move.FRENZY_PLANT,
                PKMN.Move.ROOST
            },
                new PKMN.Game[] { PKMN.Game.GOLD },
                new PKMN.Game[] { PKMN.Game.GOLD }
                );

            PokemonTestCommon.TestCommon(pokemon, testParams);

            // Gender is tied to IVs, so make sure the abstraction reflects that.

            pokemon.Gender = PKMN.Gender.MALE;
            Assert.AreEqual(pokemon.IVs[PKMN.Stat.ATTACK], 15);
            pokemon.Gender = PKMN.Gender.FEMALE;
            Assert.Less(pokemon.IVs[PKMN.Stat.ATTACK], 15);

            pokemon.IVs[PKMN.Stat.ATTACK] = 0;
            Assert.AreEqual(pokemon.Gender, PKMN.Gender.FEMALE);
            pokemon.IVs[PKMN.Stat.ATTACK] = 15;
            Assert.AreEqual(pokemon.Gender, PKMN.Gender.MALE);

            // Shininess is tied to IVs, so make sure the abstraction reflects that.

            pokemon.IsShiny = false;
            Assert.AreEqual(pokemon.IVs[PKMN.Stat.ATTACK], 13);

            pokemon.IsShiny = true;
            Assert.AreEqual(pokemon.IVs[PKMN.Stat.ATTACK], 15);
            Assert.AreEqual(pokemon.IVs[PKMN.Stat.DEFENSE], 10);
            Assert.AreEqual(pokemon.IVs[PKMN.Stat.SPEED], 10);
            Assert.AreEqual(pokemon.IVs[PKMN.Stat.SPECIAL], 10);
        }
Exemplo n.º 10
0
        public static void Gen3UnownTest(
            PKMN.Game game
            )
        {
            PKMN.Database.PokemonEntry unownEntry = new PKMN.Database.PokemonEntry(
                PKMN.Species.UNOWN,
                game,
                ""
                );
            PKMN.Pokemon unown;

            foreach (string form in unownEntry.Forms)
            {
                unown = new PKMN.Pokemon(PKMN.Species.UNOWN, game, form, 5);
                Assert.AreEqual(unown.Form, form);

                // Make sure the personality is properly set.
                string formFromPersonality = PKMN.Calculations.Gen3UnownForm(unown.Personality);
                Assert.AreEqual(unown.Form, formFromPersonality);

                Assert.IsTrue(System.IO.File.Exists(unown.IconFilepath));
                Assert.IsTrue(System.IO.File.Exists(unown.SpriteFilepath));
            }

            unown = new PKMN.Pokemon(PKMN.Species.UNOWN, game, "A", 5);

            foreach (string form in unownEntry.Forms)
            {
                unown.Form = form;
                Assert.AreEqual(unown.Form, form);

                // Make sure the personality is properly set.
                string formFromPersonality = PKMN.Calculations.Gen3UnownForm(unown.Personality);
                Assert.AreEqual(unown.Form, formFromPersonality);

                Assert.IsTrue(System.IO.File.Exists(unown.IconFilepath));
                Assert.IsTrue(System.IO.File.Exists(unown.SpriteFilepath));
            }

            // Make sure setting the personality properly sets the form.
            unown.Personality = 0x4C07DE71;
            Assert.AreEqual(unown.Form, "B");
        }
Exemplo n.º 11
0
        static private void CheckInitialRibbonMap(
            PKMN.Pokemon pokemon
            )
        {
            foreach (string contestType in ContestTypes)
            {
                Assert.IsTrue(pokemon.Ribbons.ContainsKey(contestType));
                Assert.IsFalse(pokemon.Ribbons[contestType]);

                foreach (string contestLevel in ContestLevels)
                {
                    string ribbonName = contestType + " " + contestLevel;
                    Assert.IsTrue(pokemon.Ribbons.ContainsKey(ribbonName));
                    Assert.IsFalse(pokemon.Ribbons[ribbonName]);
                }
            }

            foreach (string ribbon in Ribbons)
            {
                Assert.IsTrue(pokemon.Ribbons.ContainsKey(ribbon));
                Assert.IsFalse(pokemon.Ribbons[ribbon]);
            }
        }
Exemplo n.º 12
0
        static private void TestContestRibbons(
            PKMN.Pokemon pokemon
            )
        {
            foreach (string contestType in ContestTypes)
            {
                string ribbonName       = contestType;
                string superRibbonName  = contestType + " Super";
                string hyperRibbonName  = contestType + " Hyper";
                string masterRibbonName = contestType + " Master";

                pokemon.Ribbons[hyperRibbonName] = true;
                Assert.IsTrue(pokemon.Ribbons[ribbonName]);
                Assert.IsTrue(pokemon.Ribbons[superRibbonName]);
                Assert.IsTrue(pokemon.Ribbons[hyperRibbonName]);
                Assert.IsFalse(pokemon.Ribbons[masterRibbonName]);

                pokemon.Ribbons[superRibbonName] = false;
                Assert.IsTrue(pokemon.Ribbons[ribbonName]);
                Assert.IsFalse(pokemon.Ribbons[superRibbonName]);
                Assert.IsFalse(pokemon.Ribbons[hyperRibbonName]);
                Assert.IsFalse(pokemon.Ribbons[masterRibbonName]);
            }
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        internal static PKMN.Pokemon GetRandomPokemon(
            PKMN.Game game,
            PKMN.ItemEnumList itemList,
            PKMN.MoveEnumList moveList,
            PKMN.SpeciesEnumList pokemonList
            )
        {
            int generation = Util.GameToGeneration(game);

            // Don't deal with Deoxys or Unown issues here.
            PKMN.Species species = PKMN.Species.NONE;
            if (generation == 3)
            {
                do
                {
                    species = pokemonList[rng.Next(0, pokemonList.Count - 1)];
                }while((species == PKMN.Species.DEOXYS) || (species == PKMN.Species.UNOWN));
            }
            else
            {
                species = pokemonList[rng.Next(0, pokemonList.Count - 1)];
            }

            PKMN.Pokemon ret = new PKMN.Pokemon(
                species,
                game,
                "",
                rng.Next(2, 100)
                );

            for (int moveIndex = 0; moveIndex < 4; ++moveIndex)
            {
                PKMN.Move move;
                do
                {
                    move = moveList[rng.Next(0, moveList.Count - 1)];
                }while(move >= PKMN.Move.SHADOW_RUSH);

                ret.Moves[moveIndex].Move = move;
            }

            foreach (PKMN.Stat EV in ret.EVs.Keys)
            {
                ret.EVs[EV] = rng.Next(0, 255);
            }
            foreach (PKMN.Stat IV in ret.IVs.Keys)
            {
                ret.IVs[IV] = rng.Next(0, 15);
            }

            if (generation >= 2)
            {
                // Keep going until one is holdable.
                while (ret.HeldItem == PKMN.Item.NONE)
                {
                    try
                    {
                        ret.HeldItem = itemList[rng.Next(0, itemList.Count - 1)];
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                    }
                }

                ret.PokerusDuration = rng.Next(0, 15);
            }
            if (generation >= 3)
            {
                foreach (PKMN.Marking marking in ret.Markings.Keys)
                {
                    ret.Markings[marking] = Util.RandomBool();
                }
                foreach (string ribbon in ret.Ribbons.Keys)
                {
                    ret.Ribbons[ribbon] = Util.RandomBool();
                }
                foreach (PKMN.ContestStat contestStat in ret.ContestStats.Keys)
                {
                    ret.ContestStats[contestStat] = rng.Next(0, 255);
                }
            }

            return(ret);
        }
Exemplo n.º 15
0
        internal static void ComparePokemon(
            PKMN.Pokemon pokemon1,
            PKMN.Pokemon pokemon2
            )
        {
            PKMN.Game game       = pokemon1.Game;
            int       generation = Util.GameToGeneration(game);

            // There is no way to tell what game an imported Generation I-II
            // Pokémon comes from, so LibPKMN defaults to a default valid game.
            if (generation >= 3)
            {
                Assert.AreEqual(pokemon2.Game, game);
            }

            Assert.AreEqual(pokemon1.Species, pokemon2.Species);
            Assert.AreEqual(pokemon1.Form, pokemon2.Form);
            Assert.AreEqual(pokemon1.OriginalTrainerID, pokemon2.OriginalTrainerID);
            Assert.AreEqual(pokemon1.Experience, pokemon2.Experience);
            Assert.AreEqual(pokemon1.Level, pokemon2.Level);
            Assert.AreEqual(pokemon1.Nickname, pokemon2.Nickname);
            Assert.AreEqual(pokemon1.OriginalTrainerName, pokemon2.OriginalTrainerName);

            Assert.AreEqual(pokemon1.EVs.Keys, pokemon2.EVs.Keys);
            foreach (PKMN.Stat EV in pokemon1.EVs.Keys)
            {
                Assert.AreEqual(pokemon1.EVs[EV], pokemon2.EVs[EV]);
            }

            Assert.AreEqual(pokemon1.IVs.Keys, pokemon2.IVs.Keys);
            foreach (PKMN.Stat IV in pokemon1.IVs.Keys)
            {
                Assert.AreEqual(pokemon1.IVs[IV], pokemon2.IVs[IV]);
            }

            Assert.AreEqual(pokemon1.Stats.Keys, pokemon2.Stats.Keys);
            foreach (PKMN.Stat stat in pokemon1.Stats.Keys)
            {
                Assert.AreEqual(pokemon1.Stats[stat], pokemon2.Stats[stat]);
            }

            if (pokemon1.Game.Equals(pokemon2.Game))
            {
                Assert.AreEqual(pokemon1.IconFilepath, pokemon2.IconFilepath);
                Assert.AreEqual(pokemon1.SpriteFilepath, pokemon2.SpriteFilepath);
            }

            Assert.AreEqual(pokemon1.NumericAttributes.Names, pokemon2.NumericAttributes.Names);
            foreach (string attributeName in pokemon1.NumericAttributes.Names)
            {
                Assert.AreEqual(
                    pokemon1.NumericAttributes[attributeName],
                    pokemon2.NumericAttributes[attributeName]
                    );
            }
            Assert.AreEqual(pokemon1.StringAttributes.Names, pokemon2.StringAttributes.Names);
            foreach (string attributeName in pokemon1.StringAttributes.Names)
            {
                Assert.AreEqual(
                    pokemon1.StringAttributes[attributeName],
                    pokemon2.StringAttributes[attributeName]
                    );
            }
            Assert.AreEqual(pokemon1.BooleanAttributes.Names, pokemon2.BooleanAttributes.Names);
            foreach (string attributeName in pokemon1.BooleanAttributes.Names)
            {
                Assert.AreEqual(
                    pokemon1.BooleanAttributes[attributeName],
                    pokemon2.BooleanAttributes[attributeName]
                    );
            }

            if (generation >= 2)
            {
                Assert.AreEqual(pokemon1.OriginalTrainerGender, pokemon2.OriginalTrainerGender);
                Assert.AreEqual(pokemon1.CurrentTrainerFriendship, pokemon2.CurrentTrainerFriendship);
                Assert.AreEqual(pokemon1.Gender, pokemon2.Gender);
                Assert.AreEqual(pokemon1.IsShiny, pokemon2.IsShiny);
                Assert.AreEqual(pokemon1.HeldItem, pokemon2.HeldItem);
                Assert.AreEqual(pokemon1.LevelMet, pokemon2.LevelMet);
                Assert.AreEqual(pokemon1.LocationMet, pokemon2.LocationMet);
                Assert.AreEqual(pokemon1.PokerusDuration, pokemon2.PokerusDuration);
            }
            if (generation >= 3)
            {
                Assert.AreEqual(pokemon1.Ability, pokemon2.Ability);
                Assert.AreEqual(pokemon1.Ball, pokemon2.Ball);
                Assert.AreEqual(pokemon1.Personality, pokemon2.Personality);

                Assert.AreEqual(pokemon1.Markings.Keys, pokemon2.Markings.Keys);
                foreach (PKMN.Marking marking in pokemon1.Markings.Keys)
                {
                    Assert.AreEqual(pokemon1.Markings[marking], pokemon2.Markings[marking]);
                }

                Assert.AreEqual(pokemon1.Ribbons.Keys, pokemon2.Ribbons.Keys);
                foreach (string ribbon in pokemon1.Ribbons.Keys)
                {
                    Assert.AreEqual(pokemon1.Ribbons[ribbon], pokemon2.Ribbons[ribbon]);
                }

                Assert.AreEqual(pokemon1.ContestStats.Keys, pokemon2.ContestStats.Keys);
                foreach (PKMN.ContestStat contestStat in pokemon1.ContestStats.Keys)
                {
                    Assert.AreEqual(pokemon1.ContestStats[contestStat], pokemon2.ContestStats[contestStat]);
                }
            }
            if (generation >= 4)
            {
                Assert.AreEqual(pokemon1.LocationMetAsEgg, pokemon2.LocationMetAsEgg);
            }
        }
Exemplo n.º 16
0
        private static void TestSettingPokemon(
            PKMN.PokemonParty party,
            PKMN.Game[] validOtherGames,
            PKMN.Game invalidOtherGame
            )
        {
            PKMN.Pokemon originalFirst  = party[0];
            PKMN.Pokemon originalSecond = party[1];

            // Make sure we can't set Pokémon at invalid indices.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                party[-1] = originalFirst;
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                party[party.Length] = originalSecond;
            }
                );

            // Create Pokémon and place in party. The original variables should
            // still have the same underlying Pokémon.
            PKMN.Pokemon bulbasaur  = new PKMN.Pokemon(PKMN.Species.BULBASAUR, party.Game, "", 5);
            PKMN.Pokemon charmander = new PKMN.Pokemon(PKMN.Species.CHARMANDER, party.Game, "", 5);
            PKMN.Pokemon squirtle   = new PKMN.Pokemon(PKMN.Species.SQUIRTLE, party.Game, "", 5);

            party[0] = bulbasaur;
            Assert.AreEqual(1, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.BULBASAUR, party[0].Species);
            party[1] = charmander;
            Assert.AreEqual(2, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.CHARMANDER, party[1].Species);

            // Replace one of the new ones.
            party[0] = squirtle;
            Assert.AreEqual(2, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.SQUIRTLE, party[0].Species);

            // Copy a Pokémon already part of the party.
            party[2] = party[1];
            Assert.AreEqual(3, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.CHARMANDER, party[2].Species);

            // We should be able to clear the last contiguous Pokémon.
            party[2] = originalFirst;
            Assert.AreEqual(2, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.NONE, party[2].Species);

            // Put it back.
            party[2] = party[1];
            Assert.AreEqual(3, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.CHARMANDER, party[2].Species);

            // Check that Pokémon cannot be placed non-contiguously.
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate
            {
                party[1] = originalFirst;
            }
                );
            Assert.AreEqual(3, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.CHARMANDER, party[1].Species);

            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                party[4] = bulbasaur;
            }
                );
            Assert.AreEqual(3, party.NumPokemon);
            Assert.AreEqual(PKMN.Species.NONE, party[4].Species);

            // Now check everything we've created. Each variable should have
            // the same underlying Pokémon.
            Assert.AreEqual(PKMN.Species.SQUIRTLE, party[0].Species);
            Assert.AreEqual(PKMN.Species.CHARMANDER, party[1].Species);
            Assert.AreEqual(PKMN.Species.CHARMANDER, party[2].Species);
            Assert.AreEqual(PKMN.Species.NONE, originalFirst.Species);
            Assert.AreEqual(PKMN.Species.NONE, originalSecond.Species);
            Assert.AreEqual(PKMN.Species.BULBASAUR, bulbasaur.Species);
            Assert.AreEqual(PKMN.Species.CHARMANDER, charmander.Species);
            Assert.AreEqual(PKMN.Species.SQUIRTLE, squirtle.Species);

            // Make sure converting Pokémon before putting them in the party works (or doesn't)
            // as expected.
            foreach (PKMN.Game validGame in validOtherGames)
            {
                PKMN.Pokemon pikachu = new PKMN.Pokemon(
                    PKMN.Species.PIKACHU,
                    validGame,
                    "",
                    50
                    );
                Assert.AreEqual(validGame, pikachu.Game);

                party[3] = pikachu;
                Assert.AreEqual(PKMN.Species.PIKACHU, party[3].Species);
                Assert.AreEqual(party.Game, party[3].Game);
                Assert.AreEqual(50, party[3].Level);
            }

            PKMN.Pokemon invalidPikachu = new PKMN.Pokemon(
                PKMN.Species.PIKACHU,
                invalidOtherGame,
                "",
                50
                );
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate
            {
                party[3] = invalidPikachu;
            }
                );
        }
Exemplo n.º 17
0
        public static void ConversionsTest(
            PKMN.Species species,
            string form,
            PKMN.Game originGame,
            PKMN.Game destGame
            )
        {
            PKMN.Pokemon firstPokemon = new PKMN.Pokemon(species, originGame, form, 50);

            int originGeneration = Util.GameToGeneration(originGame);
            int destGeneration   = Util.GameToGeneration(destGame);
            int minGeneration    = System.Math.Min(originGeneration, destGeneration);

            PKMN.Game gameForLists = (minGeneration == originGeneration) ? originGame : destGame;

            PKMN.ItemEnumList items = PKMN.Database.Lists.ItemList(gameForLists);
            PKMN.MoveEnumList moves = PKMN.Database.Lists.MoveList(gameForLists);

            for (int i = 0; i < 4; ++i)
            {
                PKMN.Move move = PKMN.Move.NONE;
                do
                {
                    move = moves[rng.Next(0, moves.Count - 1)];
                }while(move >= PKMN.Move.SHADOW_RUSH);

                firstPokemon.Moves[i].Move = move;
            }

            if (originGeneration >= 3)
            {
                firstPokemon.OriginalTrainerSecretID = (ushort)rng.Next(0, 0xFFFF);

                if (firstPokemon.DatabaseEntry.Abilities.Second != PKMN.Ability.NONE)
                {
                    firstPokemon.Ability = Util.RandomBool() ? firstPokemon.DatabaseEntry.Abilities.First
                                                         : firstPokemon.DatabaseEntry.Abilities.Second;
                }
            }
            firstPokemon.OriginalTrainerPublicID = (ushort)rng.Next(0, 0xFFFF);

            if (minGeneration >= 2)
            {
                PKMN.Item heldItem = PKMN.Item.NONE;
                do
                {
                    heldItem = items[rng.Next(0, items.Count - 1)];
                } while(!(new PKMN.Database.ItemEntry(heldItem, originGame).IsHoldable) ||
                        ((heldItem >= PKMN.Item.JOY_SCENT) && (heldItem <= PKMN.Item.VIVID_SCENT)));

                firstPokemon.HeldItem = heldItem;
            }
            if (originGeneration >= 2)
            {
                firstPokemon.Gender  = Util.RandomBool() ? PKMN.Gender.MALE : PKMN.Gender.FEMALE;
                firstPokemon.IsShiny = Util.RandomBool();
                firstPokemon.CurrentTrainerFriendship = rng.Next(0, 255);

                if ((originGame == PKMN.Game.GOLD) || (originGame == PKMN.Game.CRYSTAL))
                {
                    firstPokemon.OriginalTrainerGender = Util.RandomBool() ? PKMN.Gender.MALE : PKMN.Gender.FEMALE;
                }

                // The max level met value in Generation II is 63.
                firstPokemon.LevelMet = rng.Next(2, (originGeneration == 2) ? 63 : 100);
            }
            if (originGeneration >= 3)
            {
                // Randomize ribbons, markings, and contest stats.
                foreach (PKMN.Marking marking in firstPokemon.Markings.Keys)
                {
                    firstPokemon.Markings[marking] = Util.RandomBool();
                }
                foreach (string ribbon in firstPokemon.Ribbons.Keys)
                {
                    firstPokemon.Ribbons[ribbon] = Util.RandomBool();
                }
                foreach (PKMN.ContestStat contestStat in firstPokemon.ContestStats.Keys)
                {
                    firstPokemon.ContestStats[contestStat] = rng.Next(0, 255);
                }
            }

            firstPokemon.Nickname            = Util.RandomString(10);
            firstPokemon.OriginalTrainerName = Util.RandomString(7);

            // The max level met value in Generation II is 63, which restricts this as well.
            firstPokemon.Level = rng.Next(2, (destGeneration == 2) ? 63 : 100);

            // Convert to the second game and compare.
            PKMN.Pokemon secondPokemon = firstPokemon.ToGame(destGame);

            Assert.AreEqual(firstPokemon.Species, secondPokemon.Species);
            Assert.AreEqual(destGame, secondPokemon.Game);
            Assert.AreEqual(firstPokemon.Form, secondPokemon.Form);
            Assert.AreEqual(firstPokemon.Nickname, secondPokemon.Nickname);
            Assert.AreEqual(firstPokemon.OriginalTrainerName, secondPokemon.OriginalTrainerName);
            Assert.AreEqual(firstPokemon.OriginalTrainerID, secondPokemon.OriginalTrainerID);
            Assert.AreEqual(firstPokemon.OriginalTrainerPublicID, secondPokemon.OriginalTrainerPublicID);
            Assert.AreEqual(firstPokemon.Experience, secondPokemon.Experience);
            Assert.AreEqual(firstPokemon.Level, secondPokemon.Level);

            for (int i = 0; i < 4; ++i)
            {
                Assert.AreEqual(firstPokemon.Moves[i].Move, secondPokemon.Moves[i].Move);
                Assert.AreEqual(firstPokemon.Moves[i].PP, secondPokemon.Moves[i].PP);
            }

            if (minGeneration >= 3)
            {
                Assert.AreEqual(firstPokemon.OriginalTrainerSecretID, secondPokemon.OriginalTrainerSecretID);
                Assert.AreEqual(firstPokemon.Ability, secondPokemon.Ability);
                Assert.AreEqual(firstPokemon.Ball, secondPokemon.Ball);
                Assert.AreEqual(firstPokemon.OriginalGame, secondPokemon.OriginalGame);
                Assert.AreEqual(firstPokemon.Personality, secondPokemon.Personality);

                if (originGeneration == destGeneration)
                {
                    foreach (PKMN.Marking marking in firstPokemon.Markings.Keys)
                    {
                        Assert.AreEqual(firstPokemon.Markings[marking], secondPokemon.Markings[marking]);
                    }
                    foreach (string ribbon in firstPokemon.Ribbons.Keys)
                    {
                        Assert.AreEqual(firstPokemon.Ribbons[ribbon], secondPokemon.Ribbons[ribbon]);
                    }
                    foreach (PKMN.ContestStat contestStat in firstPokemon.ContestStats.Keys)
                    {
                        Assert.AreEqual(firstPokemon.ContestStats[contestStat], secondPokemon.ContestStats[contestStat]);
                    }
                }
            }
            if (minGeneration >= 2)
            {
                Assert.AreEqual(firstPokemon.OriginalTrainerGender, secondPokemon.OriginalTrainerGender);
                Assert.AreEqual(firstPokemon.Gender, secondPokemon.Gender);
                Assert.AreEqual(firstPokemon.IsShiny, secondPokemon.IsShiny);
                Assert.AreEqual(firstPokemon.HeldItem, secondPokemon.HeldItem);
                Assert.AreEqual(firstPokemon.CurrentTrainerFriendship, secondPokemon.CurrentTrainerFriendship);
                Assert.AreEqual(firstPokemon.Level, secondPokemon.LevelMet);
            }
        }
Exemplo n.º 18
0
        private static void TestSettingPokemon(
            PKMN.PokemonBox box,
            PKMN.Game[] validOtherGames,
            PKMN.Game invalidOtherGame
            )
        {
            int generation = Util.GameToGeneration(box.Game);

            PKMN.Pokemon originalFirst  = box[0];
            PKMN.Pokemon originalSecond = box[1];

            // Make sure we can't set Pokémon at invalid indices.
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                box[-1] = originalFirst;
            }
                );
            Assert.Throws <IndexOutOfRangeException>(
                delegate
            {
                box[box.Length] = originalSecond;
            }
                );

            // Create Pokémon and place in box. The original variables should
            // still have the same underlying Pokémon.
            PKMN.Pokemon bulbasaur  = new PKMN.Pokemon(PKMN.Species.BULBASAUR, box.Game, "", 5);
            PKMN.Pokemon charmander = new PKMN.Pokemon(PKMN.Species.CHARMANDER, box.Game, "", 5);
            PKMN.Pokemon squirtle   = new PKMN.Pokemon(PKMN.Species.SQUIRTLE, box.Game, "", 5);

            box[0] = bulbasaur;
            Assert.AreEqual(box.NumPokemon, 1);
            box[1] = charmander;
            Assert.AreEqual(box.NumPokemon, 2);

            // Replace one of the new ones.
            box[0] = squirtle;
            Assert.AreEqual(box.NumPokemon, 2);

            // Copy a Pokémon already part of the box.
            box[2] = box[1];
            Assert.AreEqual(box.NumPokemon, 3);

            // We should always be able to clear the last contiguous Pokémon.
            box[2] = originalFirst;
            Assert.AreEqual(box.NumPokemon, 2);
            Assert.AreEqual(box[2].Species, PKMN.Species.NONE);

            // Put it back.
            box[2] = box[1];
            Assert.AreEqual(box.NumPokemon, 3);

            // Check that Pokémon can be placed non-contiguously in the correct games.
            if (generation <= 2)
            {
                Assert.Throws <ArgumentOutOfRangeException>(
                    delegate
                {
                    box[1] = originalFirst;
                }
                    );
                Assert.AreEqual(box.NumPokemon, 3);
                Assert.AreEqual(box[1].Species, PKMN.Species.CHARMANDER);

                Assert.Throws <IndexOutOfRangeException>(
                    delegate
                {
                    box[4] = bulbasaur;
                }
                    );
                Assert.AreEqual(box.NumPokemon, 3);
                Assert.AreEqual(box[4].Species, PKMN.Species.NONE);
            }
            else
            {
                box[1] = originalFirst;
                Assert.AreEqual(box.NumPokemon, 2);
                Assert.AreEqual(box[1].Species, PKMN.Species.NONE);

                box[4] = bulbasaur;
                Assert.AreEqual(box.NumPokemon, 3);
                Assert.AreEqual(box[4].Species, PKMN.Species.BULBASAUR);

                // Restore it to how it was.
                box[1] = charmander;
                box[4] = originalFirst;
                Assert.AreEqual(box.NumPokemon, 3);
                Assert.AreEqual(box[1].Species, PKMN.Species.CHARMANDER);
                Assert.AreEqual(box[4].Species, PKMN.Species.NONE);
            }

            // Now check everything we've created. Each variable should have
            // the same underlying Pokémon.
            Assert.AreEqual(box[0].Species, PKMN.Species.SQUIRTLE);
            Assert.AreEqual(box[1].Species, PKMN.Species.CHARMANDER);
            Assert.AreEqual(box[2].Species, PKMN.Species.CHARMANDER);
            Assert.AreEqual(originalFirst.Species, PKMN.Species.NONE);
            Assert.AreEqual(originalSecond.Species, PKMN.Species.NONE);
            Assert.AreEqual(bulbasaur.Species, PKMN.Species.BULBASAUR);
            Assert.AreEqual(charmander.Species, PKMN.Species.CHARMANDER);
            Assert.AreEqual(squirtle.Species, PKMN.Species.SQUIRTLE);

            // Make sure converting Pokémon before putting them in the box works (or doesn't)
            // as expected.
            foreach (PKMN.Game validGame in validOtherGames)
            {
                PKMN.Pokemon pikachu = new PKMN.Pokemon(
                    PKMN.Species.PIKACHU,
                    validGame,
                    "",
                    50
                    );
                Assert.AreEqual(validGame, pikachu.Game);

                box[3] = pikachu;
                Assert.AreEqual(PKMN.Species.PIKACHU, box[3].Species);
                Assert.AreEqual(box.Game, box[3].Game);
                Assert.AreEqual(50, box[3].Level);
            }

            PKMN.Pokemon invalidPikachu = new PKMN.Pokemon(
                PKMN.Species.PIKACHU,
                invalidOtherGame,
                "",
                50
                );
            Assert.Throws <ArgumentOutOfRangeException>(
                delegate
            {
                box[3] = invalidPikachu;
            }
                );
        }
Exemplo n.º 19
0
        // Outside files

        public static void TestOutside3GPKM()
        {
            /*
             * Test files in repo and compare to known values.
             */
            string _3GPKMDir = System.IO.Path.Combine(LibPKMNTestFiles, "3gpkm");

            PKMN.Pokemon mightyena = new PKMN.Pokemon(
                System.IO.Path.Combine(_3GPKMDir, "MIGHTYENA.3gpkm")
                );
            Assert.AreEqual(mightyena.Species, PKMN.Species.MIGHTYENA);
            Assert.AreEqual(mightyena.Game, PKMN.Game.EMERALD);
            Assert.AreEqual(mightyena.Form, "Standard");
            Assert.AreEqual(mightyena.Nickname, "MIGHTYENA");
            Assert.IsFalse(mightyena.IsShiny);
            Assert.AreEqual(mightyena.HeldItem, PKMN.Item.HEART_SCALE);
            Assert.AreEqual(mightyena.Condition, PKMN.Condition.NONE);
            Assert.AreEqual(mightyena.OriginalTrainerName, "A");
            Assert.AreEqual(mightyena.OriginalTrainerPublicID, 61415);
            Assert.AreEqual(mightyena.OriginalTrainerSecretID, 3417);
            Assert.AreEqual(mightyena.OriginalTrainerID, 223997927);
            Assert.AreEqual(mightyena.OriginalTrainerGender, PKMN.Gender.FEMALE);
            Assert.AreEqual(mightyena.CurrentTrainerFriendship, 254);
            Assert.AreEqual(mightyena.Ability, PKMN.Ability.INTIMIDATE);
            Assert.AreEqual(mightyena.Ball, PKMN.Ball.GREAT_BALL);
            Assert.AreEqual(mightyena.LevelMet, 25);
            Assert.AreEqual(mightyena.LocationMet, "Route 120");
            Assert.AreEqual(mightyena.OriginalGame, PKMN.Game.EMERALD);
            Assert.AreEqual(mightyena.Personality, 3557601241);
            Assert.AreEqual(mightyena.Experience, 128734);
            Assert.AreEqual(mightyena.Level, 50);

            Assert.AreEqual(mightyena.Markings.Count, 4);
            foreach (PKMN.Marking marking in mightyena.Markings.Keys)
            {
                Assert.IsFalse(mightyena.Markings[marking]);
            }

            Assert.AreEqual(mightyena.Ribbons.Count, 32);
            foreach (string ribbon in mightyena.Ribbons.Keys)
            {
                if (ribbon.Equals("Champion"))
                {
                    Assert.IsTrue(mightyena.Ribbons[ribbon]);
                }
                else
                {
                    Assert.IsFalse(mightyena.Ribbons[ribbon]);
                }
            }

            Assert.AreEqual(mightyena.ContestStats.Count, 6);
            foreach (PKMN.ContestStat contestStat in mightyena.ContestStats.Keys)
            {
                Assert.AreEqual(mightyena.ContestStats[contestStat], 0);
            }

            PKMN.Move[] expectedMightyenaMoves =
            {
                PKMN.Move.CRUNCH,
                PKMN.Move.STRENGTH,
                PKMN.Move.SHADOW_BALL,
                PKMN.Move.DOUBLE_EDGE
            };
            Assert.AreEqual(mightyena.Moves.Count, 4);
            for (int i = 0; i < 4; ++i)
            {
                Assert.AreEqual(mightyena.Moves[i].Move, expectedMightyenaMoves[i]);
            }

            Assert.AreEqual(mightyena.EVs.Count, 6);
            Assert.AreEqual(mightyena.EVs[PKMN.Stat.HP], 30);
            Assert.AreEqual(mightyena.EVs[PKMN.Stat.ATTACK], 110);
            Assert.AreEqual(mightyena.EVs[PKMN.Stat.DEFENSE], 32);
            Assert.AreEqual(mightyena.EVs[PKMN.Stat.SPEED], 48);
            Assert.AreEqual(mightyena.EVs[PKMN.Stat.SPECIAL_ATTACK], 17);
            Assert.AreEqual(mightyena.EVs[PKMN.Stat.SPECIAL_DEFENSE], 83);

            Assert.AreEqual(mightyena.IVs.Count, 6);
            Assert.AreEqual(mightyena.IVs[PKMN.Stat.HP], 26);
            Assert.AreEqual(mightyena.IVs[PKMN.Stat.ATTACK], 28);
            Assert.AreEqual(mightyena.IVs[PKMN.Stat.DEFENSE], 4);
            Assert.AreEqual(mightyena.IVs[PKMN.Stat.SPEED], 13);
            Assert.AreEqual(mightyena.IVs[PKMN.Stat.SPECIAL_ATTACK], 25);
            Assert.AreEqual(mightyena.IVs[PKMN.Stat.SPECIAL_DEFENSE], 26);

            Assert.AreEqual(mightyena.Stats.Count, 6);
            Assert.AreEqual(mightyena.Stats[PKMN.Stat.HP], 146);
            Assert.AreEqual(mightyena.Stats[PKMN.Stat.ATTACK], 122);
            Assert.AreEqual(mightyena.Stats[PKMN.Stat.DEFENSE], 81);
            Assert.AreEqual(mightyena.Stats[PKMN.Stat.SPEED], 87);
            Assert.AreEqual(mightyena.Stats[PKMN.Stat.SPECIAL_ATTACK], 79);
            Assert.AreEqual(mightyena.Stats[PKMN.Stat.SPECIAL_DEFENSE], 88);
        }
Exemplo n.º 20
0
        static public void PokemonTest(
            PKMN.Game game,
            PKMN.Species species
            )
        {
            PKMN.Pokemon pokemon = new PKMN.Pokemon(species, game, "", 30);

            PokemonTestParams testParams;
            bool isGamecube = (game == PKMN.Game.COLOSSEUM) || (game == PKMN.Game.XD);

            if (isGamecube)
            {
                testParams = new PokemonTestParams(
                    PKMN.Ball.GREAT_BALL,
                    new PKMN.Ball[] { PKMN.Ball.FRIEND_BALL, PKMN.Ball.HEAL_BALL },
                    PKMN.Item.RAZZ_BERRY,
                    new PKMN.Item[] { PKMN.Item.BERRY, PKMN.Item.MACH_BIKE },
                    "Distant land",
                    new string[] { "Phenac City", "Orre Colosseum" },
                    new string[] { "New Bark Town", "Twinleaf Town" },
                    new PKMN.Move[] {
                    PKMN.Move.SWALLOW,
                    PKMN.Move.FLAMETHROWER,
                    PKMN.Move.RETURN,
                    PKMN.Move.FIRE_BLAST
                },
                    new PKMN.Move[] {
                    PKMN.Move.ROOST,
                    PKMN.Move.FLAME_BURST
                },
                    new PKMN.Game[] {
                    PKMN.Game.RUBY, PKMN.Game.SAPPHIRE, PKMN.Game.EMERALD,
                    PKMN.Game.FIRERED, PKMN.Game.LEAFGREEN,
                    PKMN.Game.COLOSSEUM, PKMN.Game.XD
                },
                    new PKMN.Game[] { PKMN.Game.GOLD, PKMN.Game.HEARTGOLD }
                    );
            }
            else
            {
                testParams = new PokemonTestParams(
                    PKMN.Ball.GREAT_BALL,
                    new PKMN.Ball[] { PKMN.Ball.FRIEND_BALL, PKMN.Ball.HEAL_BALL },
                    PKMN.Item.RAZZ_BERRY,
                    new PKMN.Item[] { PKMN.Item.BERRY, PKMN.Item.MACH_BIKE },
                    "Fateful encounter",
                    new string[] { "Petalburg Woods", "Viridian Forest" },
                    new string[] { "New Bark Town", "Twinleaf Town" },
                    new PKMN.Move[] {
                    PKMN.Move.SWALLOW,
                    PKMN.Move.FLAMETHROWER,
                    PKMN.Move.RETURN,
                    PKMN.Move.FIRE_BLAST
                },
                    new PKMN.Move[] {
                    PKMN.Move.SHADOW_SKY,
                    PKMN.Move.ROOST
                },
                    new PKMN.Game[] {
                    PKMN.Game.RUBY, PKMN.Game.SAPPHIRE, PKMN.Game.EMERALD,
                    PKMN.Game.FIRERED, PKMN.Game.LEAFGREEN,
                    PKMN.Game.COLOSSEUM, PKMN.Game.XD
                },
                    new PKMN.Game[] { PKMN.Game.GOLD, PKMN.Game.HEARTGOLD }
                    );
            }

            PokemonTestCommon.TestCommon(pokemon, testParams);

            CheckInitialRibbonMap(pokemon);
            TestContestRibbons(pokemon);
            TestRibbons(pokemon);

            // Gender and personality are tied, so make sure they affect each other.

            pokemon.Gender = PKMN.Gender.FEMALE;
            Assert.Less((pokemon.Personality & 0xFF), 0xFF);
            pokemon.Gender = PKMN.Gender.MALE;
            Assert.AreEqual((pokemon.Personality & 0xFF), 0xFF);

            pokemon.Personality = 0x1234AB00;
            Assert.AreEqual(pokemon.Gender, PKMN.Gender.FEMALE);
            pokemon.Personality = 0xCD5678FF;
            Assert.AreEqual(pokemon.Gender, PKMN.Gender.MALE);

            // Setting shininess should affect personality.

            pokemon.IsShiny = false;
            uint nonShinyPersonality = pokemon.Personality;

            pokemon.IsShiny = true;
            Assert.AreNotEqual(pokemon.Personality, nonShinyPersonality);

            // Shadow Pokémon should only work in Gamecube games.

            if (isGamecube)
            {
                PKMN.Species shadowSpecies = (game == PKMN.Game.COLOSSEUM) ? PKMN.Species.LEDIAN
                                                                       : PKMN.Species.LEDYBA;

                PKMN.Pokemon shadowPokemon = new PKMN.Pokemon(shadowSpecies, game, "", 50);
                Assert.AreEqual(shadowPokemon.Form, "Standard");
                shadowPokemon.Form = "Shadow";
                Assert.AreEqual(shadowPokemon.Form, "Shadow");
            }
            else
            {
                Assert.Throws <ArgumentOutOfRangeException>(
                    delegate
                {
                    new PKMN.Pokemon(PKMN.Species.LEDYBA, game, "Shadow", 50);
                }
                    );
            }
        }
Exemplo n.º 21
0
    public void PokemonHelpersTest()
    {
        PKMN.Pokemon pokemon = new PKMN.Pokemon(PKMN.Species.MEW, PKMN.Game.RUBY, "", 70);

        // The Pokemon class and its helpers all use the underlying pointer
        // in generating their hash codes. Make sure these aren't equal.

        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.EVs.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.IVs.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.ContestStats.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.Markings.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.Ribbons.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.Moves.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.IVs.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.ContestStats.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.Markings.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.Ribbons.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.Moves.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.EVs.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.ContestStats.GetHashCode());
        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.Markings.GetHashCode());
        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.Ribbons.GetHashCode());
        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.Moves.GetHashCode());
        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.IVs.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.ContestStats.GetHashCode(), pokemon.Markings.GetHashCode());
        Assert.AreNotEqual(pokemon.ContestStats.GetHashCode(), pokemon.Ribbons.GetHashCode());
        Assert.AreNotEqual(pokemon.ContestStats.GetHashCode(), pokemon.Moves.GetHashCode());
        Assert.AreNotEqual(pokemon.ContestStats.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.ContestStats.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.ContestStats.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.Markings.GetHashCode(), pokemon.Ribbons.GetHashCode());
        Assert.AreNotEqual(pokemon.Markings.GetHashCode(), pokemon.Moves.GetHashCode());
        Assert.AreNotEqual(pokemon.Markings.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.Markings.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.Markings.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.Ribbons.GetHashCode(), pokemon.Moves.GetHashCode());
        Assert.AreNotEqual(pokemon.Ribbons.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.Ribbons.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.Ribbons.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.Moves.GetHashCode(), pokemon.NumericAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.Moves.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.Moves.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.NumericAttributes.GetHashCode(), pokemon.StringAttributes.GetHashCode());
        Assert.AreNotEqual(pokemon.NumericAttributes.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        Assert.AreNotEqual(pokemon.StringAttributes.GetHashCode(), pokemon.BooleanAttributes.GetHashCode());

        for (int moveIndex = 0; moveIndex < pokemon.Moves.Count; ++moveIndex)
        {
            Assert.AreNotEqual(pokemon.Moves.GetHashCode(), pokemon.Moves[moveIndex].GetHashCode());
        }
    }