Merge pull request #65 from encukou/xd-tutor

Add the VersionGroupPokemonMoveMethod table
This commit is contained in:
Eevee 2012-02-23 19:42:31 -08:00
commit 0e766d309c
3 changed files with 112 additions and 0 deletions

View 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
1 version_group_id pokemon_move_method_id
2 1 1
3 1 4
4 1 5
5 2 1
6 2 4
7 2 5
8 3 1
9 3 2
10 3 4
11 4 1
12 4 2
13 4 3
14 4 4
15 5 1
16 5 2
17 5 4
18 5 6
19 6 1
20 6 2
21 6 3
22 6 4
23 6 6
24 7 1
25 7 2
26 7 3
27 7 4
28 7 6
29 8 1
30 8 2
31 8 3
32 8 4
33 8 6
34 9 1
35 9 2
36 9 3
37 9 4
38 9 6
39 9 10
40 10 1
41 10 2
42 10 3
43 10 4
44 10 6
45 10 10
46 11 1
47 11 2
48 11 3
49 11 4
50 11 6
51 11 10
52 12 1
53 13 1
54 13 3

View file

@ -1596,6 +1596,18 @@ class VersionGroup(TableBase):
order = Column(Integer, nullable=True,
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):
u"""Maps a version group to a region that appears in it."""
__tablename__ = 'version_group_regions'
@ -2115,3 +2127,14 @@ VersionGroup.generation = relationship(Generation,
VersionGroup.version_group_regions = relationship(VersionGroupRegion,
backref='version_group')
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')

View 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()