public void SpeciesEnumListTest() { PKMN.SpeciesEnumList speciesEnumList = new PKMN.SpeciesEnumList(); speciesEnumList.Add(PKMN.Species.SQUIRTLE); speciesEnumList.Add(PKMN.Species.TOTODILE); speciesEnumList.Add(PKMN.Species.MUDKIP); speciesEnumList.Add(PKMN.Species.PIPLUP); speciesEnumList.Add(PKMN.Species.OSHAWOTT); PKMN.SpeciesEnumList speciesEnumListSame = new PKMN.SpeciesEnumList(); speciesEnumListSame.Add(PKMN.Species.SQUIRTLE); speciesEnumListSame.Add(PKMN.Species.TOTODILE); speciesEnumListSame.Add(PKMN.Species.MUDKIP); speciesEnumListSame.Add(PKMN.Species.PIPLUP); speciesEnumListSame.Add(PKMN.Species.OSHAWOTT); PKMN.SpeciesEnumList speciesEnumListReversed = new PKMN.SpeciesEnumList(); speciesEnumListReversed.Add(PKMN.Species.OSHAWOTT); speciesEnumListReversed.Add(PKMN.Species.PIPLUP); speciesEnumListReversed.Add(PKMN.Species.MUDKIP); speciesEnumListReversed.Add(PKMN.Species.TOTODILE); speciesEnumListReversed.Add(PKMN.Species.SQUIRTLE); Assert.AreEqual(speciesEnumList, speciesEnumList); Assert.AreEqual(speciesEnumList, speciesEnumListSame); Assert.AreEqual(speciesEnumList.GetHashCode(), speciesEnumListSame.GetHashCode()); Assert.AreNotEqual(speciesEnumList, speciesEnumListReversed); Assert.AreNotEqual(speciesEnumList.GetHashCode(), speciesEnumListReversed.GetHashCode()); }
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); }
public void GamecubeShadowPokemonListTest() { // // Colosseum // PKMN.SpeciesEnumList colosseumShadowPokemonList = PKMN.Database.Lists.GamecubeShadowPokemonList(true); Assert.AreEqual(colosseumShadowPokemonList.Count, 48); PKMN.StringList colosseumShadowPokemonNameList = PKMN.Database.Lists.GamecubeShadowPokemonNameList(true); Assert.AreEqual(colosseumShadowPokemonNameList.Count, 48); // Make sure lists match. for (int pokemonIndex = 0; pokemonIndex < colosseumShadowPokemonList.Count; ++pokemonIndex) { string pokemonName = PKMN.PKMN.SpeciesToString(colosseumShadowPokemonList[pokemonIndex]); Assert.AreEqual(pokemonName, colosseumShadowPokemonNameList[pokemonIndex]); } // // XD // PKMN.SpeciesEnumList xdShadowPokemonList = PKMN.Database.Lists.GamecubeShadowPokemonList(false); Assert.AreEqual(xdShadowPokemonList.Count, 83); PKMN.StringList xdShadowPokemonNameList = PKMN.Database.Lists.GamecubeShadowPokemonNameList(false); Assert.AreEqual(xdShadowPokemonNameList.Count, 83); // Make sure lists match. for (int pokemonIndex = 0; pokemonIndex < xdShadowPokemonList.Count; ++pokemonIndex) { string pokemonName = PKMN.PKMN.SpeciesToString(xdShadowPokemonList[pokemonIndex]); Assert.AreEqual(pokemonName, xdShadowPokemonNameList[pokemonIndex]); } }
public void PokemonListTest() { // Make sure trying to create an invalid list results in an exception Assert.Throws <IndexOutOfRangeException>( delegate { PKMN.Database.Lists.PokemonList(0, true); } ); Assert.Throws <IndexOutOfRangeException>( delegate { PKMN.Database.Lists.PokemonNameList(0, true); } ); PKMN.SpeciesEnumList speciesList = PKMN.Database.Lists.PokemonList(1, true); Assert.AreEqual(speciesList.Count, 151); Assert.AreEqual(speciesList[0], PKMN.Species.BULBASAUR); Assert.AreEqual(speciesList[150], PKMN.Species.MEW); PKMN.StringList speciesNameList = PKMN.Database.Lists.PokemonNameList(1, true); Assert.AreEqual(speciesNameList.Count, 151); Assert.AreEqual(speciesNameList[0], "Bulbasaur"); Assert.AreEqual(speciesNameList[150], "Mew"); // Make sure lists match. Assert.AreEqual(speciesList.Count, speciesNameList.Count); for (int speciesIndex = 0; speciesIndex < speciesList.Count; ++speciesIndex) { string speciesName = PKMN.PKMN.SpeciesToString(speciesList[speciesIndex]); Assert.AreEqual(speciesName, speciesNameList[speciesIndex]); } }
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); } } }
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); }
public static void TestPokedex( PKMN.Pokedex pokedex ) { int generation = Util.GameToGeneration(pokedex.Game); // Test initial values. Assert.AreEqual(0, pokedex.NumSeen); Assert.AreEqual(0, pokedex.AllSeen.Count); Assert.AreEqual(0, pokedex.NumCaught); Assert.AreEqual(0, pokedex.AllCaught.Count); // Set random Pokémon to be seen and caught. PKMN.SpeciesEnumList allPokemon = PKMN.Database.Lists.PokemonList(generation, true); int numSeen = rng.Next(0, allPokemon.Count); int numCaught = rng.Next(0, allPokemon.Count); PKMN.IntList allSeenNums = new PKMN.IntList(); while (allSeenNums.Count < numSeen) { int index = rng.Next(0, allPokemon.Count); if (allSeenNums.IndexOf(index) == -1) { allSeenNums.Add(index); PKMN.Species species = allPokemon[index]; pokedex.SeenPokemonMap[species] = true; Assert.IsTrue(pokedex.SeenPokemonMap[species]); } } Assert.AreEqual(allSeenNums.Count, pokedex.NumSeen); Assert.AreEqual(allSeenNums.Count, pokedex.AllSeen.Count); PKMN.IntList allCaughtNums = new PKMN.IntList(); while (allCaughtNums.Count < numCaught) { int index = rng.Next(0, allPokemon.Count); if (allCaughtNums.IndexOf(index) == -1) { allCaughtNums.Add(index); PKMN.Species species = allPokemon[index]; pokedex.CaughtPokemonMap[species] = true; Assert.IsTrue(pokedex.CaughtPokemonMap[species]); } } Assert.AreEqual(allCaughtNums.Count, pokedex.NumCaught); Assert.AreEqual(allCaughtNums.Count, pokedex.AllCaught.Count); // Remove all entries. foreach (PKMN.Species species in pokedex.AllSeen) { pokedex.SeenPokemonMap[species] = false; Assert.IsFalse(pokedex.SeenPokemonMap[species]); } Assert.AreEqual(0, pokedex.NumSeen); Assert.AreEqual(0, pokedex.AllSeen.Count); foreach (PKMN.Species species in pokedex.AllCaught) { pokedex.CaughtPokemonMap[species] = false; Assert.IsFalse(pokedex.CaughtPokemonMap[species]); } Assert.AreEqual(0, pokedex.NumCaught); Assert.AreEqual(0, pokedex.AllCaught.Count); }