The game Ruby (version ID 7) is a Generation 3 game, and it belongs to the "version group" ruby-sapphire (version group ID 5). Currently, the only way to get the "version group" name and ID mapping is via tables such as pokedex.db.tables.VersionGroup or pokedex.db.tables.Version. But making a query every time we want to retrieve the data is unnecessarily costly. Thus, adding a GameVersion class will help getting the right version/version group ID at ease.
Usage Example
>>> from pokemaster.game_version import GameVersion
>>> GameVersion.EMERALD.generation
<Gen.THREE: 3>
>>> # What's the version group ID for Platinum?
>>> GameVersion.PLATINUM.version_group
<VersionGroup.PLATINUM: 9>
Implementation Suggestions
First, we need a Genenum and VersionGroupenum:
class Gen(enum.IntEnum):
ONE = 1
TWO = 2
THREE = 3
...
class VersionGroup(enum.IntEnum):
RED_BLUE = 1
YELLOW = 2
GOLD_SILVER = 3
...
Then, we can make a GameVersionenum that combines Gen and VersionGroup:
class GameVersion(enum.Enum):
RED = (1, 1, 1)
BLUE = (1, 1, 2)
YELLOW = (1, 2, 3)
...
def __init__(self, generation, version_group, version):
self.generation = Gen(generation)
self.version_group = VersionGroup(version_group)
self.version = version
Feature Description and Rationale
The game Ruby (version ID 7) is a Generation 3 game, and it belongs to the "version group" ruby-sapphire (version group ID 5). Currently, the only way to get the "version group" name and ID mapping is via tables such as
pokedex.db.tables.VersionGroup
orpokedex.db.tables.Version
. But making a query every time we want to retrieve the data is unnecessarily costly. Thus, adding aGameVersion
class will help getting the right version/version group ID at ease.Usage Example
Implementation Suggestions
First, we need a
Gen
enum
andVersionGroup
enum
:Then, we can make a
GameVersion
enum
that combinesGen
andVersionGroup
:And then we can do something like:
If we make the values of
GameVersion
tonamedtuple
, we can even have something more descriptive: