kipyin / pokemaster

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

`Pokemon` instantiation #7

Closed kipyin closed 5 years ago

kipyin commented 5 years ago

I've been scratching my head on this for about a month, and I still can't find a good design for the most basic Pokemon class.

On one hand, I want Pokemon to be dead simple to use. One should expect to do this without any worry:

>>> bulbasaur = Pokemon('bulbasaur', level=5)

and everything about a Bulbasaur will be created, such as its IVs, stats, ability, nature, gender, etc. But the price of this convenience is binding the database schema to Pokemon.__init__().

This brings me to my next point, although I've said it before (in #1): I want to have Pokemon separated from veekun's pokedex project. pokedex is a great thing, and I can't imagine having a better one. But it has some critical issues, such as the Pokémon's base experience (i.e. the experience some Pokémon gains upon defeating a Pokémon) and items' costs are only valid for Gen. VII. Also, decoupling the class with the database gives the class more flexibility. What if someone wants to use pokemaster to make their own Pokémon game? Having the class coupled to a fixed database is definitely not a good design.

The attrs team suggests using @classmethod as a helper function to instantiate the class. But if we do so, the convenience will be sacrificed. Doing something like Pokemon.new() is truly cumbersome.

Also, I don't think it is possible to have a Pokemon class that is completely separated from a database. The evolution data has to come from somewhere. Pokémon's nature, ability, moves, are tightly related to the exact game version. Pokemon has different attributes for different games. All of these should be considered when we are trying to come up with some kind of "blank" or fit-all Pokemon design. From this point of view, I think having the class coupled with a database is inevitable. But I'm still open for other possibilities.

kipyin commented 5 years ago

Decoupling the class from the db ain't happening.