mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Merge pull request #65 from encukou/xd-tutor
Add the VersionGroupPokemonMoveMethod table
This commit is contained in:
commit
0e766d309c
3 changed files with 112 additions and 0 deletions
54
pokedex/data/csv/version_group_pokemon_move_methods.csv
Normal file
54
pokedex/data/csv/version_group_pokemon_move_methods.csv
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
version_group_id,pokemon_move_method_id
|
||||||
|
1,1
|
||||||
|
1,4
|
||||||
|
1,5
|
||||||
|
2,1
|
||||||
|
2,4
|
||||||
|
2,5
|
||||||
|
3,1
|
||||||
|
3,2
|
||||||
|
3,4
|
||||||
|
4,1
|
||||||
|
4,2
|
||||||
|
4,3
|
||||||
|
4,4
|
||||||
|
5,1
|
||||||
|
5,2
|
||||||
|
5,4
|
||||||
|
5,6
|
||||||
|
6,1
|
||||||
|
6,2
|
||||||
|
6,3
|
||||||
|
6,4
|
||||||
|
6,6
|
||||||
|
7,1
|
||||||
|
7,2
|
||||||
|
7,3
|
||||||
|
7,4
|
||||||
|
7,6
|
||||||
|
8,1
|
||||||
|
8,2
|
||||||
|
8,3
|
||||||
|
8,4
|
||||||
|
8,6
|
||||||
|
9,1
|
||||||
|
9,2
|
||||||
|
9,3
|
||||||
|
9,4
|
||||||
|
9,6
|
||||||
|
9,10
|
||||||
|
10,1
|
||||||
|
10,2
|
||||||
|
10,3
|
||||||
|
10,4
|
||||||
|
10,6
|
||||||
|
10,10
|
||||||
|
11,1
|
||||||
|
11,2
|
||||||
|
11,3
|
||||||
|
11,4
|
||||||
|
11,6
|
||||||
|
11,10
|
||||||
|
12,1
|
||||||
|
13,1
|
||||||
|
13,3
|
|
|
@ -1596,6 +1596,18 @@ class VersionGroup(TableBase):
|
||||||
order = Column(Integer, nullable=True,
|
order = Column(Integer, nullable=True,
|
||||||
info=dict(description=u"Order for sorting. Almost by date of release, except similar versions are grouped together."))
|
info=dict(description=u"Order for sorting. Almost by date of release, except similar versions are grouped together."))
|
||||||
|
|
||||||
|
class VersionGroupPokemonMoveMethod(TableBase):
|
||||||
|
u"""Maps a version group to a move learn methods it supports.
|
||||||
|
|
||||||
|
"Supporting" means simply that the method appears in the game.
|
||||||
|
For example, Breeding didn't exist in Gen.I, so it's not in this table.
|
||||||
|
"""
|
||||||
|
__tablename__ = 'version_group_pokemon_move_methods'
|
||||||
|
version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False,
|
||||||
|
info=dict(description=u"The ID of the version group."))
|
||||||
|
pokemon_move_method_id = Column(Integer, ForeignKey('pokemon_move_methods.id'), primary_key=True, nullable=False,
|
||||||
|
info=dict(description=u"The ID of the move method."))
|
||||||
|
|
||||||
class VersionGroupRegion(TableBase):
|
class VersionGroupRegion(TableBase):
|
||||||
u"""Maps a version group to a region that appears in it."""
|
u"""Maps a version group to a region that appears in it."""
|
||||||
__tablename__ = 'version_group_regions'
|
__tablename__ = 'version_group_regions'
|
||||||
|
@ -2115,3 +2127,14 @@ VersionGroup.generation = relationship(Generation,
|
||||||
VersionGroup.version_group_regions = relationship(VersionGroupRegion,
|
VersionGroup.version_group_regions = relationship(VersionGroupRegion,
|
||||||
backref='version_group')
|
backref='version_group')
|
||||||
VersionGroup.regions = association_proxy('version_group_regions', 'region')
|
VersionGroup.regions = association_proxy('version_group_regions', 'region')
|
||||||
|
VersionGroup.pokemon_move_methods = relationship(PokemonMoveMethod,
|
||||||
|
secondary=VersionGroupPokemonMoveMethod.__table__,
|
||||||
|
primaryjoin=and_(VersionGroup.id == VersionGroupPokemonMoveMethod.version_group_id),
|
||||||
|
secondaryjoin=and_(PokemonMoveMethod.id == VersionGroupPokemonMoveMethod.pokemon_move_method_id),
|
||||||
|
backref="version_groups")
|
||||||
|
|
||||||
|
|
||||||
|
VersionGroupPokemonMoveMethod.version_group = relationship(VersionGroup,
|
||||||
|
backref='version_group_move_methods')
|
||||||
|
VersionGroupPokemonMoveMethod.pokemon_move_method = relationship(PokemonMoveMethod,
|
||||||
|
backref='version_group_move_methods')
|
||||||
|
|
35
scripts/version-group-pokemon-move-methods.py
Normal file
35
scripts/version-group-pokemon-move-methods.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# Encoding: UTF-8
|
||||||
|
"""Fill the version_group_pokemon_move_methods table
|
||||||
|
|
||||||
|
This is an unmaintained one-shot script, only included in the repo for reference.
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
from sqlalchemy.sql import exists, func
|
||||||
|
from sqlalchemy.orm import lazyload
|
||||||
|
from sqlalchemy import and_, or_, not_
|
||||||
|
|
||||||
|
from pokedex.db import connect, tables, load
|
||||||
|
|
||||||
|
session = connect()
|
||||||
|
|
||||||
|
session.query(tables.VersionGroupPokemonMoveMethod).delete()
|
||||||
|
|
||||||
|
q = session.query(tables.VersionGroup, tables.PokemonMoveMethod)
|
||||||
|
q = q.filter(exists().where(and_(
|
||||||
|
tables.PokemonMove.pokemon_move_method_id == tables.PokemonMoveMethod.id,
|
||||||
|
tables.PokemonMove.version_group_id == tables.VersionGroup.id)))
|
||||||
|
q = q.options(lazyload('*'))
|
||||||
|
for version_group, pokemon_move_method in q:
|
||||||
|
entry = tables.VersionGroupPokemonMoveMethod(
|
||||||
|
version_group=version_group,
|
||||||
|
pokemon_move_method=pokemon_move_method,
|
||||||
|
)
|
||||||
|
session.add(entry)
|
||||||
|
|
||||||
|
|
||||||
|
load.dump(session, tables=['version_group_pokemon_move_methods'])
|
||||||
|
print "Dumped to CSV, rolling back transaction"
|
||||||
|
session.rollback()
|
Loading…
Reference in a new issue