kipyin / pokemaster

Checkout kipyin/pokemaster2 !
https://github.com/kipyin/pokemaster2
2 stars 2 forks source link

Use `Pokemon.OFFICIAL` to switch between using official data and custom data #16

Open kipyin opened 5 years ago

kipyin commented 5 years ago

Currently, the Pokemon class will enforce all attributes and methods conform with the official data, and the users are not able to alter the attribute values whatsoever.

Conforming to the official data is a good practice, but what if the "official data" is wrong? Or what if the users want to make their own Pokémon world? In these cases, with the current design, the users only have one option: make and use their own database. This option will solve the first problem, but will not always solve the second, because the users have to use the database schema that veekun has designed.

Adding a Pokemon.OFFICIAL class variable as a switch will solve this issue:

class Pokemon:
    OFFICIAL = True
    def __init__(...):
        ...

In the methods, we can also add an if-else block that checks the setting:

class Pokemon:
    ...
    @property
    def ability(...):
        if self.OFFICIAL:
            return get_ability_from_db(...)
        else:
            return self._ability
kipyin commented 5 years ago

OK, but can we have two Pokémon, one is official and the other is not at the same time? For example, can official_mew interact with customized_mew? What is the key difference between these two mews?

kipyin commented 5 years ago

Adding an official argument to Pokemon() is better, since the "official" flag is tied to each individual Pokémon, not to all Pokémon.