Ejemplo n.º 1
0
    def __test_setting_pokemon(self, daycare):
        daycare.levelup_pokemon[0] = pkmn.pokemon(pkmn.species.VENUSAUR,
                                                  daycare.game, "", 50)
        self.assertEquals(pkmn.species.VENUSAUR,
                          daycare.levelup_pokemon[0].species)

        if len(daycare.levelup_pokemon) == 2:
            daycare.levelup_pokemon[1] = pkmn.pokemon(pkmn.species.CHARIZARD,
                                                      daycare.game, "", 50)
            self.assertEquals(pkmn.species.CHARIZARD,
                              daycare.levelup_pokemon[1].species)

        # TODO: validate genders
        if daycare.can_breed_pokemon:
            daycare.levelup_pokemon[0] = pkmn.pokemon(pkmn.species.BLASTOISE,
                                                      daycare.game, "", 50)
            daycare.levelup_pokemon[0].gender = pkmn.gender.FEMALE

            self.assertEquals(pkmn.species.BLASTOISE,
                              daycare.levelup_pokemon[0].species)
            self.assertEquals(pkmn.gender.FEMALE,
                              daycare.levelup_pokemon[0].gender)

            daycare.levelup_pokemon[1] = pkmn.pokemon(pkmn.species.MAROWAK,
                                                      daycare.game, "", 50)
            daycare.levelup_pokemon[1].gender = pkmn.gender.MALE

            self.assertEquals(pkmn.species.MAROWAK,
                              daycare.levelup_pokemon[1].species)
            self.assertEquals(pkmn.gender.MALE,
                              daycare.levelup_pokemon[1].gender)
Ejemplo n.º 2
0
    def __test_setting_pokemon(self, daycare):
        daycare.levelup_pokemon[0] = pkmn.pokemon(
                                         pkmn.species.VENUSAUR,
                                         daycare.game,
                                         "",
                                         50
                                     )
        self.assertEquals(
            pkmn.species.VENUSAUR,
            daycare.levelup_pokemon[0].species
        )

        if len(daycare.levelup_pokemon) == 2:
            daycare.levelup_pokemon[1] = pkmn.pokemon(
                                             pkmn.species.CHARIZARD,
                                             daycare.game,
                                             "",
                                             50
                                         )
            self.assertEquals(
                pkmn.species.CHARIZARD,
                daycare.levelup_pokemon[1].species
            )

        # TODO: validate genders
        if daycare.can_breed_pokemon:
            daycare.levelup_pokemon[0] = pkmn.pokemon(
                                             pkmn.species.BLASTOISE,
                                             daycare.game,
                                             "",
                                             50
                                         )
            daycare.levelup_pokemon[0].gender = pkmn.gender.FEMALE

            self.assertEquals(
                pkmn.species.BLASTOISE,
                daycare.levelup_pokemon[0].species
            )
            self.assertEquals(
                pkmn.gender.FEMALE,
                daycare.levelup_pokemon[0].gender
            )

            daycare.levelup_pokemon[1] = pkmn.pokemon(
                                             pkmn.species.MAROWAK,
                                             daycare.game,
                                             "",
                                             50
                                         )
            daycare.levelup_pokemon[1].gender = pkmn.gender.MALE

            self.assertEquals(
                pkmn.species.MAROWAK,
                daycare.levelup_pokemon[1].species
            )
            self.assertEquals(
                pkmn.gender.MALE,
                daycare.levelup_pokemon[1].gender
            )
Ejemplo n.º 3
0
    def test_unown(self, game_name):
        game = pkmn.string_to_game(game_name)

        unown_entry = pkmn.database.pokemon_entry(pkmn.species.UNOWN, game, "")

        unown = None

        for form in unown_entry.forms:
            unown = pkmn.pokemon(pkmn.species.UNOWN, game, form, 5)
            self.assertEqual(unown.form, form)

            # Make sure personality is properly set.
            form_from_personality = pkmn.calculations.gen3_unown_form(
                unown.personality)
            self.assertEqual(unown.form, form_from_personality)

            self.assertTrue(os.path.exists(unown.icon_filepath))
            self.assertTrue(os.path.exists(unown.sprite_filepath))

        # Make sure setting the form properly changes the IVs.
        for form in unown_entry.forms:
            unown.form = form
            self.assertEqual(unown.form, form)

            # Make sure personality is properly set.
            form_from_personality = pkmn.calculations.gen3_unown_form(
                unown.personality)
            self.assertEqual(unown.form, form_from_personality)

            self.assertTrue(os.path.exists(unown.icon_filepath))
            self.assertTrue(os.path.exists(unown.sprite_filepath))

        # Make sure setting the personality properly sets the form.
        unown.personality = 0x4C07DE71
        self.assertEqual(unown.form, "B")
Ejemplo n.º 4
0
    def test_pokemon(self, species, game):
        pokemon = pkmn.pokemon(species, game, "", 30)
        test_params = pokemon_test_base.pokemon_test_params(
            pkmn.ball.GREAT_BALL, [pkmn.ball.GREAT_BALL], pkmn.item.BERRY,
            [pkmn.item.RAZZ_BERRY, pkmn.item.BICYCLE],
            pkmn.pokemon_stat.SPECIAL, ["Sprout Tower", "Tohjo Falls"],
            ["Littleroot Town", "Petalburg Woods"], [
                pkmn.move.SLASH, pkmn.move.FLAMETHROWER, pkmn.move.RETURN,
                pkmn.move.FIRE_BLAST
            ], [pkmn.move.FRENZY_PLANT, pkmn.move.ROOST], [pkmn.game.GOLD],
            [pkmn.game.GOLD])
        self.common_test(pokemon, test_params)

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

        pokemon.gender = pkmn.gender.MALE
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 15)
        pokemon.gender = pkmn.gender.FEMALE
        self.assertLess(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 15)

        pokemon.IVs[pkmn.pokemon_stat.ATTACK] = 0
        self.assertEqual(pokemon.gender, pkmn.gender.FEMALE)
        pokemon.IVs[pkmn.pokemon_stat.ATTACK] = 15
        self.assertEqual(pokemon.gender, pkmn.gender.MALE)

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

        pokemon.is_shiny = False
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 13)

        pokemon.is_shiny = True
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 15)
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.DEFENSE], 10)
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.SPEED], 10)
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.SPECIAL], 10)
Ejemplo n.º 5
0
    def test_gender(self, game_name):
        game = pkmn.string_to_game(game_name)

        # Single-gender
        nidorina = pkmn.pokemon(pkmn.species.NIDORINA, game, "", 50)
        self.assertEqual(nidorina.gender, pkmn.gender.FEMALE)
        nidorina.gender = pkmn.gender.FEMALE
        with self.assertRaises(ValueError):
            nidorina.gender = pkmn.gender.MALE
        with self.assertRaises(ValueError):
            nidorina.gender = pkmn.gender.GENDERLESS

        nidorino = pkmn.pokemon(pkmn.species.NIDORINO, game, "", 50)
        self.assertEqual(nidorino.gender, pkmn.gender.MALE)
        nidorino.gender = pkmn.gender.MALE
        with self.assertRaises(ValueError):
            nidorino.gender = pkmn.gender.FEMALE
        with self.assertRaises(ValueError):
            nidorino.gender = pkmn.gender.GENDERLESS

        magnemite = pkmn.pokemon(pkmn.species.MAGNEMITE, game, "", 50)
        self.assertEqual(magnemite.gender, pkmn.gender.GENDERLESS)
        magnemite.gender = pkmn.gender.GENDERLESS
        with self.assertRaises(ValueError):
            magnemite.gender = pkmn.gender.MALE
        with self.assertRaises(ValueError):
            magnemite.gender = pkmn.gender.FEMALE

        mixed_pokemon = [
            pkmn.species.CHARMANDER,  # 87.5% male
            pkmn.species.GROWLITHE,  # 75% male
            pkmn.species.PIDGEY,  # 50% male
            pkmn.species.VULPIX  # 25% male
        ]

        for species in mixed_pokemon:
            pokemon = pkmn.pokemon(species, game, "", 50)
            pokemon.gender = pkmn.gender.FEMALE
            self.assertEqual(pokemon.gender, pkmn.gender.FEMALE)
            pokemon.gender = pkmn.gender.MALE
            self.assertEqual(pokemon.gender, pkmn.gender.MALE)
            with self.assertRaises(ValueError):
                pokemon.gender = pkmn.gender.GENDERLESS
Ejemplo n.º 6
0
    def test_gender(self, game_name):
        game = pkmn.string_to_game(game_name)

        # Single-gender
        nidorina = pkmn.pokemon(pkmn.species.NIDORINA, game, "", 50)
        self.assertEqual(nidorina.gender, pkmn.gender.FEMALE)
        nidorina.gender = pkmn.gender.FEMALE
        with self.assertRaises(ValueError):
            nidorina.gender = pkmn.gender.MALE
        with self.assertRaises(ValueError):
            nidorina.gender = pkmn.gender.GENDERLESS

        nidorino = pkmn.pokemon(pkmn.species.NIDORINO, game, "", 50)
        self.assertEqual(nidorino.gender, pkmn.gender.MALE)
        nidorino.gender = pkmn.gender.MALE
        with self.assertRaises(ValueError):
            nidorino.gender = pkmn.gender.FEMALE
        with self.assertRaises(ValueError):
            nidorino.gender = pkmn.gender.GENDERLESS

        magnemite = pkmn.pokemon(pkmn.species.MAGNEMITE, game, "", 50)
        self.assertEqual(magnemite.gender, pkmn.gender.GENDERLESS)
        magnemite.gender = pkmn.gender.GENDERLESS
        with self.assertRaises(ValueError):
            magnemite.gender = pkmn.gender.MALE
        with self.assertRaises(ValueError):
            magnemite.gender = pkmn.gender.FEMALE

        mixed_pokemon = [
            pkmn.species.CHARMANDER, # 87.5% male
            pkmn.species.GROWLITHE,  # 75% male
            pkmn.species.PIDGEY,     # 50% male
            pkmn.species.VULPIX      # 25% male
        ]

        for species in mixed_pokemon:
            pokemon = pkmn.pokemon(species, game, "", 50)
            pokemon.gender = pkmn.gender.FEMALE
            self.assertEqual(pokemon.gender, pkmn.gender.FEMALE)
            pokemon.gender = pkmn.gender.MALE
            self.assertEqual(pokemon.gender, pkmn.gender.MALE)
            with self.assertRaises(ValueError):
                pokemon.gender = pkmn.gender.GENDERLESS
Ejemplo n.º 7
0
    def test_pokemon(self, species, game):
        pokemon = pkmn.pokemon(species, game, "", 30)
        test_params = pokemon_test_base.pokemon_test_params(
            pkmn.ball.GREAT_BALL, [pkmn.ball.GREAT_BALL], pkmn.item.POTION,
            [pkmn.item.POTION], "Special", ["Route 1"], ["Route 1"], [
                pkmn.move.SLASH, pkmn.move.FLAMETHROWER, pkmn.move.TAIL_WHIP,
                pkmn.move.FIRE_BLAST
            ], [pkmn.move.RETURN], [pkmn.game.RED], [pkmn.game.RED])
        self.common_test(pokemon, test_params)

        # Test attributes.
        self.assertEqual(pokemon.numeric_attributes["Catch rate"], 45)
Ejemplo n.º 8
0
    def test_pokemon(self, species, game):
        pokemon = pkmn.pokemon(species, game, "", 30)
        test_params = pokemon_test_base.pokemon_test_params(
                          pkmn.ball.GREAT_BALL,
                          [pkmn.ball.GREAT_BALL],
                          pkmn.item.BERRY,
                          [pkmn.item.RAZZ_BERRY, pkmn.item.BICYCLE],
                          pkmn.pokemon_stat.SPECIAL,
                          ["Sprout Tower", "Tohjo Falls"],
                          ["Littleroot Town", "Petalburg Woods"],
                          [
                              pkmn.move.SLASH,
                              pkmn.move.FLAMETHROWER,
                              pkmn.move.RETURN,
                              pkmn.move.FIRE_BLAST
                          ],
                          [
                              pkmn.move.FRENZY_PLANT,
                              pkmn.move.ROOST
                          ],
                          [pkmn.game.GOLD],
                          [pkmn.game.GOLD]
                      )
        self.common_test(pokemon, test_params)

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

        pokemon.gender = pkmn.gender.MALE
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 15)
        pokemon.gender = pkmn.gender.FEMALE
        self.assertLess(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 15)

        pokemon.IVs[pkmn.pokemon_stat.ATTACK] = 0
        self.assertEqual(pokemon.gender, pkmn.gender.FEMALE)
        pokemon.IVs[pkmn.pokemon_stat.ATTACK] = 15
        self.assertEqual(pokemon.gender, pkmn.gender.MALE)

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

        pokemon.is_shiny = False
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 13)

        pokemon.is_shiny = True
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.ATTACK], 15)
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.DEFENSE], 10)
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.SPEED], 10)
        self.assertEqual(pokemon.IVs[pkmn.pokemon_stat.SPECIAL], 10)
Ejemplo n.º 9
0
    def get_specific_random_pokemon(
        self,
        game,
        species,
        form,
        move_list,
        item_list
    ):
        generation = GAME_TO_GENERATION[game]

        # Level bound accounts for Gen II level met limitation
        pokemon = pkmn.pokemon(species, game, form, random.randint(2, 63))

        for move_index in range(4):
            move = ""
            while True:
                move = random.choice(move_list)
                if move < pkmn.move.SHADOW_RUSH:
                    break
            pokemon.moves[move_index].move = move

        for EV in pokemon.EVs.keys:
            pokemon.EVs[EV] = random.randint(0, 255)
        for IV in pokemon.IVs.keys:
            pokemon.IVs[IV] = random.randint(0, 15)

        if generation >= 2:
            # Keep going until one is holdable.
            while (pokemon.held_item == pkmn.item.NONE) or \
                   ((pokemon.held_item >= pkmn.item.JOY_SCENT) and (pokemon.held_item <= pkmn.item.VIVID_SCENT)):
                try:
                    pokemon.held_item = random.choice(item_list)
                except:
                    continue

            pokemon.pokerus_duration = random.randint(0, 15)

        if generation >= 3:
            for marking in pokemon.markings.keys:
                pokemon.markings[marking] = random_bool()
            for ribbon in pokemon.ribbons.keys:
                pokemon.ribbons[ribbon] = random_bool()
            for contest_stat in pokemon.contest_stats.keys:
                pokemon.contest_stats[contest_stat] = random.randint(0, 255)

        return pokemon
Ejemplo n.º 10
0
    def test_unown(self, game_name):
        game = pkmn.string_to_game(game_name)

        unown_entry = pkmn.database.pokemon_entry(pkmn.species.UNOWN, game, "")

        unown = None

        for form in unown_entry.forms:
            unown = pkmn.pokemon(pkmn.species.UNOWN, game, form, 5)
            self.assertEqual(unown.form, form)

            # Make sure IVs are properly set.
            form_from_IVs = pkmn.calculations.gen2_unown_form(
                                unown.IVs[pkmn.pokemon_stat.ATTACK],
                                unown.IVs[pkmn.pokemon_stat.DEFENSE],
                                unown.IVs[pkmn.pokemon_stat.SPEED],
                                unown.IVs[pkmn.pokemon_stat.SPECIAL]
                            )
            self.assertEqual(unown.form, form_from_IVs)

            self.assertTrue(os.path.exists(unown.icon_filepath))
            self.assertTrue(os.path.exists(unown.sprite_filepath))

        # Make sure setting the form properly changes the IVs.
        for form in unown_entry.forms:
            unown.form = form
            self.assertEqual(unown.form, form)

            # Make sure IVs are properly set.
            form_from_IVs = pkmn.calculations.gen2_unown_form(
                                unown.IVs[pkmn.pokemon_stat.ATTACK],
                                unown.IVs[pkmn.pokemon_stat.DEFENSE],
                                unown.IVs[pkmn.pokemon_stat.SPEED],
                                unown.IVs[pkmn.pokemon_stat.SPECIAL]
                            )
            self.assertEqual(unown.form, form_from_IVs)

            self.assertTrue(os.path.exists(unown.icon_filepath))
            self.assertTrue(os.path.exists(unown.sprite_filepath))

        # Make sure setting IVs properly changes the form.
        unown.IVs[pkmn.pokemon_stat.ATTACK] = 10;
        unown.IVs[pkmn.pokemon_stat.DEFENSE] = 9;
        unown.IVs[pkmn.pokemon_stat.SPEED] = 1;
        unown.IVs[pkmn.pokemon_stat.SPECIAL] = 14;
        self.assertEquals(unown.form, "G");
Ejemplo n.º 11
0
    def _test_saving_and_loading(self, game, extension):
        tmp_path = os.path.join(
            TMP_DIR, "{0}_{1}.{2}".format(game, random.randint(0, 1000),
                                          extension))

        item_list = pkmn.database.lists.get_item_list(game)
        move_list = pkmn.database.lists.get_move_list(game)
        pokemon_list = pkmn.database.lists.get_pokemon_list(
            GAME_TO_GENERATION[game], True)

        random_pokemon = self.get_random_pokemon(game, pokemon_list, move_list,
                                                 item_list)
        random_pokemon.export_to_file(tmp_path)

        imported_pokemon = pkmn.pokemon(tmp_path)
        self.compare_pokemon(random_pokemon, imported_pokemon)

        os.remove(tmp_path)
Ejemplo n.º 12
0
    def test_unown(self, game_name):
        game = pkmn.string_to_game(game_name)

        unown_entry = pkmn.database.pokemon_entry(pkmn.species.UNOWN, game, "")

        unown = None

        for form in unown_entry.forms:
            unown = pkmn.pokemon(pkmn.species.UNOWN, game, form, 5)
            self.assertEqual(unown.form, form)

            # Make sure IVs are properly set.
            form_from_IVs = pkmn.calculations.gen2_unown_form(
                unown.IVs[pkmn.pokemon_stat.ATTACK],
                unown.IVs[pkmn.pokemon_stat.DEFENSE],
                unown.IVs[pkmn.pokemon_stat.SPEED],
                unown.IVs[pkmn.pokemon_stat.SPECIAL])
            self.assertEqual(unown.form, form_from_IVs)

            self.assertTrue(os.path.exists(unown.icon_filepath))
            self.assertTrue(os.path.exists(unown.sprite_filepath))

        # Make sure setting the form properly changes the IVs.
        for form in unown_entry.forms:
            unown.form = form
            self.assertEqual(unown.form, form)

            # Make sure IVs are properly set.
            form_from_IVs = pkmn.calculations.gen2_unown_form(
                unown.IVs[pkmn.pokemon_stat.ATTACK],
                unown.IVs[pkmn.pokemon_stat.DEFENSE],
                unown.IVs[pkmn.pokemon_stat.SPEED],
                unown.IVs[pkmn.pokemon_stat.SPECIAL])
            self.assertEqual(unown.form, form_from_IVs)

            self.assertTrue(os.path.exists(unown.icon_filepath))
            self.assertTrue(os.path.exists(unown.sprite_filepath))

        # Make sure setting IVs properly changes the form.
        unown.IVs[pkmn.pokemon_stat.ATTACK] = 10
        unown.IVs[pkmn.pokemon_stat.DEFENSE] = 9
        unown.IVs[pkmn.pokemon_stat.SPEED] = 1
        unown.IVs[pkmn.pokemon_stat.SPECIAL] = 14
        self.assertEquals(unown.form, "G")
Ejemplo n.º 13
0
    def _test_saving_and_loading(self, game, extension):
        tmp_path = os.path.join(TMP_DIR, "{0}_{1}.{2}".format(
                       game,
                       random.randint(0, 1000),
                       extension
                   ))

        item_list = pkmn.database.lists.get_item_list(game)
        move_list = pkmn.database.lists.get_move_list(game)
        pokemon_list = pkmn.database.lists.get_pokemon_list(
                           GAME_TO_GENERATION[game],
                           True
                       )

        random_pokemon = self.get_random_pokemon(game, pokemon_list, move_list, item_list)
        random_pokemon.export_to_file(tmp_path)

        imported_pokemon = pkmn.pokemon(tmp_path)
        self.compare_pokemon(random_pokemon, imported_pokemon)

        os.remove(tmp_path)
Ejemplo n.º 14
0
    def get_specific_random_pokemon(self, game, species, form, move_list,
                                    item_list):
        generation = GAME_TO_GENERATION[game]

        # Level bound accounts for Gen II level met limitation
        pokemon = pkmn.pokemon(species, game, form, random.randint(2, 63))

        for move_index in range(4):
            move = ""
            while True:
                move = random.choice(move_list)
                if move < pkmn.move.SHADOW_RUSH:
                    break
            pokemon.moves[move_index].move = move

        for EV in pokemon.EVs.keys:
            pokemon.EVs[EV] = random.randint(0, 255)
        for IV in pokemon.IVs.keys:
            pokemon.IVs[IV] = random.randint(0, 15)

        if generation >= 2:
            # Keep going until one is holdable.
            while (pokemon.held_item == pkmn.item.NONE) or \
                   ((pokemon.held_item >= pkmn.item.JOY_SCENT) and (pokemon.held_item <= pkmn.item.VIVID_SCENT)):
                try:
                    pokemon.held_item = random.choice(item_list)
                except:
                    continue

            pokemon.pokerus_duration = random.randint(0, 15)

        if generation >= 3:
            for marking in pokemon.markings.keys:
                pokemon.markings[marking] = random_bool()
            for ribbon in pokemon.ribbons.keys:
                pokemon.ribbons[ribbon] = random_bool()
            for contest_stat in pokemon.contest_stats.keys:
                pokemon.contest_stats[contest_stat] = random.randint(0, 255)

        return pokemon
Ejemplo n.º 15
0
    def test_pokemon(self, species_name, game_name):
        species = pkmn.string_to_species(species_name)
        game = pkmn.string_to_game(game_name)

        pokemon = pkmn.pokemon(species, game, "", 30)
        test_params = None

        valid_moves = [
            pkmn.move.SWALLOW, pkmn.move.FLAMETHROWER, pkmn.move.RETURN,
            pkmn.move.FIRE_BLAST
        ]
        valid_games = [
            pkmn.game.RUBY, pkmn.game.SAPPHIRE, pkmn.game.EMERALD,
            pkmn.game.FIRERED, pkmn.game.LEAFGREEN, pkmn.game.COLOSSEUM,
            pkmn.game.XD
        ]

        if game in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
            test_params = pokemon_test_base.pokemon_test_params(
                pkmn.ball.GREAT_BALL,
                [pkmn.ball.FRIEND_BALL, pkmn.ball.HEAL_BALL],
                pkmn.item.RAZZ_BERRY, [pkmn.item.BERRY, pkmn.item.MACH_BIKE],
                "Distant land", ["Phenac Story", "Orre Colosseum"],
                ["New Bark Town", "Twinleaf Town"], valid_moves,
                [pkmn.move.ROOST, pkmn.move.FLAME_BURST], valid_games,
                [pkmn.game.GOLD, pkmn.game.HEARTGOLD])
        else:
            test_params = pokemon_test_base.pokemon_test_params(
                pkmn.ball.GREAT_BALL,
                [pkmn.ball.FRIEND_BALL, pkmn.ball.HEAL_BALL],
                pkmn.item.RAZZ_BERRY, [pkmn.item.BERRY, pkmn.item.MACH_BIKE],
                "Fateful encounter", ["Petalburg Woods", "Viridian Forest"],
                ["New Bark Town", "Twinleaf Town"], valid_moves,
                [pkmn.move.SHADOW_SKY, pkmn.move.ROOST], valid_games,
                [pkmn.game.GOLD, pkmn.game.HEARTGOLD])

        self.common_test(pokemon, test_params)
Ejemplo n.º 16
0
    def test_pokemon(self, species, game):
        pokemon = pkmn.pokemon(species, game, "", 30)
        test_params = pokemon_test_base.pokemon_test_params(
                          pkmn.ball.GREAT_BALL,
                          [pkmn.ball.GREAT_BALL],
                          pkmn.item.POTION,
                          [pkmn.item.POTION],
                          "Special",
                          ["Route 1"],
                          ["Route 1"],
                          [
                              pkmn.move.SLASH,
                              pkmn.move.FLAMETHROWER,
                              pkmn.move.TAIL_WHIP,
                              pkmn.move.FIRE_BLAST
                          ],
                          [pkmn.move.RETURN],
                          [pkmn.game.RED],
                          [pkmn.game.RED]
                      )
        self.common_test(pokemon, test_params)

        # Test attributes.
        self.assertEqual(pokemon.numeric_attributes["Catch rate"], 45)
Ejemplo n.º 17
0
    def gen1_forms_test(self, game):
        generation = GAME_TO_GENERATION[game]

        # Check that Mega forms only work in their given games.
        for species in GEN1_POKEMON_WITH_XY_MEGA_FORMS:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        for species in GEN1_POKEMON_WITH_ORAS_MEGA_FORMS:
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        # Cosplay Pikachu should only work in OR/AS.
        for form in pkmn.database.pokemon_entry(pkmn.species.PIKACHU,
                                                pkmn.game.OMEGA_RUBY,
                                                "").forms[1:]:
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(pkmn.species.PIKACHU, game, form, 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(pkmn.species.PIKACHU, game, form, 100)

        # Hardcode Mega X/Y cases.
        for species in [pkmn.species.CHARIZARD, pkmn.species.MEWTWO]:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega X", 100)
                pkmn.pokemon(species, game, "Mega Y", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega X", 100)
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega Y", 100)
Ejemplo n.º 18
0
    def __test_setting_pokemon(self, party):
        game = party.game

        original_first = party[0]
        original_second = party[1]

        # Make sure we can't set Pokemon at invalid indices.
        with self.assertRaises(OverflowError):
            party[-1] = original_first
        with self.assertRaises(IndexError):
            party[len(party)] = original_second

        # Create Pokemon and place in party. The original variables should
        # have the same underlying Pokemon.
        bulbasaur = pkmn.pokemon(pkmn.species.BULBASAUR, game, "", 5)
        charmander = pkmn.pokemon(pkmn.species.CHARMANDER, game, "", 5)
        squirtle = pkmn.pokemon(pkmn.species.SQUIRTLE, game, "", 5)

        party[0] = bulbasaur
        self.assertEqual(party.num_pokemon, 1)
        self.assertEqual(party[0].species, pkmn.species.BULBASAUR)
        party[1] = charmander
        self.assertEqual(party.num_pokemon, 2)
        self.assertEqual(party[1].species, pkmn.species.CHARMANDER)

        # Replace one of the new ones.
        party[0] = squirtle
        self.assertEqual(party.num_pokemon, 2)
        self.assertEqual(party[0].species, pkmn.species.SQUIRTLE)

        # Copy a Pokemon already part of the party.
        party[2] = party[1]
        self.assertEqual(party.num_pokemon, 3)
        self.assertEqual(party[2].species, pkmn.species.CHARMANDER)

        # We should be able to clear the last contiguous Pokemon.
        party[2] = original_first
        self.assertEqual(party.num_pokemon, 2)
        self.assertEqual(party[2].species, pkmn.species.NONE)

        # Put it back.
        party[2] = party[1]
        self.assertEqual(party.num_pokemon, 3)

        # Check that Pokemon cannot be placed non-contiguously.
        with self.assertRaises(ValueError):
            party[1] = original_first
        self.assertEqual(party.num_pokemon, 3)
        self.assertEqual(party[1].species, pkmn.species.CHARMANDER)

        with self.assertRaises(IndexError):
            party[4] = bulbasaur
        self.assertEqual(party.num_pokemon, 3)
        self.assertEqual(party[4].species, pkmn.species.NONE)

        # Now check everything we've created. Each variable should have
        # the same underlying Pokemon.
        self.assertEqual(party[0].species, pkmn.species.SQUIRTLE)
        self.assertEqual(party[1].species, pkmn.species.CHARMANDER)
        self.assertEqual(party[2].species, pkmn.species.CHARMANDER)
        self.assertEqual(original_first.species, pkmn.species.NONE)
        self.assertEqual(original_second.species, pkmn.species.NONE)
        self.assertEqual(bulbasaur.species, pkmn.species.BULBASAUR)
        self.assertEqual(charmander.species, pkmn.species.CHARMANDER)
        self.assertEqual(squirtle.species, pkmn.species.SQUIRTLE)
Ejemplo n.º 19
0
    def gen2_forms_test(self, game):
        generation = GAME_TO_GENERATION[game]

        # Check that Mega forms only work in their given games.
        for species in GEN2_POKEMON_WITH_XY_MEGA_FORMS:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
            pkmn.pokemon(pkmn.species.STEELIX, game, "Mega", 100)
        else:
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.STEELIX, game, "Mega", 100)

        # Spiky-eared Pichu should only work in HG/SS.
        if game in [pkmn.game.HEARTGOLD, pkmn.game.SOULSILVER]:
            pkmn.pokemon(pkmn.species.PICHU, game, "Spiky-eared", 100)
        else:
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.PICHU, game, "Spiky-eared", 100)

        # Unown's "!" and "?" forms aren't in Generation II.
        for letter in string.ascii_uppercase:
            unown = pkmn.pokemon(pkmn.species.UNOWN, game, letter, 10)
            if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                self.assertTrue(os.path.exists(unown.icon_filepath))
                self.assertTrue(os.path.exists(unown.sprite_filepath))

        if generation > 2:
            pkmn.pokemon(pkmn.species.UNOWN, game, "!", 10)
            pkmn.pokemon(pkmn.species.UNOWN, game, "?", 10)
        else:
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.UNOWN, game, "!", 10)
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.UNOWN, game, "?", 10)
Ejemplo n.º 20
0
    def __test_setting_pokemon(self, box):
        game = box.game
        generation = GAME_TO_GENERATION[game]

        original_first = box[0]
        original_second = box[1]

        # Make sure we can't set Pokemon at invalid indices.
        with self.assertRaises(OverflowError):
            box[-1] = original_first
        with self.assertRaises(IndexError):
            box[len(box)] = original_second

        # Create Pokemon and place in box. The original variables should
        # have the same underlying Pokemon.
        bulbasaur = pkmn.pokemon(pkmn.species.BULBASAUR, game, "", 5)
        charmander = pkmn.pokemon(pkmn.species.CHARMANDER, game, "", 5)
        squirtle = pkmn.pokemon(pkmn.species.SQUIRTLE, game, "", 5)

        box[0] = bulbasaur
        box[1] = charmander

        # Replace one of the new ones.
        box[0] = squirtle

        # Copy a Pokemon already part of the box.
        box[2] = box[1]

        # We should always be able to clear the last contiguous Pokemon.
        box[2] = original_first
        self.assertEqual(box.num_pokemon, 2)
        self.assertStringEqual(box[2].species, pkmn.species.NONE)

        # Put it back.
        box[2] = box[1]
        self.assertEqual(box.num_pokemon, 3)

        # Check that Pokemon can be placed non-contiguously in the correct games.
        if generation <= 2:
            with self.assertRaises(ValueError):
                box[1] = original_first
            self.assertEqual(box.num_pokemon, 3)
            self.assertStringEqual(box[1].species, pkmn.species.CHARMANDER)

            with self.assertRaises(IndexError):
                box[4] = bulbasaur
            self.assertEqual(box.num_pokemon, 3)
            self.assertStringEqual(box[4].species, pkmn.species.NONE)
        else:
            box[1] = original_first
            self.assertEqual(box.num_pokemon, 2)
            self.assertStringEqual(box[1].species, pkmn.species.NONE)

            box[4] = bulbasaur
            self.assertEqual(box.num_pokemon, 3)
            self.assertStringEqual(box[4].species, pkmn.species.BULBASAUR)

            # Restore it to how it was.
            box[1] = charmander
            box[4] = original_first
            self.assertStringEqual(box[1].species, pkmn.species.CHARMANDER)
            self.assertStringEqual(box[4].species, pkmn.species.NONE)

        # Now check everything we've created. Each variable should have
        # the same underlying Pokemon.
        self.assertEqual(box[0].species, pkmn.species.SQUIRTLE)
        self.assertEqual(box[1].species, pkmn.species.CHARMANDER)
        self.assertEqual(box[2].species, pkmn.species.CHARMANDER)
        self.assertEqual(original_first.species, pkmn.species.NONE)
        self.assertEqual(original_second.species, pkmn.species.NONE)
        self.assertEqual(bulbasaur.species, pkmn.species.BULBASAUR)
        self.assertEqual(charmander.species, pkmn.species.CHARMANDER)
        self.assertEqual(squirtle.species, pkmn.species.SQUIRTLE)
Ejemplo n.º 21
0
    def gen1_forms_test(self, game):
        generation = GAME_TO_GENERATION[game]

        # Check that Mega forms only work in their given games.
        for species in GEN1_POKEMON_WITH_XY_MEGA_FORMS:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        for species in GEN1_POKEMON_WITH_ORAS_MEGA_FORMS:
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        # Cosplay Pikachu should only work in OR/AS.
        for form in pkmn.database.pokemon_entry(pkmn.species.PIKACHU,
                                                pkmn.game.OMEGA_RUBY,
                                                "").forms[1:]:
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(pkmn.species.PIKACHU, game, form, 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(pkmn.species.PIKACHU, game, form, 100)

        # Hardcode Mega X/Y cases.
        for species in [pkmn.species.CHARIZARD, pkmn.species.MEWTWO]:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega X", 100)
                pkmn.pokemon(species, game, "Mega Y", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega X", 100)
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega Y", 100)
Ejemplo n.º 22
0
    def test_outside_3gpkm(self):
        # Test files in repo and compare to known values.
        _3gpkm_dir = os.path.join(LIBPKMN_TEST_FILES, "3gpkm")

        mightyena = pkmn.pokemon(os.path.join(_3gpkm_dir, "MIGHTYENA.3gpkm"))
        self.assertEqual(mightyena.species, pkmn.species.MIGHTYENA)
        self.assertEqual(mightyena.game, pkmn.game.EMERALD)
        self.assertEqual(mightyena.form, "Standard")
        self.assertEqual(mightyena.nickname, "MIGHTYENA")
        self.assertFalse(mightyena.is_shiny)
        self.assertEqual(mightyena.condition, pkmn.condition.NONE)
        self.assertEqual(mightyena.held_item, pkmn.item.HEART_SCALE)
        self.assertEqual(mightyena.original_trainer_name, "A")
        self.assertEqual(mightyena.original_trainer_public_id, 61415)
        self.assertEqual(mightyena.original_trainer_secret_id, 3417)
        self.assertEqual(mightyena.original_trainer_id, 223997927)
        self.assertEqual(mightyena.original_trainer_gender, pkmn.gender.FEMALE)
        self.assertEqual(mightyena.current_trainer_friendship, 254)
        self.assertEqual(mightyena.ability, pkmn.ability.INTIMIDATE)
        self.assertEqual(mightyena.ball, pkmn.ball.GREAT_BALL)
        self.assertEqual(mightyena.level_met, 25)
        self.assertEqual(mightyena.location_met, "Route 120")
        self.assertEqual(mightyena.original_game, pkmn.game.EMERALD)
        self.assertEqual(mightyena.personality, 3557601241)
        self.assertEqual(mightyena.experience, 128734)
        self.assertEqual(mightyena.level, 50)

        self.assertEqual(len(mightyena.markings), 4)
        for marking in mightyena.markings.keys:
            self.assertFalse(mightyena.markings[marking])

        self.assertEqual(len(mightyena.ribbons), 32)
        for ribbon in mightyena.ribbons.keys:
            if ribbon == "Champion":
                self.assertTrue(mightyena.ribbons[ribbon])
            else:
                self.assertFalse(mightyena.ribbons[ribbon])

        self.assertEqual(len(mightyena.contest_stats), 6)
        for contest_stat in mightyena.contest_stats.keys:
            self.assertEqual(mightyena.contest_stats[contest_stat], 0)

        expected_moves = [
            pkmn.move.CRUNCH,
            pkmn.move.STRENGTH,
            pkmn.move.SHADOW_BALL,
            pkmn.move.DOUBLE_EDGE
        ]
        self.assertEqual(len(mightyena.moves), 4)
        for move_index in range(4):
            self.assertEqual(
                mightyena.moves[move_index].move,
                expected_moves[move_index]
            )

        self.assertEqual(len(mightyena.EVs), 6)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.HP], 30)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.ATTACK], 110)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.DEFENSE], 32)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.SPEED], 48)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.SPECIAL_ATTACK], 17)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.SPECIAL_DEFENSE], 83)

        self.assertEqual(len(mightyena.IVs), 6)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.HP], 26)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.ATTACK], 28)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.DEFENSE], 4)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.SPEED], 13)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.SPECIAL_ATTACK], 25)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.SPECIAL_DEFENSE], 26)

        self.assertEqual(len(mightyena.stats), 6)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.HP], 146)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.ATTACK], 122)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.DEFENSE], 81)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.SPEED], 87)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.SPECIAL_ATTACK], 79)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.SPECIAL_DEFENSE], 88)
Ejemplo n.º 23
0
    def gen3_forms_test(self, game):
        gamecube = (game in [pkmn.game.COLOSSEUM, pkmn.game.XD])
        generation = GAME_TO_GENERATION[game]

        # Check that Mega forms only work in their given games.
        for species in GEN3_POKEMON_WITH_XY_MEGA_FORMS:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        for species in GEN3_POKEMON_WITH_ORAS_MEGA_FORMS:
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        # Castform should always work.
        for form in pkmn.database.pokemon_entry(pkmn.species.CASTFORM,
                                                pkmn.game.OMEGA_RUBY,
                                                "").forms:
            castform = pkmn.pokemon(pkmn.species.CASTFORM, game, form, 30)
            if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                self.assertTrue(os.path.exists(castform.icon_filepath))
                self.assertTrue(os.path.exists(castform.sprite_filepath))

        # Primal Reversion should only work in OR/AS.
        for species in [pkmn.species.GROUDON, pkmn.species.KYOGRE]:
            pokemon = pkmn.pokemon(species, game, "", 70)
            if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                self.assertTrue(os.path.exists(pokemon.icon_filepath))
                self.assertTrue(os.path.exists(pokemon.sprite_filepath))
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(species, game, "Primal Reversion", 70)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Primal Reversion", 70)

        # In Generation III, Deoxys's form is game-specific.
        if generation == 3:
            if game in [
                    pkmn.game.RUBY, pkmn.game.SAPPHIRE, pkmn.game.COLOSSEUM,
                    pkmn.game.XD
            ]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Normal", 70)
                if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                    self.assertTrue(os.path.exists(deoxys.icon_filepath))
                    self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Normal",
                                          70)

            if game in [pkmn.game.FIRERED]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Attack", 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Attack",
                                          70)

            if game in [pkmn.game.LEAFGREEN]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Defense", 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Defense",
                                          70)

            if game in [pkmn.game.EMERALD]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Speed", 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Speed",
                                          70)
        else:
            for form in pkmn.database.pokemon_entry(pkmn.species.DEOXYS,
                                                    pkmn.game.OMEGA_RUBY,
                                                    "").forms:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, form, 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
Ejemplo n.º 24
0
    def gen3_forms_test(self, game):
        gamecube = (game in [pkmn.game.COLOSSEUM, pkmn.game.XD])
        generation = GAME_TO_GENERATION[game]

        # Check that Mega forms only work in their given games.
        for species in GEN3_POKEMON_WITH_XY_MEGA_FORMS:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        for species in GEN3_POKEMON_WITH_ORAS_MEGA_FORMS:
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        # Castform should always work.
        for form in pkmn.database.pokemon_entry(pkmn.species.CASTFORM,
                                                pkmn.game.OMEGA_RUBY,
                                                "").forms:
            castform = pkmn.pokemon(pkmn.species.CASTFORM, game, form, 30)
            if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                self.assertTrue(os.path.exists(castform.icon_filepath))
                self.assertTrue(os.path.exists(castform.sprite_filepath))

        # Primal Reversion should only work in OR/AS.
        for species in [pkmn.species.GROUDON, pkmn.species.KYOGRE]:
            pokemon = pkmn.pokemon(species, game, "", 70)
            if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                self.assertTrue(os.path.exists(pokemon.icon_filepath))
                self.assertTrue(os.path.exists(pokemon.sprite_filepath))
            if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
                pkmn.pokemon(species, game, "Primal Reversion", 70)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Primal Reversion", 70)

        # In Generation III, Deoxys's form is game-specific.
        if generation == 3:
            if game in [pkmn.game.RUBY, pkmn.game.SAPPHIRE, pkmn.game.COLOSSEUM, pkmn.game.XD]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Normal", 70)
                if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                    self.assertTrue(os.path.exists(deoxys.icon_filepath))
                    self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Normal", 70)

            if game in [pkmn.game.FIRERED]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Attack", 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Attack", 70)

            if game in [pkmn.game.LEAFGREEN]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Defense", 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Defense", 70)

            if game in [pkmn.game.EMERALD]:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Speed", 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
            else:
                with self.assertRaises(ValueError):
                    deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, "Speed", 70)
        else:
            for form in pkmn.database.pokemon_entry(pkmn.species.DEOXYS,
                                                    pkmn.game.OMEGA_RUBY,
                                                    "").forms:
                deoxys = pkmn.pokemon(pkmn.species.DEOXYS, game, form, 70)
                self.assertTrue(os.path.exists(deoxys.icon_filepath))
                self.assertTrue(os.path.exists(deoxys.sprite_filepath))
Ejemplo n.º 25
0
    def test_outside_3gpkm(self):
        # Test files in repo and compare to known values.
        _3gpkm_dir = os.path.join(LIBPKMN_TEST_FILES, "3gpkm")

        mightyena = pkmn.pokemon(os.path.join(_3gpkm_dir, "MIGHTYENA.3gpkm"))
        self.assertEqual(mightyena.species, pkmn.species.MIGHTYENA)
        self.assertEqual(mightyena.game, pkmn.game.EMERALD)
        self.assertEqual(mightyena.form, "Standard")
        self.assertEqual(mightyena.nickname, "MIGHTYENA")
        self.assertFalse(mightyena.is_shiny)
        self.assertEqual(mightyena.condition, pkmn.condition.NONE)
        self.assertEqual(mightyena.held_item, pkmn.item.HEART_SCALE)
        self.assertEqual(mightyena.original_trainer_name, "A")
        self.assertEqual(mightyena.original_trainer_public_id, 61415)
        self.assertEqual(mightyena.original_trainer_secret_id, 3417)
        self.assertEqual(mightyena.original_trainer_id, 223997927)
        self.assertEqual(mightyena.original_trainer_gender, pkmn.gender.FEMALE)
        self.assertEqual(mightyena.current_trainer_friendship, 254)
        self.assertEqual(mightyena.ability, pkmn.ability.INTIMIDATE)
        self.assertEqual(mightyena.ball, pkmn.ball.GREAT_BALL)
        self.assertEqual(mightyena.level_met, 25)
        self.assertEqual(mightyena.location_met, "Route 120")
        self.assertEqual(mightyena.original_game, pkmn.game.EMERALD)
        self.assertEqual(mightyena.personality, 3557601241)
        self.assertEqual(mightyena.experience, 128734)
        self.assertEqual(mightyena.level, 50)

        self.assertEqual(len(mightyena.markings), 4)
        for marking in mightyena.markings.keys:
            self.assertFalse(mightyena.markings[marking])

        self.assertEqual(len(mightyena.ribbons), 32)
        for ribbon in mightyena.ribbons.keys:
            if ribbon == "Champion":
                self.assertTrue(mightyena.ribbons[ribbon])
            else:
                self.assertFalse(mightyena.ribbons[ribbon])

        self.assertEqual(len(mightyena.contest_stats), 6)
        for contest_stat in mightyena.contest_stats.keys:
            self.assertEqual(mightyena.contest_stats[contest_stat], 0)

        expected_moves = [
            pkmn.move.CRUNCH, pkmn.move.STRENGTH, pkmn.move.SHADOW_BALL,
            pkmn.move.DOUBLE_EDGE
        ]
        self.assertEqual(len(mightyena.moves), 4)
        for move_index in range(4):
            self.assertEqual(mightyena.moves[move_index].move,
                             expected_moves[move_index])

        self.assertEqual(len(mightyena.EVs), 6)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.HP], 30)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.ATTACK], 110)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.DEFENSE], 32)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.SPEED], 48)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.SPECIAL_ATTACK], 17)
        self.assertEqual(mightyena.EVs[pkmn.pokemon_stat.SPECIAL_DEFENSE], 83)

        self.assertEqual(len(mightyena.IVs), 6)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.HP], 26)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.ATTACK], 28)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.DEFENSE], 4)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.SPEED], 13)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.SPECIAL_ATTACK], 25)
        self.assertEqual(mightyena.IVs[pkmn.pokemon_stat.SPECIAL_DEFENSE], 26)

        self.assertEqual(len(mightyena.stats), 6)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.HP], 146)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.ATTACK], 122)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.DEFENSE], 81)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.SPEED], 87)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.SPECIAL_ATTACK], 79)
        self.assertEqual(mightyena.stats[pkmn.pokemon_stat.SPECIAL_DEFENSE],
                         88)
Ejemplo n.º 26
0
    def __test_setting_pokemon(self, party):
        game = party.game

        original_first = party[0]
        original_second = party[1]

        # Make sure we can't set Pokemon at invalid indices.
        with self.assertRaises(OverflowError):
            party[-1] = original_first
        with self.assertRaises(IndexError):
            party[len(party)] = original_second

        # Create Pokemon and place in party. The original variables should
        # have the same underlying Pokemon.
        bulbasaur = pkmn.pokemon(pkmn.species.BULBASAUR, game, "", 5)
        charmander = pkmn.pokemon(pkmn.species.CHARMANDER, game, "", 5)
        squirtle = pkmn.pokemon(pkmn.species.SQUIRTLE, game, "", 5)

        party[0] = bulbasaur
        self.assertEqual(party.num_pokemon, 1)
        self.assertEqual(party[0].species, pkmn.species.BULBASAUR)
        party[1] = charmander
        self.assertEqual(party.num_pokemon, 2)
        self.assertEqual(party[1].species, pkmn.species.CHARMANDER)

        # Replace one of the new ones.
        party[0] = squirtle
        self.assertEqual(party.num_pokemon, 2)
        self.assertEqual(party[0].species, pkmn.species.SQUIRTLE)

        # Copy a Pokemon already part of the party.
        party[2] = party[1]
        self.assertEqual(party.num_pokemon, 3)
        self.assertEqual(party[2].species, pkmn.species.CHARMANDER)

        # We should be able to clear the last contiguous Pokemon.
        party[2] = original_first
        self.assertEqual(party.num_pokemon, 2)
        self.assertEqual(party[2].species, pkmn.species.NONE)

        # Put it back.
        party[2] = party[1]
        self.assertEqual(party.num_pokemon, 3)

        # Check that Pokemon cannot be placed non-contiguously.
        with self.assertRaises(ValueError):
            party[1] = original_first
        self.assertEqual(party.num_pokemon, 3)
        self.assertEqual(party[1].species, pkmn.species.CHARMANDER)

        with self.assertRaises(IndexError):
            party[4] = bulbasaur
        self.assertEqual(party.num_pokemon, 3)
        self.assertEqual(party[4].species, pkmn.species.NONE)

        # Now check everything we've created. Each variable should have
        # the same underlying Pokemon.
        self.assertEqual(party[0].species, pkmn.species.SQUIRTLE)
        self.assertEqual(party[1].species, pkmn.species.CHARMANDER)
        self.assertEqual(party[2].species, pkmn.species.CHARMANDER)
        self.assertEqual(original_first.species, pkmn.species.NONE)
        self.assertEqual(original_second.species, pkmn.species.NONE)
        self.assertEqual(bulbasaur.species, pkmn.species.BULBASAUR)
        self.assertEqual(charmander.species, pkmn.species.CHARMANDER)
        self.assertEqual(squirtle.species, pkmn.species.SQUIRTLE)
Ejemplo n.º 27
0
    def gen2_forms_test(self, game):
        generation = GAME_TO_GENERATION[game]

        # Check that Mega forms only work in their given games.
        for species in GEN2_POKEMON_WITH_XY_MEGA_FORMS:
            if generation >= 6:
                pkmn.pokemon(species, game, "Mega", 100)
            else:
                with self.assertRaises(ValueError):
                    pkmn.pokemon(species, game, "Mega", 100)

        if game in [pkmn.game.OMEGA_RUBY, pkmn.game.ALPHA_SAPPHIRE]:
            pkmn.pokemon(pkmn.species.STEELIX, game, "Mega", 100)
        else:
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.STEELIX, game, "Mega", 100)

        # Spiky-eared Pichu should only work in HG/SS.
        if game in [pkmn.game.HEARTGOLD, pkmn.game.SOULSILVER]:
            pkmn.pokemon(pkmn.species.PICHU, game, "Spiky-eared", 100)
        else:
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.PICHU, game, "Spiky-eared", 100)

        # Unown's "!" and "?" forms aren't in Generation II.
        for letter in string.ascii_uppercase:
            unown = pkmn.pokemon(pkmn.species.UNOWN, game, letter, 10)
            if game not in [pkmn.game.COLOSSEUM, pkmn.game.XD]:
                self.assertTrue(os.path.exists(unown.icon_filepath))
                self.assertTrue(os.path.exists(unown.sprite_filepath))

        if generation > 2:
            pkmn.pokemon(pkmn.species.UNOWN, game, "!", 10)
            pkmn.pokemon(pkmn.species.UNOWN, game, "?", 10)
        else:
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.UNOWN, game, "!", 10)
            with self.assertRaises(ValueError):
                pkmn.pokemon(pkmn.species.UNOWN, game, "?", 10)