Added move categories. #41
[zzz-pokedex.git] / pokedex / db / tables.py
1 # encoding: utf8
2
3 from sqlalchemy import Column, ForeignKey, MetaData, Table
4 from sqlalchemy.ext.declarative import declarative_base
5 from sqlalchemy.ext.associationproxy import association_proxy
6 from sqlalchemy.orm import backref, relation
7 from sqlalchemy.types import *
8 from sqlalchemy.databases.mysql import *
9
10 from pokedex.db import rst
11
12 metadata = MetaData()
13 TableBase = declarative_base(metadata=metadata)
14
15 class Ability(TableBase):
16 __tablename__ = 'abilities'
17 __singlename__ = 'ability'
18 id = Column(Integer, primary_key=True, nullable=False)
19 name = Column(Unicode(24), nullable=False)
20 flavor_text = Column(Unicode(64), nullable=False)
21 effect = Column(Unicode(255), nullable=False)
22
23 class ContestCombo(TableBase):
24 __tablename__ = 'contest_combos'
25 first_move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
26 second_move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
27
28 class ContestEffect(TableBase):
29 __tablename__ = 'contest_effects'
30 id = Column(Integer, primary_key=True, nullable=False)
31 appeal = Column(SmallInteger, nullable=False)
32 jam = Column(SmallInteger, nullable=False)
33 flavor_text = Column(Unicode(64), nullable=False)
34 effect = Column(Unicode(255), nullable=False)
35
36 class EggGroup(TableBase):
37 __tablename__ = 'egg_groups'
38 id = Column(Integer, primary_key=True, nullable=False)
39 name = Column(Unicode(16), nullable=False)
40
41 class Encounter(TableBase):
42 """Rows in this table represent encounters with wild Pokémon.
43
44 Within a given area in a given game, encounters are differentiated by the
45 slot they are in and a world condition.
46
47 Groups of slots belong to encounter types; these are what the player is
48 doing to get an encounter, such as surfing or walking through tall grass.
49
50 Within an encounter type, slots are defined primarily by rarity. Each slot
51 can also be affected by a world condition; for example, the 20% slot for
52 walking in tall grass is affected by whether a swarm is in effect in the
53 areas. "There is a swarm" and "there is not a swarm" are conditions, and
54 together they make a condition group. However, since "not a swarm" is a
55 base state rather than any sort of new state, it is omitted and instead
56 referred to by a NULL.
57
58 A slot (20% walking in grass) and single world condition (NULL, i.e. no
59 swarm) are thus enough to define a specific encounter.
60
61 Well, okay, almost: each slot actually appears twice.
62 """
63
64 __tablename__ = 'encounters'
65 id = Column(Integer, primary_key=True, nullable=False)
66 version_id = Column(Integer, ForeignKey('versions.id'), nullable=False, autoincrement=False)
67 location_area_id = Column(Integer, ForeignKey('location_areas.id'), nullable=False, autoincrement=False)
68 encounter_type_slot_id = Column(Integer, ForeignKey('encounter_type_slots.id'), nullable=False, autoincrement=False)
69 encounter_condition_id = Column(Integer, ForeignKey('encounter_conditions.id'), nullable=True, autoincrement=False)
70 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), nullable=False, autoincrement=False)
71 min_level = Column(Integer, nullable=False, autoincrement=False)
72 max_level = Column(Integer, nullable=False, autoincrement=False)
73
74 class EncounterCondition(TableBase):
75 """Rows in this table represent something different about the world that
76 can affect what Pokémon are encountered.
77 """
78
79 __tablename__ = 'encounter_conditions'
80 id = Column(Integer, primary_key=True, nullable=False)
81 encounter_condition_group_id = Column(Integer, ForeignKey('encounter_condition_groups.id'), primary_key=False, nullable=False, autoincrement=False)
82 name = Column(Unicode(64), nullable=False)
83
84 class EncounterConditionGroup(TableBase):
85 """Rows in this table represent a group of mutually exclusive conditions,
86 such as morning/day/night. "Conditions" that are part of the default state
87 of the world, such as "not during a swarm" or "not using the PokéRadar",
88 are not included in this table and are referred to by NULLs in other
89 tables.
90 """
91
92 __tablename__ = 'encounter_condition_groups'
93 id = Column(Integer, primary_key=True, nullable=False)
94 name = Column(Unicode(64), nullable=False)
95
96 class EncounterType(TableBase):
97 """Rows in this table represent ways the player can enter a wild encounter;
98 i.e. surfing, fishing, or walking through tall grass.
99 """
100
101 __tablename__ = 'encounter_types'
102 id = Column(Integer, primary_key=True, nullable=False)
103 name = Column(Unicode(64), nullable=False)
104
105 class EncounterTypeSlot(TableBase):
106 """Rows in this table represent an abstract "slot" within an encounter
107 type, associated with both a condition group and a rarity.
108
109 Note that there are two encounters per slot, so the rarities will only add
110 up to 50.
111 """
112
113 __tablename__ = 'encounter_type_slots'
114 id = Column(Integer, primary_key=True, nullable=False)
115 encounter_type_id = Column(Integer, ForeignKey('encounter_types.id'), primary_key=False, nullable=False, autoincrement=False)
116 encounter_condition_group_id = Column(Integer, ForeignKey('encounter_condition_groups.id'), primary_key=False, nullable=True, autoincrement=False)
117 rarity = Column(Integer, nullable=False, autoincrement=False)
118
119 class EvolutionChain(TableBase):
120 __tablename__ = 'evolution_chains'
121 id = Column(Integer, primary_key=True, nullable=False)
122 growth_rate_id = Column(Integer, ForeignKey('growth_rates.id'), nullable=False)
123 steps_to_hatch = Column(Integer, nullable=False)
124 baby_trigger_item = Column(Unicode(12))
125
126 class EvolutionMethod(TableBase):
127 __tablename__ = 'evolution_methods'
128 id = Column(Integer, primary_key=True, nullable=False)
129 name = Column(Unicode(64), nullable=False)
130 description = Column(Unicode(255), nullable=False)
131
132 class Generation(TableBase):
133 __tablename__ = 'generations'
134 id = Column(Integer, primary_key=True, nullable=False)
135 name = Column(Unicode(16), nullable=False)
136 main_region = Column(Unicode(16), nullable=False)
137
138 class GrowthRate(TableBase):
139 """`formula` is written in LaTeX math notation."""
140 __tablename__ = 'growth_rates'
141 id = Column(Integer, primary_key=True, nullable=False)
142 name = Column(Unicode(20), nullable=False)
143 formula = Column(Unicode(500), nullable=False)
144
145 class Item(TableBase):
146 __tablename__ = 'items'
147 __singlename__ = 'item'
148 id = Column(Integer, primary_key=True, nullable=False)
149 name = Column(Unicode(16), nullable=False)
150
151 class Language(TableBase):
152 __tablename__ = 'languages'
153 id = Column(Integer, primary_key=True, nullable=False)
154 name = Column(Unicode(16), nullable=False)
155
156 class Location(TableBase):
157 __tablename__ = 'locations'
158 __singlename__ = 'location'
159 id = Column(Integer, primary_key=True, nullable=False)
160 generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
161 name = Column(Unicode(64), nullable=False)
162
163 class LocationArea(TableBase):
164 __tablename__ = 'location_areas'
165 id = Column(Integer, primary_key=True, nullable=False)
166 location_id = Column(Integer, ForeignKey('locations.id'), nullable=False)
167 internal_id = Column(Integer, nullable=False)
168 name = Column(Unicode(64), nullable=True)
169
170 class LocationAreaEncounterRate(TableBase):
171 __tablename__ = 'location_area_encounter_rates'
172 location_area_id = Column(Integer, ForeignKey('location_areas.id'), primary_key=True, nullable=False, autoincrement=False)
173 encounter_type_id = Column(Integer, ForeignKey('encounter_types.id'), primary_key=True, nullable=False, autoincrement=False)
174 rate = Column(Integer, nullable=True)
175
176 class Machine(TableBase):
177 __tablename__ = 'machines'
178 machine_number = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
179 version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False)
180 move_id = Column(Integer, ForeignKey('moves.id'), nullable=False)
181
182 class MoveEffectCategory(TableBase):
183 __tablename__ = 'move_effect_categories'
184 id = Column(Integer, primary_key=True, nullable=False)
185 name = Column(Unicode(64), nullable=False)
186 can_affect_user = Column(Boolean, nullable=False)
187
188 class MoveEffectCategoryMap(TableBase):
189 __tablename__ = 'move_effect_category_map'
190 move_effect_id = Column(Integer, ForeignKey('move_effects.id'), primary_key=True, nullable=False)
191 move_effect_category_id = Column(Integer, ForeignKey('move_effect_categories.id'), primary_key=True, nullable=False)
192 affects_user = Column(Boolean, primary_key=True, nullable=False)
193
194 class MoveDamageClass(TableBase):
195 __tablename__ = 'move_damage_classes'
196 id = Column(Integer, primary_key=True, nullable=False)
197 name = Column(Unicode(8), nullable=False)
198 description = Column(Unicode(64), nullable=False)
199
200 class MoveEffect(TableBase):
201 __tablename__ = 'move_effects'
202 id = Column(Integer, primary_key=True, nullable=False)
203 priority = Column(SmallInteger, nullable=False)
204 short_effect = Column(Unicode(256), nullable=False)
205 effect = Column(Unicode(5120), nullable=False)
206
207 class MoveFlag(TableBase):
208 __tablename__ = 'move_flags'
209 move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
210 move_flag_type_id = Column(Integer, ForeignKey('move_flag_types.id'), primary_key=True, nullable=False, autoincrement=False)
211
212 class MoveFlagType(TableBase):
213 __tablename__ = 'move_flag_types'
214 id = Column(Integer, primary_key=True, nullable=False)
215 name = Column(Unicode(32), nullable=False)
216 description = Column(rst.RstTextColumn(128), nullable=False)
217
218 class MoveFlavorText(TableBase):
219 __tablename__ = 'move_flavor_text'
220 move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
221 generation_id = Column(Integer, ForeignKey('generations.id'), primary_key=True, nullable=False, autoincrement=False)
222 flavor_text = Column(Unicode(255), nullable=False)
223
224 class MoveName(TableBase):
225 __tablename__ = 'move_names'
226 move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
227 language_id = Column(Integer, ForeignKey('languages.id'), primary_key=True, nullable=False, autoincrement=False)
228 name = Column(Unicode(16), nullable=False)
229
230 class MoveTarget(TableBase):
231 __tablename__ = 'move_targets'
232 id = Column(Integer, primary_key=True, nullable=False)
233 name = Column(Unicode(32), nullable=False)
234 description = Column(Unicode(128), nullable=False)
235
236 class Move(TableBase):
237 __tablename__ = 'moves'
238 __singlename__ = 'move'
239 id = Column(Integer, primary_key=True, nullable=False)
240 name = Column(Unicode(12), nullable=False)
241 generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
242 type_id = Column(Integer, ForeignKey('types.id'), nullable=False)
243 power = Column(SmallInteger)
244 pp = Column(SmallInteger, nullable=False)
245 accuracy = Column(SmallInteger)
246 target_id = Column(Integer, ForeignKey('move_targets.id'), nullable=False)
247 damage_class_id = Column(Integer, ForeignKey('move_damage_classes.id'), nullable=False)
248 effect_id = Column(Integer, ForeignKey('move_effects.id'), nullable=False)
249 effect_chance = Column(Integer)
250 contest_type = Column(Unicode(8), nullable=False)
251 contest_effect_id = Column(Integer, ForeignKey('contest_effects.id'), nullable=True)
252 super_contest_effect_id = Column(Integer, ForeignKey('super_contest_effects.id'), nullable=False)
253
254 class Pokemon(TableBase):
255 """The core to this whole mess.
256
257 Note that I use both 'forme' and 'form' in both code and the database. I
258 only use 'forme' when specifically referring to Pokémon that have multiple
259 distinct species as forms—i.e., different stats or movesets. 'Form' is a
260 more general term referring to any variation within a species, including
261 purely cosmetic forms like Unown.
262 """
263 __tablename__ = 'pokemon'
264 __singlename__ = 'pokemon'
265 id = Column(Integer, primary_key=True, nullable=False)
266 name = Column(Unicode(20), nullable=False)
267 forme_name = Column(Unicode(16))
268 forme_base_pokemon_id = Column(Integer, ForeignKey('pokemon.id'))
269 generation_id = Column(Integer, ForeignKey('generations.id'))
270 evolution_chain_id = Column(Integer, ForeignKey('evolution_chains.id'))
271 evolution_parent_pokemon_id = Column(Integer, ForeignKey('pokemon.id'))
272 evolution_method_id = Column(Integer, ForeignKey('evolution_methods.id'))
273 evolution_parameter = Column(Unicode(32))
274 height = Column(Integer, nullable=False)
275 weight = Column(Integer, nullable=False)
276 species = Column(Unicode(16), nullable=False)
277 color = Column(Unicode(6), nullable=False)
278 pokemon_shape_id = Column(Integer, ForeignKey('pokemon_shapes.id'), nullable=False)
279 habitat = Column(Unicode(16), nullable=False)
280 gender_rate = Column(Integer, nullable=False)
281 capture_rate = Column(Integer, nullable=False)
282 base_experience = Column(Integer, nullable=False)
283 base_happiness = Column(Integer, nullable=False)
284 gen1_internal_id = Column(Integer)
285 is_baby = Column(Boolean, nullable=False)
286 has_gen4_fem_sprite = Column(Boolean, nullable=False)
287 has_gen4_fem_back_sprite = Column(Boolean, nullable=False)
288
289 ### Stuff to handle alternate Pokémon forms
290
291 @property
292 def national_id(self):
293 """Returns the National Pokédex number for this Pokémon. Use this
294 instead of the id directly; alternate formes may make the id incorrect.
295 """
296
297 if self.forme_base_pokemon_id:
298 return self.forme_base_pokemon_id
299 return self.id
300
301 @property
302 def full_name(self):
303 """Returns the name of this Pokémon, including its Forme, if any."""
304
305 if self.forme_name:
306 return "%s %s" % (self.forme_name.capitalize(), self.name)
307 return self.name
308
309 @property
310 def normal_form(self):
311 """Returns the normal form for this Pokémon; i.e., this will return
312 regular Deoxys when called on any Deoxys form.
313 """
314
315 if self.forme_base_pokemon:
316 return self.forme_base_pokemon
317
318 return self
319
320 class PokemonAbility(TableBase):
321 __tablename__ = 'pokemon_abilities'
322 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
323 ability_id = Column(Integer, ForeignKey('abilities.id'), nullable=False)
324 slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
325
326 class PokemonDexNumber(TableBase):
327 __tablename__ = 'pokemon_dex_numbers'
328 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
329 generation_id = Column(Integer, ForeignKey('generations.id'), primary_key=True, nullable=False, autoincrement=False)
330 pokedex_number = Column(Integer, nullable=False)
331
332 class PokemonEggGroup(TableBase):
333 __tablename__ = 'pokemon_egg_groups'
334 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
335 egg_group_id = Column(Integer, ForeignKey('egg_groups.id'), primary_key=True, nullable=False, autoincrement=False)
336
337 class PokemonFlavorText(TableBase):
338 __tablename__ = 'pokemon_flavor_text'
339 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
340 version_id = Column(Integer, ForeignKey('versions.id'), primary_key=True, nullable=False, autoincrement=False)
341 flavor_text = Column(Unicode(255), nullable=False)
342
343 class PokemonFormGroup(TableBase):
344 __tablename__ = 'pokemon_form_groups'
345 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
346 description = Column(Unicode(512), nullable=False)
347
348 class PokemonFormSprite(TableBase):
349 __tablename__ = 'pokemon_form_sprites'
350 id = Column(Integer, primary_key=True, nullable=False)
351 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
352 introduced_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False)
353 name = Column(Unicode(16), nullable=True)
354
355 class PokemonItem(TableBase):
356 __tablename__ = 'pokemon_items'
357 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
358 version_id = Column(Integer, ForeignKey('versions.id'), primary_key=True, nullable=False, autoincrement=False)
359 item_id = Column(Integer, ForeignKey('items.id'), primary_key=True, nullable=False, autoincrement=False)
360 rarity = Column(Integer, nullable=False)
361
362 class PokemonMove(TableBase):
363 __tablename__ = 'pokemon_moves'
364 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
365 version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False)
366 move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False, index=True)
367 pokemon_move_method_id = Column(Integer, ForeignKey('pokemon_move_methods.id'), primary_key=True, nullable=False, autoincrement=False)
368 level = Column(Integer, primary_key=True, nullable=True, autoincrement=False)
369 order = Column(Integer, nullable=True)
370
371 class PokemonMoveMethod(TableBase):
372 __tablename__ = 'pokemon_move_methods'
373 id = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
374 name = Column(Unicode(64), nullable=False)
375 description = Column(Unicode(255), nullable=False)
376
377 class PokemonName(TableBase):
378 __tablename__ = 'pokemon_names'
379 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
380 language_id = Column(Integer, ForeignKey('languages.id'), primary_key=True, nullable=False, autoincrement=False)
381 name = Column(Unicode(16), nullable=False)
382
383 class PokemonShape(TableBase):
384 __tablename__ = 'pokemon_shapes'
385 id = Column(Integer, primary_key=True, nullable=False)
386 name = Column(Unicode(24), nullable=False)
387 awesome_name = Column(Unicode(16), nullable=False)
388
389 class PokemonStat(TableBase):
390 __tablename__ = 'pokemon_stats'
391 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
392 stat_id = Column(Integer, ForeignKey('stats.id'), primary_key=True, nullable=False, autoincrement=False)
393 base_stat = Column(Integer, nullable=False)
394 effort = Column(Integer, nullable=False)
395
396 class PokemonType(TableBase):
397 __tablename__ = 'pokemon_types'
398 pokemon_id = Column(Integer, ForeignKey('pokemon.id'), primary_key=True, nullable=False, autoincrement=False)
399 type_id = Column(Integer, ForeignKey('types.id'), nullable=False)
400 slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
401
402 class Stat(TableBase):
403 __tablename__ = 'stats'
404 id = Column(Integer, primary_key=True, nullable=False)
405 name = Column(Unicode(16), nullable=False)
406
407 class SuperContestCombo(TableBase):
408 __tablename__ = 'super_contest_combos'
409 first_move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
410 second_move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
411
412 class SuperContestEffect(TableBase):
413 __tablename__ = 'super_contest_effects'
414 id = Column(Integer, primary_key=True, nullable=False)
415 appeal = Column(SmallInteger, nullable=False)
416 flavor_text = Column(Unicode(64), nullable=False)
417
418 class TypeEfficacy(TableBase):
419 __tablename__ = 'type_efficacy'
420 damage_type_id = Column(Integer, ForeignKey('types.id'), primary_key=True, nullable=False, autoincrement=False)
421 target_type_id = Column(Integer, ForeignKey('types.id'), primary_key=True, nullable=False, autoincrement=False)
422 damage_factor = Column(Integer, nullable=False)
423
424 class Type(TableBase):
425 __tablename__ = 'types'
426 __singlename__ = 'type'
427 id = Column(Integer, primary_key=True, nullable=False)
428 name = Column(Unicode(8), nullable=False)
429 abbreviation = Column(Unicode(3), nullable=False)
430
431 class VersionGroup(TableBase):
432 __tablename__ = 'version_groups'
433 id = Column(Integer, primary_key=True, nullable=False)
434 generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
435
436 class Version(TableBase):
437 __tablename__ = 'versions'
438 id = Column(Integer, primary_key=True, nullable=False)
439 version_group_id = Column(Integer, ForeignKey('version_groups.id'), nullable=False)
440 name = Column(Unicode(32), nullable=False)
441
442
443 ### Relations down here, to avoid ordering problems
444 ContestCombo.first = relation(Move, primaryjoin=ContestCombo.first_move_id==Move.id,
445 backref='contest_combo_first')
446 ContestCombo.second = relation(Move, primaryjoin=ContestCombo.second_move_id==Move.id,
447 backref='contest_combo_second')
448
449 Encounter.pokemon = relation(Pokemon, backref='encounters')
450 Encounter.version = relation(Version, backref='encounters')
451 Encounter.location_area = relation(LocationArea, backref='encounters')
452 Encounter.slot = relation(EncounterTypeSlot, backref='encounters')
453 Encounter.condition = relation(EncounterCondition, backref='encounters')
454
455 EncounterCondition.group = relation(EncounterConditionGroup,
456 backref='conditions')
457
458 EncounterTypeSlot.type = relation(EncounterType, backref='slots')
459
460 EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains')
461
462 Generation.versions = relation(Version, secondary=VersionGroup.__table__)
463
464 LocationArea.location = relation(Location, backref='areas')
465
466 Machine.version_group = relation(VersionGroup)
467
468 Move.contest_effect = relation(ContestEffect, backref='moves')
469 Move.contest_combo_next = association_proxy('contest_combo_first', 'second')
470 Move.contest_combo_prev = association_proxy('contest_combo_second', 'first')
471 Move.damage_class = relation(MoveDamageClass, backref='moves')
472 Move.flags = association_proxy('move_flags', 'flag')
473 Move.flavor_text = relation(MoveFlavorText, order_by=MoveFlavorText.generation_id, backref='move')
474 Move.foreign_names = relation(MoveName, backref='pokemon')
475 Move.generation = relation(Generation, backref='moves')
476 Move.machines = relation(Machine, backref='move')
477 Move.move_effect = relation(MoveEffect, backref='moves')
478 Move.move_flags = relation(MoveFlag, backref='move')
479 Move.super_contest_effect = relation(SuperContestEffect, backref='moves')
480 Move.super_contest_combo_next = association_proxy('super_contest_combo_first', 'second')
481 Move.super_contest_combo_prev = association_proxy('super_contest_combo_second', 'first')
482 Move.target = relation(MoveTarget, backref='moves')
483 Move.type = relation(Type, backref='moves')
484
485 Move.effect = rst.MoveEffectProperty('effect')
486 Move.priority = association_proxy('move_effect', 'priority')
487 Move.short_effect = rst.MoveEffectProperty('short_effect')
488
489 MoveEffect.category_map = relation(MoveEffectCategoryMap)
490 MoveEffect.categories = association_proxy('category_map', 'category')
491 MoveEffectCategoryMap.category = relation(MoveEffectCategory)
492
493 MoveFlag.flag = relation(MoveFlagType)
494
495 MoveFlavorText.generation = relation(Generation)
496
497 MoveName.language = relation(Language)
498
499 Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
500 order_by=PokemonAbility.slot,
501 backref='pokemon')
502 Pokemon.formes = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.forme_base_pokemon_id,
503 backref=backref('forme_base_pokemon',
504 remote_side=[Pokemon.id]))
505 Pokemon.dex_numbers = relation(PokemonDexNumber, backref='pokemon')
506 Pokemon.egg_groups = relation(EggGroup, secondary=PokemonEggGroup.__table__,
507 order_by=PokemonEggGroup.egg_group_id,
508 backref='pokemon')
509 Pokemon.evolution_chain = relation(EvolutionChain, backref='pokemon')
510 Pokemon.evolution_method = relation(EvolutionMethod)
511 Pokemon.evolution_children = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.evolution_parent_pokemon_id,
512 backref=backref('evolution_parent',
513 remote_side=[Pokemon.id]))
514 Pokemon.flavor_text = relation(PokemonFlavorText, order_by=PokemonFlavorText.pokemon_id, backref='pokemon')
515 Pokemon.foreign_names = relation(PokemonName, backref='pokemon')
516 Pokemon.items = relation(PokemonItem)
517 Pokemon.generation = relation(Generation, backref='pokemon')
518 Pokemon.shape = relation(PokemonShape, backref='pokemon')
519 Pokemon.stats = relation(PokemonStat, backref='pokemon')
520 Pokemon.types = relation(Type, secondary=PokemonType.__table__)
521
522 PokemonDexNumber.generation = relation(Generation)
523
524 PokemonFlavorText.version = relation(Version)
525
526 PokemonItem.item = relation(Item, backref='pokemon')
527 PokemonItem.version = relation(Version)
528
529 PokemonFormGroup.pokemon = relation(Pokemon, backref=backref('form_group',
530 uselist=False))
531 PokemonFormSprite.pokemon = relation(Pokemon, backref='form_sprites')
532 PokemonFormSprite.introduced_in = relation(VersionGroup)
533
534 PokemonMove.pokemon = relation(Pokemon, backref='pokemon_moves')
535 PokemonMove.version_group = relation(VersionGroup)
536 PokemonMove.move = relation(Move, backref='pokemon_moves')
537 PokemonMove.method = relation(PokemonMoveMethod)
538
539 PokemonName.language = relation(Language)
540
541 PokemonStat.stat = relation(Stat)
542
543 SuperContestCombo.first = relation(Move, primaryjoin=SuperContestCombo.first_move_id==Move.id,
544 backref='super_contest_combo_first')
545 SuperContestCombo.second = relation(Move, primaryjoin=SuperContestCombo.second_move_id==Move.id,
546 backref='super_contest_combo_second')
547
548 Type.damage_efficacies = relation(TypeEfficacy,
549 primaryjoin=Type.id
550 ==TypeEfficacy.damage_type_id,
551 backref='damage_type')
552 Type.target_efficacies = relation(TypeEfficacy,
553 primaryjoin=Type.id
554 ==TypeEfficacy.target_type_id,
555 backref='target_type')
556
557 Version.version_group = relation(VersionGroup, backref='versions')
558 Version.generation = association_proxy('version_group', 'generation')
559
560 VersionGroup.generation = relation(Generation, backref='version_groups')