mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Made regions first-class objects.
This commit is contained in:
parent
e3c6cf7d10
commit
81eaf4a9ef
5 changed files with 141 additions and 100 deletions
|
@ -1,5 +1,5 @@
|
|||
id,name,main_region
|
||||
1,Generation I,Kanto
|
||||
2,Generation II,Johto
|
||||
3,Generation III,Hoenn
|
||||
4,Generation IV,Sinnoh
|
||||
id,main_region_id,name
|
||||
1,1,Generation I
|
||||
2,2,Generation II
|
||||
3,3,Generation III
|
||||
4,4,Generation IV
|
||||
|
|
|
|
@ -1,4 +1,4 @@
|
|||
id,generation_id,name
|
||||
id,region_id,name
|
||||
1,4,Canalave City
|
||||
2,4,Eterna City
|
||||
3,4,Pastoria City
|
||||
|
@ -62,95 +62,95 @@ id,generation_id,name
|
|||
62,4,Sea Route 223
|
||||
63,4,Sea Route 226
|
||||
64,4,Sea Route 230
|
||||
65,4,Blackthorn City
|
||||
66,4,Burned Tower
|
||||
67,4,Celadon City
|
||||
68,4,Cerulean City
|
||||
69,4,Cherrygrove City
|
||||
70,4,Cianwood City
|
||||
71,4,Cinnabar Island
|
||||
72,4,Dark Cave
|
||||
73,4,Diglett's Cave
|
||||
74,4,Dragon's Den
|
||||
75,4,Ecruteak City
|
||||
76,4,Fuchsia City
|
||||
77,4,Ice Cave
|
||||
78,4,Ilex Forest
|
||||
79,4,Lake of Rage
|
||||
80,4,Mt. Moon
|
||||
81,4,Mt. Mortar
|
||||
82,4,Mt. Silver
|
||||
83,4,National Park
|
||||
84,4,New Bark Town
|
||||
85,4,Olivine City
|
||||
86,4,Pallet Town
|
||||
87,4,Rock Tunnel
|
||||
88,4,Route 1
|
||||
89,4,Route 10
|
||||
90,4,Route 11
|
||||
91,4,Route 12
|
||||
92,4,Route 13
|
||||
93,4,Route 14
|
||||
94,4,Route 15
|
||||
95,4,Route 16
|
||||
96,4,Route 17
|
||||
97,4,Route 18
|
||||
98,4,Route 19
|
||||
99,4,Route 2
|
||||
100,4,Route 20
|
||||
101,4,Route 21
|
||||
102,4,Route 22
|
||||
103,4,Route 24
|
||||
104,4,Route 25
|
||||
105,4,Route 26
|
||||
106,4,Route 27
|
||||
107,4,Route 28
|
||||
108,4,Route 29
|
||||
109,4,Route 3
|
||||
110,4,Route 30
|
||||
111,4,Route 31
|
||||
112,4,Route 32
|
||||
113,4,Route 33
|
||||
114,4,Route 34
|
||||
115,4,Route 35
|
||||
116,4,Route 36
|
||||
117,4,Route 37
|
||||
118,4,Route 38
|
||||
119,4,Route 39
|
||||
120,4,Route 4
|
||||
121,4,Route 40
|
||||
122,4,Route 41
|
||||
123,4,Route 42
|
||||
124,4,Route 43
|
||||
125,4,Route 44
|
||||
126,4,Route 45
|
||||
127,4,Route 46
|
||||
128,4,Route 47
|
||||
129,4,Route 48
|
||||
130,4,Route 5
|
||||
131,4,Route 6
|
||||
132,4,Route 7
|
||||
133,4,Route 8
|
||||
134,4,Route 9
|
||||
135,4,Ruins of Alph
|
||||
136,4,Seafoam Islands
|
||||
137,4,Slowpoke Well
|
||||
138,4,Sprout Tower
|
||||
139,4,Tin Tower
|
||||
140,4,Tohjo Falls
|
||||
141,4,Union Cave
|
||||
142,4,Unknown 138
|
||||
143,4,Unknown 49
|
||||
144,4,Unknown 50
|
||||
145,4,Unknown 64
|
||||
146,4,Unknown 90
|
||||
147,4,Unknown Dungeon
|
||||
148,4,Unknown; all Poliwag
|
||||
149,4,Unknown; all Rattata
|
||||
150,4,Unknown; all bugs
|
||||
151,4,Vermilion City
|
||||
152,4,Victory Road
|
||||
153,4,Violet City
|
||||
154,4,Viridian City
|
||||
155,4,Viridian Forest
|
||||
156,4,Whirl Islands
|
||||
65,2,Blackthorn City
|
||||
66,2,Burned Tower
|
||||
67,1,Celadon City
|
||||
68,1,Cerulean City
|
||||
69,2,Cherrygrove City
|
||||
70,2,Cianwood City
|
||||
71,1,Cinnabar Island
|
||||
72,2,Dark Cave
|
||||
73,1,Diglett's Cave
|
||||
74,2,Dragon's Den
|
||||
75,2,Ecruteak City
|
||||
76,1,Fuchsia City
|
||||
77,2,Ice Cave
|
||||
78,2,Ilex Forest
|
||||
79,2,Lake of Rage
|
||||
80,1,Mt. Moon
|
||||
81,2,Mt. Mortar
|
||||
82,2,Mt. Silver
|
||||
83,2,National Park
|
||||
84,2,New Bark Town
|
||||
85,2,Olivine City
|
||||
86,1,Pallet Town
|
||||
87,1,Rock Tunnel
|
||||
88,1,Route 1
|
||||
89,1,Route 10
|
||||
90,1,Route 11
|
||||
91,1,Route 12
|
||||
92,1,Route 13
|
||||
93,1,Route 14
|
||||
94,1,Route 15
|
||||
95,1,Route 16
|
||||
96,1,Route 17
|
||||
97,1,Route 18
|
||||
98,1,Route 19
|
||||
99,1,Route 2
|
||||
100,1,Route 20
|
||||
101,1,Route 21
|
||||
102,1,Route 22
|
||||
103,1,Route 24
|
||||
104,1,Route 25
|
||||
105,1,Route 26
|
||||
106,1,Route 27
|
||||
107,1,Route 28
|
||||
108,2,Route 29
|
||||
109,1,Route 3
|
||||
110,2,Route 30
|
||||
111,2,Route 31
|
||||
112,2,Route 32
|
||||
113,2,Route 33
|
||||
114,2,Route 34
|
||||
115,2,Route 35
|
||||
116,2,Route 36
|
||||
117,2,Route 37
|
||||
118,2,Route 38
|
||||
119,2,Route 39
|
||||
120,1,Route 4
|
||||
121,2,Route 40
|
||||
122,2,Route 41
|
||||
123,2,Route 42
|
||||
124,2,Route 43
|
||||
125,2,Route 44
|
||||
126,2,Route 45
|
||||
127,2,Route 46
|
||||
128,2,Route 47
|
||||
129,2,Route 48
|
||||
130,1,Route 5
|
||||
131,1,Route 6
|
||||
132,1,Route 7
|
||||
133,1,Route 8
|
||||
134,1,Route 9
|
||||
135,2,Ruins of Alph
|
||||
136,1,Seafoam Islands
|
||||
137,2,Slowpoke Well
|
||||
138,2,Sprout Tower
|
||||
139,2,Tin Tower
|
||||
140,2,Tohjo Falls
|
||||
141,2,Union Cave
|
||||
142,2,Unknown 138
|
||||
143,2,Unknown 49
|
||||
144,2,Unknown 50
|
||||
145,2,Unknown 64
|
||||
146,2,Unknown 90
|
||||
147,2,Unknown Dungeon
|
||||
148,2,Unknown; all Poliwag
|
||||
149,2,Unknown; all Rattata
|
||||
150,2,Unknown; all bugs
|
||||
151,1,Vermilion City
|
||||
152,1,Victory Road
|
||||
153,2,Violet City
|
||||
154,1,Viridian City
|
||||
155,1,Viridian Forest
|
||||
156,2,Whirl Islands
|
||||
|
|
|
5
pokedex/data/csv/regions.csv
Normal file
5
pokedex/data/csv/regions.csv
Normal file
|
@ -0,0 +1,5 @@
|
|||
id,name
|
||||
1,Kanto
|
||||
2,Johto
|
||||
3,Hoenn
|
||||
4,Sinnoh
|
|
14
pokedex/data/csv/version_group_regions.csv
Normal file
14
pokedex/data/csv/version_group_regions.csv
Normal file
|
@ -0,0 +1,14 @@
|
|||
version_group_id,region_id
|
||||
1,1
|
||||
2,1
|
||||
3,1
|
||||
3,2
|
||||
4,1
|
||||
4,2
|
||||
5,3
|
||||
6,3
|
||||
7,1
|
||||
8,4
|
||||
9,4
|
||||
10,1
|
||||
10,2
|
|
|
@ -144,8 +144,8 @@ class EvolutionMethod(TableBase):
|
|||
class Generation(TableBase):
|
||||
__tablename__ = 'generations'
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
main_region_id = Column(Integer, ForeignKey('regions.id'))
|
||||
name = Column(Unicode(16), nullable=False)
|
||||
main_region = Column(Unicode(16), nullable=False)
|
||||
|
||||
class GrowthRate(TableBase):
|
||||
"""`formula` is written in LaTeX math notation."""
|
||||
|
@ -170,7 +170,7 @@ class Location(TableBase):
|
|||
__tablename__ = 'locations'
|
||||
__singlename__ = 'location'
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
|
||||
region_id = Column(Integer, ForeignKey('regions.id'))
|
||||
name = Column(Unicode(64), nullable=False)
|
||||
|
||||
class LocationArea(TableBase):
|
||||
|
@ -412,6 +412,12 @@ class PokemonType(TableBase):
|
|||
type_id = Column(Integer, ForeignKey('types.id'), nullable=False)
|
||||
slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
|
||||
|
||||
class Region(TableBase):
|
||||
"""Major areas of the world: Kanto, Johto, etc."""
|
||||
__tablename__ = 'regions'
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
name = Column(Unicode(16), nullable=False)
|
||||
|
||||
class Stat(TableBase):
|
||||
__tablename__ = 'stats'
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
|
@ -448,6 +454,11 @@ class VersionGroup(TableBase):
|
|||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
|
||||
|
||||
class VersionGroupRegion(TableBase):
|
||||
__tablename__ = 'version_group_regions'
|
||||
version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False)
|
||||
region_id = Column(Integer, ForeignKey('regions.id'), primary_key=True, nullable=False)
|
||||
|
||||
class Version(TableBase):
|
||||
__tablename__ = 'versions'
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
|
@ -483,6 +494,9 @@ EncounterSlotCondition.condition = relation(EncounterCondition,
|
|||
EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains')
|
||||
|
||||
Generation.versions = relation(Version, secondary=VersionGroup.__table__)
|
||||
Generation.main_region = relation(Region)
|
||||
|
||||
Location.region = relation(Region, backref='locations')
|
||||
|
||||
LocationArea.location = relation(Location, backref='areas')
|
||||
|
||||
|
@ -568,6 +582,12 @@ PokemonName.language = relation(Language)
|
|||
|
||||
PokemonStat.stat = relation(Stat)
|
||||
|
||||
# This is technically a has-many; Generation.main_region_id -> Region.id
|
||||
Region.generation = relation(Generation, uselist=False)
|
||||
Region.version_group_regions = relation(VersionGroupRegion, backref='region',
|
||||
order_by='VersionGroupRegion.version_group_id')
|
||||
Region.version_groups = association_proxy('version_group_regions', 'version_group')
|
||||
|
||||
SuperContestCombo.first = relation(Move, primaryjoin=SuperContestCombo.first_move_id==Move.id,
|
||||
backref='super_contest_combo_first')
|
||||
SuperContestCombo.second = relation(Move, primaryjoin=SuperContestCombo.second_move_id==Move.id,
|
||||
|
@ -589,3 +609,5 @@ Version.version_group = relation(VersionGroup, backref='versions')
|
|||
Version.generation = association_proxy('version_group', 'generation')
|
||||
|
||||
VersionGroup.generation = relation(Generation, backref='version_groups')
|
||||
VersionGroup.version_group_regions = relation(VersionGroupRegion, backref='version_group')
|
||||
VersionGroup.regions = association_proxy('version_group_regions', 'region')
|
||||
|
|
Loading…
Reference in a new issue