5 Columns have a info dictionary with these keys:
6 - description: The description of the column
7 - official: True if the values appear in games or official material; False if
8 they are fan-created or fan-written. This flag is currently only set for
10 - markup: The format of a text column. Can be one of:
11 - plaintext: Normal Unicode text (widely used in names)
12 - markdown: Veekun's Markdown flavor (generally used in effect descriptions)
13 - gametext: Transcription of in-game text that strives to be both
14 human-readable and represent the original text exactly.
15 - identifier: A fan-made identifier in the [-_a-z0-9]* format. Not intended
17 - latex: A formula in LaTeX syntax.
18 - foreign: If set, the column contains foreign (non-English) text.
21 # XXX: Check if "gametext" is set correctly everywhere
23 # XXX: Some columns paradoxically have official=True and markup='identifier'.
24 # This is when one column is used as both the English name (lowercased) and
25 # an identifier. This should be fixed.
27 from sqlalchemy
import Column
, ForeignKey
, MetaData
, PrimaryKeyConstraint
, Table
28 from sqlalchemy
.ext
.declarative
import declarative_base
29 from sqlalchemy
.ext
.associationproxy
import association_proxy
30 from sqlalchemy
.orm
import backref
, eagerload_all
, relation
31 from sqlalchemy
.orm
.session
import Session
32 from sqlalchemy
.sql
import and_
33 from sqlalchemy
.types
import *
35 from pokedex
.db
import markdown
38 TableBase
= declarative_base(metadata
=metadata
)
40 class Ability(TableBase
):
41 u
"""An ability a pokémon can have, such as Static or Pressure.
43 __tablename__
= 'abilities'
44 __singlename__
= 'ability'
45 id = Column(Integer
, primary_key
=True, nullable
=False,
46 info
=dict(description
="A numeric ID"))
47 name
= Column(Unicode(24), nullable
=False,
48 info
=dict(description
="The official English name of this ability", official
=True, format
='plaintext'))
49 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
50 info
=dict(description
="ID of the generation this ability was introduced in", detail
=True))
51 effect
= Column(markdown
.MarkdownColumn(5120), nullable
=False,
52 info
=dict(description
="Detailed description of this ability's effect", format
='markdown'))
53 short_effect
= Column(markdown
.MarkdownColumn(255), nullable
=False,
54 info
=dict(description
="Short summary of this ability's effect", format
='markdown'))
56 class AbilityFlavorText(TableBase
):
57 u
"""In-game flavor text of an ability
59 __tablename__
= 'ability_flavor_text'
60 ability_id
= Column(Integer
, ForeignKey('abilities.id'), primary_key
=True, nullable
=False, autoincrement
=False,
61 info
=dict(description
="A numeric ID"))
62 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
63 info
=dict(description
="The versions this flavor text is shown in"))
64 flavor_text
= Column(Unicode(64), nullable
=False,
65 info
=dict(description
="The actual flavor text", official
=True, format
='gametext'))
67 class AbilityName(TableBase
):
68 u
"""Non-English official name of an ability
70 __tablename__
= 'ability_names'
71 ability_id
= Column(Integer
, ForeignKey('abilities.id'), primary_key
=True, nullable
=False, autoincrement
=False,
72 info
=dict(description
="ID of the ability"))
73 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
74 info
=dict(description
="ID of the language"))
75 name
= Column(Unicode(16), nullable
=False,
76 info
=dict(description
="ID of the language", official
=True, foreign
=True, format
='plaintext'))
78 class Berry(TableBase
):
79 u
"""A Berry, consumable item that grows on trees
81 For data common to all Items, such as the name, see the corresponding Item entry.
83 __tablename__
= 'berries'
84 id = Column(Integer
, primary_key
=True, nullable
=False,
85 info
=dict(description
="A numeric ID"))
86 item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=False,
87 info
=dict(description
="ID of the Item this Berry corresponds to"))
88 firmness_id
= Column(Integer
, ForeignKey('berry_firmness.id'), nullable
=False,
89 info
=dict(description
="ID of this berry's firmness"))
90 natural_gift_power
= Column(Integer
, nullable
=True,
91 info
=dict(description
="Power of Natural Gift when that move is used with this Berry"))
92 natural_gift_type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=True,
93 info
=dict(description
="ID of the Type that Natural Gift will have when used with this Berry"))
94 size
= Column(Integer
, nullable
=False,
95 info
=dict(description
=u
"Size of this Berry, in millimeters"))
96 max_harvest
= Column(Integer
, nullable
=False,
97 info
=dict(description
="Maximum number of these berries that can grow on one tree"))
98 growth_time
= Column(Integer
, nullable
=False,
99 info
=dict(description
="Time it takes the tree to grow one stage, in hours. Multiply by four to get overall time."))
100 soil_dryness
= Column(Integer
, nullable
=False,
101 info
=dict(description
="The speed of soil drying the tree causes")) # XXX: What's this exactly? I'm not a good farmer
102 smoothness
= Column(Integer
, nullable
=False,
103 info
=dict(description
="Smoothness of this Berry, a culinary attribute. Higher is better."))
105 class BerryFirmness(TableBase
):
106 u
"""A Berry firmness, such as "hard" or "very soft".
108 __tablename__
= 'berry_firmness'
109 id = Column(Integer
, primary_key
=True, nullable
=False,
110 info
=dict(description
="A numeric ID"))
111 name
= Column(Unicode(10), nullable
=False,
112 info
=dict(description
="English name of the firmness level", official
=True, format
='plaintext'))
114 class BerryFlavor(TableBase
):
115 u
"""A Berry flavor level.
117 __tablename__
= 'berry_flavors'
118 berry_id
= Column(Integer
, ForeignKey('berries.id'), primary_key
=True, nullable
=False, autoincrement
=False,
119 info
=dict(description
="ID of the berry"))
120 contest_type_id
= Column(Integer
, ForeignKey('contest_types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
121 info
=dict(description
="ID of the flavor"))
122 flavor
= Column(Integer
, nullable
=False,
123 info
=dict(description
="Level of the flavor in the berry"))
125 class ContestCombo(TableBase
):
126 u
"""Combo of two moves in a Contest.
128 __tablename__
= 'contest_combos'
129 first_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
130 info
=dict(description
="ID of the first move in the combo"))
131 second_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
132 info
=dict(description
="ID of the second and final move in the combo"))
134 class ContestEffect(TableBase
):
135 u
"""Effect of a move when used in a Contest.
137 __tablename__
= 'contest_effects'
138 id = Column(Integer
, primary_key
=True, nullable
=False,
139 info
=dict(description
="A numeric ID"))
140 appeal
= Column(SmallInteger
, nullable
=False,
141 info
=dict(description
="The base number of hearts the user of this move gets"))
142 jam
= Column(SmallInteger
, nullable
=False,
143 info
=dict(description
="The base number of hearts the user's opponent loses"))
144 flavor_text
= Column(Unicode(64), nullable
=False,
145 info
=dict(description
="English in-game description of this effect", official
=True, format
='gametext'))
146 effect
= Column(Unicode(255), nullable
=False,
147 info
=dict(description
="Detailed description of the effect", format
='markdown'))
149 class ContestType(TableBase
):
150 u
"""A Contest type, such as "cool" or "smart". Also functions as Berry flavor and Pokéblock color.
152 __tablename__
= 'contest_types'
153 id = Column(Integer
, primary_key
=True, nullable
=False,
154 info
=dict(description
="A numeric ID"))
155 name
= Column(Unicode(6), nullable
=False,
156 info
=dict(description
="The English name of the Contest type", official
=True, format
='identifier'))
157 flavor
= Column(Unicode(6), nullable
=False,
158 info
=dict(description
="The English name of the corresponding Berry flavor", official
=True, format
='identifier'))
159 color
= Column(Unicode(6), nullable
=False,
160 info
=dict(description
=u
"The English name of the corresponding Pokéblock color", official
=True, format
='identifier'))
162 class EggGroup(TableBase
):
163 u
"""An Egg group. Usually, two Pokémon can breed if they share an Egg Group.
165 (exceptions are the Ditto and No Eggs groups)
167 __tablename__
= 'egg_groups'
168 id = Column(Integer
, primary_key
=True, nullable
=False,
169 info
=dict(description
="A numeric ID"))
170 name
= Column(Unicode(16), nullable
=False,
171 info
=dict(description
=u
'The English "official" name. One NPC in Stadium uses these names; they are pretty bad.', official
=True, format
='identifier'))
173 class Encounter(TableBase
):
174 u
"""Encounters with wild Pokémon.
178 Within a given area in a given game, encounters are differentiated by the
179 "slot" they are in and the state of the game world.
181 What the player is doing to get an encounter, such as surfing or walking
182 through tall grass, is called terrain. Each terrain has its own set of
185 Within a terrain, slots are defined primarily by rarity. Each slot can
186 also be affected by world conditions; for example, the 20% slot for walking
187 in tall grass is affected by whether a swarm is in effect in that area.
188 "Is there a swarm?" is a condition; "there is a swarm" and "there is not a
189 swarm" are the possible values of this condition.
191 A slot (20% walking in grass) and any appropriate world conditions (no
192 swarm) are thus enough to define a specific encounter.
194 Well, okay, almost: each slot actually appears twice.
197 __tablename__
= 'encounters'
198 id = Column(Integer
, primary_key
=True, nullable
=False,
199 info
=dict(description
="A numeric ID"))
200 version_id
= Column(Integer
, ForeignKey('versions.id'), nullable
=False, autoincrement
=False,
201 info
=dict(description
="The ID of the Version this applies to"))
202 location_area_id
= Column(Integer
, ForeignKey('location_areas.id'), nullable
=False, autoincrement
=False,
203 info
=dict(description
="The ID of the Location of this encounter"))
204 encounter_slot_id
= Column(Integer
, ForeignKey('encounter_slots.id'), nullable
=False, autoincrement
=False,
205 info
=dict(description
="The ID of the encounter slot, which determines terrain and rarity"))
206 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False, autoincrement
=False,
207 info
=dict(description
=u
"The ID of the encountered Pokémon"))
208 min_level
= Column(Integer
, nullable
=False, autoincrement
=False,
209 info
=dict(description
=u
"The minimum level of the encountered Pokémon"))
210 max_level
= Column(Integer
, nullable
=False, autoincrement
=False,
211 info
=dict(description
=u
"The maxmum level of the encountered Pokémon"))
213 class EncounterCondition(TableBase
):
214 u
"""A conditions in the game world that affects pokémon encounters, such as time of day.
217 __tablename__
= 'encounter_conditions'
218 id = Column(Integer
, primary_key
=True, nullable
=False,
219 info
=dict(description
="A numeric ID"))
220 name
= Column(Unicode(64), nullable
=False,
221 info
=dict(description
="An English name of the condition", format
='plaintext'))
223 class EncounterConditionValue(TableBase
):
224 u
"""A possible state for a condition; for example, the state of 'swarm' could be 'swarm' or 'no swarm'.
227 __tablename__
= 'encounter_condition_values'
228 id = Column(Integer
, primary_key
=True, nullable
=False,
229 info
=dict(description
="A numeric ID"))
230 encounter_condition_id
= Column(Integer
, ForeignKey('encounter_conditions.id'), primary_key
=False, nullable
=False, autoincrement
=False,
231 info
=dict(description
="The ID of the encounter condition this is a value of"))
232 name
= Column(Unicode(64), nullable
=False,
233 info
=dict(description
="An english name of this value", format
='plaintext'))
234 is_default
= Column(Boolean
, nullable
=False,
235 info
=dict(description
='Set if this value is "default" or "normal" in some sense'))
237 class EncounterConditionValueMap(TableBase
):
238 u
"""Maps encounters to the specific conditions under which they occur.
240 __tablename__
= 'encounter_condition_value_map'
241 encounter_id
= Column(Integer
, ForeignKey('encounters.id'), primary_key
=True, nullable
=False, autoincrement
=False,
242 info
=dict(description
="ID of the encounter"))
243 encounter_condition_value_id
= Column(Integer
, ForeignKey('encounter_condition_values.id'), primary_key
=True, nullable
=False, autoincrement
=False,
244 info
=dict(description
="ID of the encounter condition value"))
246 class EncounterTerrain(TableBase
):
247 u
"""A way the player can enter a wild encounter, e.g., surfing, fishing, or walking through tall grass.
250 __tablename__
= 'encounter_terrain'
251 id = Column(Integer
, primary_key
=True, nullable
=False,
252 info
=dict(description
="A numeric ID"))
253 name
= Column(Unicode(64), nullable
=False,
254 info
=dict(description
="An english name of this terrain", format
='plaintext'))
256 class EncounterSlot(TableBase
):
257 u
"""An abstract "slot" within a terrain, associated with both some set of conditions and a rarity.
259 Note that there are two encounters per slot, so the rarities will only add
263 __tablename__
= 'encounter_slots'
264 id = Column(Integer
, primary_key
=True, nullable
=False,
265 info
=dict(description
="A numeric ID"))
266 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False, autoincrement
=False,
267 info
=dict(description
="The ID of the Version group this slot is in"))
268 encounter_terrain_id
= Column(Integer
, ForeignKey('encounter_terrain.id'), primary_key
=False, nullable
=False, autoincrement
=False,
269 info
=dict(description
="The ID of the terrain"))
270 slot
= Column(Integer
, nullable
=True,
271 info
=dict(description
="The slot")) # XXX: What is this, exactly?
272 rarity
= Column(Integer
, nullable
=False,
273 info
=dict(description
="The chance of the encounter, in percent")) # XXX: It is in percent, right? I'm confused.
275 class EncounterSlotCondition(TableBase
):
276 u
"""A condition that affects an encounter slot.
278 __tablename__
= 'encounter_slot_conditions'
279 encounter_slot_id
= Column(Integer
, ForeignKey('encounter_slots.id'), primary_key
=True, nullable
=False, autoincrement
=False,
280 info
=dict(description
="The ID of the encounter slot"))
281 encounter_condition_id
= Column(Integer
, ForeignKey('encounter_conditions.id'), primary_key
=True, nullable
=False, autoincrement
=False,
282 info
=dict(description
="The ID of the encounter condition"))
284 class EvolutionChain(TableBase
):
285 u
"""A family of pokémon that are linked by evolution
287 __tablename__
= 'evolution_chains'
288 id = Column(Integer
, primary_key
=True, nullable
=False,
289 info
=dict(description
="A numeric ID"))
290 growth_rate_id
= Column(Integer
, ForeignKey('growth_rates.id'), nullable
=False,
291 info
=dict(description
="ID of the growth rate for this family"))
292 baby_trigger_item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=True,
293 info
=dict(description
="Item that a parent must hold while breeding to produce a baby"))
295 class EvolutionTrigger(TableBase
):
296 u
"""An evolution type, such as "level" or "trade".
298 __tablename__
= 'evolution_triggers'
299 id = Column(Integer
, primary_key
=True, nullable
=False,
300 info
=dict(description
="A numeric ID"))
301 identifier
= Column(Unicode(16), nullable
=False,
302 info
=dict(description
="An English identifier", format
='identifier'))
304 class Experience(TableBase
):
305 u
"""EXP needed for a certain level with a certain growth rate
307 __tablename__
= 'experience'
308 growth_rate_id
= Column(Integer
, ForeignKey('growth_rates.id'), primary_key
=True, nullable
=False,
309 info
=dict(description
="ID of the growth rate"))
310 level
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
311 info
=dict(description
="The level"))
312 experience
= Column(Integer
, nullable
=False,
313 info
=dict(description
="The number of EXP points needed to get to that level"))
315 class Generation(TableBase
):
316 u
"""A Generation of the pokémon franchise
318 __tablename__
= 'generations'
319 id = Column(Integer
, primary_key
=True, nullable
=False,
320 info
=dict(description
="A numeric ID"))
321 main_region_id
= Column(Integer
, ForeignKey('regions.id'),
322 info
=dict(description
="ID of the region this generation's main games take place in"))
323 canonical_pokedex_id
= Column(Integer
, ForeignKey('pokedexes.id'),
324 info
=dict(description
=u
"ID of the pokédex this generation's main games use by default"))
325 name
= Column(Unicode(16), nullable
=False,
326 info
=dict(description
=u
'An English name of this generation, such as "Generation IV"', format
='plaintext'))
328 class GrowthRate(TableBase
):
329 u
"""Growth rate of a pokémon, i.e. the EXP → level function.
331 __tablename__
= 'growth_rates'
332 id = Column(Integer
, primary_key
=True, nullable
=False,
333 info
=dict(description
="A numeric ID"))
334 name
= Column(Unicode(20), nullable
=False,
335 info
=dict(description
="A name for the", format
='identifier'))
336 formula
= Column(Unicode(500), nullable
=False,
337 info
=dict(description
="The formula", format
='latex'))
339 class Item(TableBase
):
340 u
"""An Item from the games, like "Poké Ball" or "Bicycle".
342 __tablename__
= 'items'
343 __singlename__
= 'item'
344 id = Column(Integer
, primary_key
=True, nullable
=False,
345 info
=dict(description
="A numeric ID"))
346 name
= Column(Unicode(20), nullable
=False,
347 info
=dict(description
="The English name of the item", official
=True, format
='plaintext'))
348 category_id
= Column(Integer
, ForeignKey('item_categories.id'), nullable
=False,
349 info
=dict(description
="ID of a category this item belongs to"))
350 cost
= Column(Integer
, nullable
=False,
351 info
=dict(description
=u
"Cost of the item when bought. Items sell for half this price."))
352 fling_power
= Column(Integer
, nullable
=True,
353 info
=dict(description
=u
"Power of the move Fling when used with this item."))
354 fling_effect_id
= Column(Integer
, ForeignKey('item_fling_effects.id'), nullable
=True,
355 info
=dict(description
=u
"ID of the fling-effect of the move Fling when used with this item. Note that these are different from move effects."))
356 effect
= Column(markdown
.MarkdownColumn(5120), nullable
=False,
357 info
=dict(description
=u
"Detailed English description of the item's effect.", format
='markdown'))
360 def appears_underground(self
):
361 u
"""True if the item appears underground, as specified by the appropriate flag
363 return any(flag
.identifier
== u
'underground' for flag
in self
.flags
)
365 class ItemCategory(TableBase
):
368 # XXX: This is fanon, right?
369 __tablename__
= 'item_categories'
370 id = Column(Integer
, primary_key
=True, nullable
=False,
371 info
=dict(description
="A numeric ID"))
372 pocket_id
= Column(Integer
, ForeignKey('item_pockets.id'), nullable
=False,
373 info
=dict(description
="ID of the pocket these items go to"))
374 name
= Column(Unicode(16), nullable
=False,
375 info
=dict(description
="English name of the category", format
='plaintext'))
377 class ItemFlag(TableBase
):
378 u
"""An item attribute such as "consumable" or "holdable".
380 __tablename__
= 'item_flags'
381 id = Column(Integer
, primary_key
=True, nullable
=False,
382 info
=dict(description
="A numeric ID"))
383 identifier
= Column(Unicode(24), nullable
=False,
384 info
=dict(description
="Identifier of the flag", format
='identifier'))
385 name
= Column(Unicode(64), nullable
=False,
386 info
=dict(description
="Short English description of the flag", format
='plaintext'))
388 class ItemFlagMap(TableBase
):
389 u
"""Maps an item flag to its item.
391 __tablename__
= 'item_flag_map'
392 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, autoincrement
=False, nullable
=False,
393 info
=dict(description
="The ID of the item"))
394 item_flag_id
= Column(Integer
, ForeignKey('item_flags.id'), primary_key
=True, autoincrement
=False, nullable
=False,
395 info
=dict(description
="The ID of the item flag"))
397 class ItemFlavorText(TableBase
):
398 u
"""An in-game description of an item
400 __tablename__
= 'item_flavor_text'
401 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, autoincrement
=False, nullable
=False,
402 info
=dict(description
="The ID of the item"))
403 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, autoincrement
=False, nullable
=False,
404 info
=dict(description
="ID of the version group that sports this text"))
405 flavor_text
= Column(Unicode(255), nullable
=False,
406 info
=dict(description
="The flavor text itself", official
=True, format
='gametext'))
408 class ItemFlingEffect(TableBase
):
409 u
"""An effect of the move Fling when used with a specific item
411 __tablename__
= 'item_fling_effects'
412 id = Column(Integer
, primary_key
=True, nullable
=False,
413 info
=dict(description
="A numeric ID"))
414 effect
= Column(Unicode(255), nullable
=False,
415 info
=dict(description
="English description of the effect", format
='plaintext'))
417 class ItemInternalID(TableBase
):
418 u
"""The internal ID number a game uses for an item
420 __tablename__
= 'item_internal_ids'
421 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, autoincrement
=False, nullable
=False,
422 info
=dict(description
="The database ID of the item"))
423 generation_id
= Column(Integer
, ForeignKey('generations.id'), primary_key
=True, autoincrement
=False, nullable
=False,
424 info
=dict(description
="ID of the generation of games"))
425 internal_id
= Column(Integer
, nullable
=False,
426 info
=dict(description
="Internal ID of the item in the generation"))
428 class ItemName(TableBase
):
429 u
"""A non-English name of an item
431 __tablename__
= 'item_names'
432 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, nullable
=False, autoincrement
=False,
433 info
=dict(description
="The ID of the item"))
434 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
435 info
=dict(description
="The ID of the language"))
436 name
= Column(Unicode(16), nullable
=False,
437 info
=dict(description
="The name of the item in this language", foreign
=True, format
='plaintext'))
439 class ItemPocket(TableBase
):
440 u
"""A pocket that categorizes items
442 __tablename__
= 'item_pockets'
443 id = Column(Integer
, primary_key
=True, nullable
=False,
444 info
=dict(description
="A numeric ID"))
445 identifier
= Column(Unicode(16), nullable
=False,
446 info
=dict(description
="An identifier of this pocket", format
='identifier'))
447 name
= Column(Unicode(16), nullable
=False,
448 info
=dict(description
="A numeric ID", format
='plaintext'))
450 class Language(TableBase
):
451 u
"""A language the Pokémon games have been transleted into; except English
453 __tablename__
= 'languages'
454 id = Column(Integer
, primary_key
=True, nullable
=False,
455 info
=dict(description
="A numeric ID"))
456 iso639
= Column(Unicode(2), nullable
=False,
457 info
=dict(description
="The two-letter code of the country where this language is spoken. Note that it is not unique."))
458 iso3166
= Column(Unicode(2), nullable
=False,
459 info
=dict(description
="The two-letter code of the language. Note that it is not unique."))
460 name
= Column(Unicode(16), nullable
=False,
461 info
=dict(description
="The English name of the language", format
='plaintext'))
463 class Location(TableBase
):
464 u
"""A place in the Pokémon world
466 __tablename__
= 'locations'
467 __singlename__
= 'location'
468 id = Column(Integer
, primary_key
=True, nullable
=False,
469 info
=dict(description
="A numeric ID"))
470 region_id
= Column(Integer
, ForeignKey('regions.id'),
471 info
=dict(description
="ID of the region this location is in"))
472 name
= Column(Unicode(64), nullable
=False,
473 info
=dict(description
="English name of the location", official
=True, format
='plaintext'))
475 class LocationArea(TableBase
):
476 u
"""A sub-area of a location
478 __tablename__
= 'location_areas'
479 id = Column(Integer
, primary_key
=True, nullable
=False,
480 info
=dict(description
="A numeric ID"))
481 location_id
= Column(Integer
, ForeignKey('locations.id'), nullable
=False,
482 info
=dict(description
="ID of the location this area is part of"))
483 internal_id
= Column(Integer
, nullable
=False,
484 info
=dict(description
="ID the games ude for this area"))
485 name
= Column(Unicode(64), nullable
=True,
486 info
=dict(description
="An English name of the area, if applicable", format
='plaintext'))
488 class LocationAreaEncounterRate(TableBase
):
489 # XXX: What's this exactly? Someone add the docstring & revise the descriptions
490 __tablename__
= 'location_area_encounter_rates'
491 location_area_id
= Column(Integer
, ForeignKey('location_areas.id'), primary_key
=True, nullable
=False, autoincrement
=False,
492 info
=dict(description
="ID of the area"))
493 encounter_terrain_id
= Column(Integer
, ForeignKey('encounter_terrain.id'), primary_key
=True, nullable
=False, autoincrement
=False,
494 info
=dict(description
="ID of the terrain"))
495 version_id
= Column(Integer
, ForeignKey('versions.id'), primary_key
=True, autoincrement
=False,
496 info
=dict(description
="ID of the version"))
497 rate
= Column(Integer
, nullable
=True,
498 info
=dict(description
="The encounter rate")) # units?
500 class LocationInternalID(TableBase
):
501 u
"""IDs the games use internally for locations
503 __tablename__
= 'location_internal_ids'
504 location_id
= Column(Integer
, ForeignKey('locations.id'), nullable
=False, primary_key
=True,
505 info
=dict(description
="Database ID of the locaion"))
506 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False, primary_key
=True,
507 info
=dict(description
="ID of the generation this entry to"))
508 internal_id
= Column(Integer
, nullable
=False,
509 info
=dict(description
="Internal game ID of the location"))
511 class Machine(TableBase
):
512 u
"""A TM or HM; numbered item that can teach a move to a pokémon
514 __tablename__
= 'machines'
515 machine_number
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
516 info
=dict(description
="Number of the machine for TMs, or 100 + the munber for HMs"))
517 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
518 info
=dict(description
="Versions this entry applies to"))
519 item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=False,
520 info
=dict(description
="ID of the corresponding Item"))
521 move_id
= Column(Integer
, ForeignKey('moves.id'), nullable
=False,
522 info
=dict(description
="ID of the taught move"))
526 u
"""True if this machine is a HM, False if it's a TM
528 return self
.machine_number
>= 100
530 class MoveBattleStyle(TableBase
):
531 u
"""A battle style of a move""" # XXX: Explain better
532 __tablename__
= 'move_battle_styles'
533 id = Column(Integer
, primary_key
=True, nullable
=False,
534 info
=dict(description
="A numeric ID"))
535 name
= Column(Unicode(8), nullable
=False,
536 info
=dict(description
="An English name for this battle style", format
='plaintext'))
538 class MoveEffectCategory(TableBase
):
539 u
"""Category of a move effect
541 __tablename__
= 'move_effect_categories'
542 id = Column(Integer
, primary_key
=True, nullable
=False,
543 info
=dict(description
="A numeric ID"))
544 name
= Column(Unicode(64), nullable
=False,
545 info
=dict(description
="English name of the category", format
='plaintext'))
546 can_affect_user
= Column(Boolean
, nullable
=False,
547 info
=dict(description
="Set if the user can be affected"))
549 class MoveEffectCategoryMap(TableBase
):
550 u
"""Maps a move effect category to a move effect
552 __tablename__
= 'move_effect_category_map'
553 move_effect_id
= Column(Integer
, ForeignKey('move_effects.id'), primary_key
=True, nullable
=False,
554 info
=dict(description
="ID of the move effect"))
555 move_effect_category_id
= Column(Integer
, ForeignKey('move_effect_categories.id'), primary_key
=True, nullable
=False,
556 info
=dict(description
="ID of the category"))
557 affects_user
= Column(Boolean
, primary_key
=True, nullable
=False,
558 info
=dict(description
="Set if the user is affected"))
560 class MoveDamageClass(TableBase
):
561 u
"""Damage class of a move, i.e. "Physical", "Special, or "None".
563 __tablename__
= 'move_damage_classes'
564 id = Column(Integer
, primary_key
=True, nullable
=False,
565 info
=dict(description
="A numeric ID"))
566 name
= Column(Unicode(8), nullable
=False,
567 info
=dict(description
="An English name of the class", format
='plaintext'))
568 description
= Column(Unicode(64), nullable
=False,
569 info
=dict(description
="An English description of the class", format
='plaintext'))
571 class MoveEffect(TableBase
):
572 u
"""An effect of a move
574 __tablename__
= 'move_effects'
575 id = Column(Integer
, primary_key
=True, nullable
=False,
576 info
=dict(description
="A numeric ID"))
577 short_effect
= Column(Unicode(256), nullable
=False,
578 info
=dict(description
="A short summary of the effect", format
='plaintext'))
579 effect
= Column(Unicode(5120), nullable
=False,
580 info
=dict(description
="A detailed description of the effect", format
='plaintext'))
582 class MoveFlag(TableBase
):
583 u
"""Maps a move flag to a move
585 # XXX: Other flags have a ___Flag class for the actual flag and ___FlagMap for the map,
586 # these, somewhat confusingly, have MoveFlagType and MoveFlag
587 __tablename__
= 'move_flags'
588 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
589 info
=dict(description
="ID of the move"))
590 move_flag_type_id
= Column(Integer
, ForeignKey('move_flag_types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
591 info
=dict(description
="ID of the flag"))
593 class MoveFlagType(TableBase
):
594 u
"""A Move attribute such as "snatchable" or "contact".
596 __tablename__
= 'move_flag_types'
597 id = Column(Integer
, primary_key
=True, nullable
=False,
598 info
=dict(description
="A numeric ID"))
599 identifier
= Column(Unicode(16), nullable
=False,
600 info
=dict(description
="A short identifier for the flag", format
='identifier'))
601 name
= Column(Unicode(32), nullable
=False,
602 info
=dict(description
="An English name for the flag", format
='plaintext'))
603 description
= Column(markdown
.MarkdownColumn(128), nullable
=False,
604 info
=dict(description
="A short English description of the flag", format
='markdown'))
606 class MoveFlavorText(TableBase
):
607 u
"""In-game description of a move
609 __tablename__
= 'move_flavor_text'
610 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
611 info
=dict(description
="ID of the move"))
612 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
613 info
=dict(description
="ID of the version group this text appears in"))
614 flavor_text
= Column(Unicode(255), nullable
=False,
615 info
=dict(description
="The English flavor text", official
=True, format
='gametext'))
617 class MoveName(TableBase
):
618 u
"""Non-English name of a move
620 __tablename__
= 'move_names'
621 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
622 info
=dict(description
="ID of the move"))
623 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
624 info
=dict(description
="ID of the language"))
625 name
= Column(Unicode(16), nullable
=False,
626 info
=dict(description
="ID of the language", foreign
=True, format
='plaintext'))
628 class MoveTarget(TableBase
):
629 u
"""Targetting or "range" of a move, e.g. "Affects all opponents" or "Affects user".
631 __tablename__
= 'move_targets'
632 id = Column(Integer
, primary_key
=True, nullable
=False,
633 info
=dict(description
="A numeric ID"))
634 name
= Column(Unicode(32), nullable
=False,
635 info
=dict(description
="An English name", format
='plaintext'))
636 description
= Column(Unicode(128), nullable
=False,
637 info
=dict(description
="An English description", format
='plaintext'))
639 class Move(TableBase
):
640 u
"""A Move: technique or attack a Pokémon can learn to use
642 __tablename__
= 'moves'
643 __singlename__
= 'move'
644 id = Column(Integer
, primary_key
=True, nullable
=False,
645 info
=dict(description
="A numeric ID"))
646 name
= Column(Unicode(24), nullable
=False,
647 info
=dict(description
="The English name of the move", official
=True, format
='plaintext'))
648 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
649 info
=dict(description
="ID of the generation this move first appeared in"))
650 type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=False,
651 info
=dict(description
="ID of the move's elemental type"))
652 power
= Column(SmallInteger
, nullable
=False,
653 info
=dict(description
="Base power of the move"))
654 pp
= Column(SmallInteger
, nullable
=False,
655 info
=dict(description
="Base PP (Power Points) of the move"))
656 accuracy
= Column(SmallInteger
, nullable
=True,
657 info
=dict(description
="Accuracy of the move; NULL means it never misses"))
658 priority
= Column(SmallInteger
, nullable
=False,
659 info
=dict(description
="The move's priority bracket"))
660 target_id
= Column(Integer
, ForeignKey('move_targets.id'), nullable
=False,
661 info
=dict(description
="ID of the target (range) of the move"))
662 damage_class_id
= Column(Integer
, ForeignKey('move_damage_classes.id'), nullable
=False,
663 info
=dict(description
="ID of the damage class (physical/special) of the move"))
664 effect_id
= Column(Integer
, ForeignKey('move_effects.id'), nullable
=False,
665 info
=dict(description
="ID of the move's effect"))
666 effect_chance
= Column(Integer
,
667 info
=dict(description
="The chance for a secondary effect. What this is a chance of is specified by the move's effect."))
668 contest_type_id
= Column(Integer
, ForeignKey('contest_types.id'), nullable
=True,
669 info
=dict(description
="ID of the move's Contest type (e.g. cool or smart)"))
670 contest_effect_id
= Column(Integer
, ForeignKey('contest_effects.id'), nullable
=True,
671 info
=dict(description
="ID of the move's Contest effect"))
672 super_contest_effect_id
= Column(Integer
, ForeignKey('super_contest_effects.id'), nullable
=True,
673 info
=dict(description
="ID of the move's Super Contest effect"))
675 class Nature(TableBase
):
676 u
"""A nature a pokémon can have, such as Calm or Brave
678 __tablename__
= 'natures'
679 __singlename__
= 'nature'
680 id = Column(Integer
, primary_key
=True, nullable
=False,
681 info
=dict(description
="A numeric ID"))
682 name
= Column(Unicode(8), nullable
=False,
683 info
=dict(description
="An English name of the nature", official
=True, format
='plaintext'))
684 decreased_stat_id
= Column(Integer
, ForeignKey('stats.id'), nullable
=False,
685 info
=dict(description
="ID of the stat that this nature decreases by 10% (if decreased_stat_id is the same, the effects cancel out)"))
686 increased_stat_id
= Column(Integer
, ForeignKey('stats.id'), nullable
=False,
687 info
=dict(description
="ID of the stat that this nature increases by 10% (if decreased_stat_id is the same, the effects cancel out)"))
688 hates_flavor_id
= Column(Integer
, ForeignKey('contest_types.id'), nullable
=False,
689 info
=dict(description
=u
"ID of the Berry flavor the Pokémon hates (if likes_flavor_id is the same, the effects cancel out)"))
690 likes_flavor_id
= Column(Integer
, ForeignKey('contest_types.id'), nullable
=False,
691 info
=dict(description
=u
"ID of the Berry flavor the Pokémon likes (if hates_flavor_id is the same, the effects cancel out)"))
694 def is_neutral(self
):
695 u
"""Returns True iff this nature doesn't alter a Pokémon's stats,
696 bestow taste preferences, etc.
698 return self
.increased_stat_id
== self
.decreased_stat_id
700 class NatureBattleStylePreference(TableBase
):
701 u
"""Battle Palace move preference
703 Specifies how likely a pokémon with a specific Nature is to use a move of
704 a particular battl style in Battle Palace or Battle Tent
706 __tablename__
= 'nature_battle_style_preferences'
707 nature_id
= Column(Integer
, ForeignKey('natures.id'), primary_key
=True, nullable
=False,
708 info
=dict(description
=u
"ID of the pokémon's nature"))
709 move_battle_style_id
= Column(Integer
, ForeignKey('move_battle_styles.id'), primary_key
=True, nullable
=False,
710 info
=dict(description
="ID of the battle style"))
711 low_hp_preference
= Column(Integer
, nullable
=False,
712 info
=dict(description
=u
"Chance of using the move, in percent, if HP is under ½"))
713 high_hp_preference
= Column(Integer
, nullable
=False,
714 info
=dict(description
=u
"Chance of using the move, in percent, if HP is over ½"))
716 class NatureName(TableBase
):
717 u
"""Non-english name of a Nature
719 __tablename__
= 'nature_names'
720 nature_id
= Column(Integer
, ForeignKey('natures.id'), primary_key
=True, nullable
=False, autoincrement
=False,
721 info
=dict(description
="ID of the nature"))
722 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
723 info
=dict(description
="ID of the language"))
724 name
= Column(Unicode(8), nullable
=False,
725 info
=dict(description
="The nature's foreign name", foreign
=True, format
='plaintext'))
727 class NaturePokeathlonStat(TableBase
):
728 u
"""Specifies how a Nature affects a Pokéathlon stat
730 __tablename__
= 'nature_pokeathlon_stats'
731 nature_id
= Column(Integer
, ForeignKey('natures.id'), primary_key
=True, nullable
=False,
732 info
=dict(description
="ID of the nature"))
733 pokeathlon_stat_id
= Column(Integer
, ForeignKey('pokeathlon_stats.id'), primary_key
=True, nullable
=False,
734 info
=dict(description
="ID of the stat"))
735 max_change
= Column(Integer
, nullable
=False,
736 info
=dict(description
="Maximum change"))
738 class PokeathlonStat(TableBase
):
739 u
"""A Pokéathlon stat, such as "Stamina" or "Jump".
741 __tablename__
= 'pokeathlon_stats'
742 id = Column(Integer
, primary_key
=True, nullable
=False,
743 info
=dict(description
="A numeric ID"))
744 name
= Column(Unicode(8), nullable
=False,
745 info
=dict(description
="The English name of the stat", official
=True, format
='plaintext'))
747 class Pokedex(TableBase
):
748 u
"""A collection of pokémon species ordered in a particular way
750 __tablename__
= 'pokedexes'
751 id = Column(Integer
, primary_key
=True, nullable
=False,
752 info
=dict(description
="A numeric ID"))
753 region_id
= Column(Integer
, ForeignKey('regions.id'), nullable
=True,
754 info
=dict(description
=u
"ID of the region this pokédex is used in, or None if it's global"))
755 name
= Column(Unicode(16), nullable
=False,
756 info
=dict(description
=u
"An English name of the pokédex", format
='plaintext'))
757 description
= Column(Unicode(512),
758 info
=dict(description
=u
"A longer description of the pokédex", format
='plaintext'))
760 class PokedexVersionGroup(TableBase
):
761 u
"""Maps a pokédex to the version group that uses it
763 __tablename__
= 'pokedex_version_groups'
764 pokedex_id
= Column(Integer
, ForeignKey('pokedexes.id'), primary_key
=True, nullable
=False, autoincrement
=False,
765 info
=dict(description
=u
"ID of the pokédex"))
766 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
767 info
=dict(description
=u
"ID of the version group"))
769 class Pokemon(TableBase
):
770 u
"""A species of Pokémon. The core to this whole mess.
772 __tablename__
= 'pokemon'
773 __singlename__
= 'pokemon'
774 id = Column(Integer
, primary_key
=True, nullable
=False,
775 info
=dict(description
=u
"A numeric ID"))
776 name
= Column(Unicode(20), nullable
=False,
777 info
=dict(description
=u
"The English name of the Pokémon", official
=True, format
='plaintext'))
778 generation_id
= Column(Integer
, ForeignKey('generations.id'),
779 info
=dict(description
=u
"ID of the generation this species first appeared in"))
780 evolution_chain_id
= Column(Integer
, ForeignKey('evolution_chains.id'),
781 info
=dict(description
=u
"ID of the species' evolution chain (a.k.a. family)"))
782 height
= Column(Integer
, nullable
=False,
783 info
=dict(description
=u
"The height of the pokémon, in decimeters (tenths of a meter)"))
784 weight
= Column(Integer
, nullable
=False,
785 info
=dict(description
=u
"The weight of the pokémon, in tenths of a kilogram (decigrams)"))
786 species
= Column(Unicode(16), nullable
=False,
787 info
=dict(description
=u
'The short English flavor text, such as "Seed" or "Lizard"; usually affixed with the word "Pokémon"',
788 official
=True, format
='plaintext'))
789 color_id
= Column(Integer
, ForeignKey('pokemon_colors.id'), nullable
=False,
790 info
=dict(description
=u
"ID of this pokémon's pokédex color, as used for a gimmick search function in the games."))
791 pokemon_shape_id
= Column(Integer
, ForeignKey('pokemon_shapes.id'), nullable
=True,
792 info
=dict(description
=u
"ID of this pokémon's body shape, as used for a gimmick search function in the games."))
793 habitat_id
= Column(Integer
, ForeignKey('pokemon_habitats.id'), nullable
=True,
794 info
=dict(description
=u
"ID of this pokémon's habitat, as used for a gimmick search function in the games."))
795 gender_rate
= Column(Integer
, nullable
=False,
796 info
=dict(description
=u
"The chance of this pokémon being female, in eighths; or -1 for genderless"))
797 capture_rate
= Column(Integer
, nullable
=False,
798 info
=dict(description
=u
"The base capture rate; up to 255"))
799 base_experience
= Column(Integer
, nullable
=False,
800 info
=dict(description
=u
"The base EXP gained when defeating this pokémon")) # XXX: Is this correct?
801 base_happiness
= Column(Integer
, nullable
=False,
802 info
=dict(description
=u
"The tameness when caught by a normal ball"))
803 is_baby
= Column(Boolean
, nullable
=False,
804 info
=dict(description
=u
"True iff the pokémon is a baby")) # XXX: What exactly makes it a baby?
805 hatch_counter
= Column(Integer
, nullable
=False,
806 info
=dict(description
=u
"Initial hatch counter: one must walk 255 × (hatch_counter + 1) steps before this pokémon's egg hatches, unless utilizing bonuses like Flame Body's"))
807 has_gen4_fem_sprite
= Column(Boolean
, nullable
=False,
808 info
=dict(description
=u
"Set iff the species' female front sprite is different from the male's in generation IV"))
809 has_gen4_fem_back_sprite
= Column(Boolean
, nullable
=False,
810 info
=dict(description
=u
"Set iff the species' female back sprite is different from the male's in generation IV"))
812 ### Stuff to handle alternate Pokémon forms
815 def is_base_form(self
):
816 u
"""Returns True iff the Pokémon is the base form for its species,
820 return self
.unique_form
is None or self
.unique_form
.is_default
824 u
"""Returns the Pokémon's form name if it represents a particular form
825 and that form has a name, or None otherwise.
828 # If self.unique_form is None, the short-circuit "and" will go ahead
829 # and return that. Otherwise, it'll return the form's name, which may
831 return self
.unique_form
and self
.unique_form
.name
835 u
"""Returns the Pokémon's name, including its form if applicable."""
838 return '{0} {1}'.format(self
.form_name
, self
.name
)
843 def normal_form(self
):
844 u
"""Returns the normal form for this Pokémon; i.e., this will return
845 regular Deoxys when called on any Deoxys form.
849 return self
.unique_form
.form_base_pokemon
854 def stat(self
, stat_name
):
855 u
"""Returns a PokemonStat record for the given stat name (or Stat row
856 object). Uses the normal has-many machinery, so all the stats are
859 if isinstance(stat_name
, Stat
):
860 stat_name
= stat_name
.name
862 for pokemon_stat
in self
.stats
:
863 if pokemon_stat
.stat
.name
== stat_name
:
866 raise KeyError(u
'No stat named %s' % stat_name
)
869 def better_damage_class(self
):
870 u
"""Returns the MoveDamageClass that this Pokémon is best suited for,
871 based on its attack stats.
873 If the attack stats are about equal (within 5), returns None. The
874 value None, not the damage class called 'None'.
876 phys
= self
.stat(u
'Attack')
877 spec
= self
.stat(u
'Special Attack')
879 diff
= phys
.base_stat
- spec
.base_stat
882 return phys
.stat
.damage_class
884 return spec
.stat
.damage_class
888 class PokemonAbility(TableBase
):
889 u
"""Maps an ability to a pokémon that can have it
891 __tablename__
= 'pokemon_abilities'
892 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
893 info
=dict(description
=u
"ID of the pokémon"))
894 ability_id
= Column(Integer
, ForeignKey('abilities.id'), nullable
=False,
895 info
=dict(description
=u
"ID of the ability"))
896 # XXX having both a method and a slot is kind of gross. "slot" is a
897 # misnomer, anyway: duplicate abilities don't appear in slot 2.
898 # Probably should replace that with "order".
899 is_dream
= Column(Boolean
, nullable
=False, index
=True,
900 info
=dict(description
=u
"Whether this is a Dream World ability"))
901 slot
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
902 info
=dict(description
=u
"The ability slot, i.e. 1 or 2 for gen. IV"))
904 class PokemonColor(TableBase
):
905 u
"""The "pokédex color" of a pokémon species. Usually based on the pokémon's color.
907 __tablename__
= 'pokemon_colors'
908 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
909 info
=dict(description
=u
"ID of the pokémon"))
910 name
= Column(Unicode(6), nullable
=False,
911 info
=dict(description
=u
"The English name of the color", official
=True, format
='identifier'))
913 class PokemonDexNumber(TableBase
):
914 u
"""The number of a Pokémon in a particular Pokédex (e.g. Jigglypuff is #138 in Hoenn's 'dex)
916 __tablename__
= 'pokemon_dex_numbers'
917 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
918 info
=dict(description
=u
"ID of the pokémon"))
919 pokedex_id
= Column(Integer
, ForeignKey('pokedexes.id'), primary_key
=True, nullable
=False, autoincrement
=False,
920 info
=dict(description
=u
"ID of the pokédex"))
921 pokedex_number
= Column(Integer
, nullable
=False,
922 info
=dict(description
=u
"Number of the pokémon in that the pokédex"))
924 class PokemonEggGroup(TableBase
):
925 u
"""Maps an Egg group to a pokémon; each pokémon belongs to one or two egg groups
927 __tablename__
= 'pokemon_egg_groups'
928 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
929 info
=dict(description
=u
"ID of the pokémon"))
930 egg_group_id
= Column(Integer
, ForeignKey('egg_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
931 info
=dict(description
=u
"ID of the egg group"))
933 class PokemonEvolution(TableBase
):
934 u
"""Specifies what causes a particular pokémon to evolve into another species.
936 __tablename__
= 'pokemon_evolution'
937 from_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False,
938 info
=dict(description
=u
"ID of the pre-evolution species"))
939 to_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
940 info
=dict(description
=u
"ID of the post-evolution species"))
941 evolution_trigger_id
= Column(Integer
, ForeignKey('evolution_triggers.id'), nullable
=False,
942 info
=dict(description
=u
"ID of the trigger type"))
943 trigger_item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=True,
944 info
=dict(description
=u
"ID of the item that triggers the evolution in a way defined by evolution_trigger_id"))
945 minimum_level
= Column(Integer
, nullable
=True,
946 info
=dict(description
=u
"Minimum level, or None if level doean't matter"))
947 gender
= Column(Enum('male', 'female', name
='pokemon_evolution_gender'), nullable
=True,
948 info
=dict(description
=u
"Required gender, or None if gender doesn't matter"))
949 location_id
= Column(Integer
, ForeignKey('locations.id'), nullable
=True,
950 info
=dict(description
=u
"Required location, or None if it doesn't matter"))
951 held_item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=True,
952 info
=dict(description
=u
"An item the pokémon must hold, or None if it doesn't matter"))
953 time_of_day
= Column(Enum('morning', 'day', 'night', name
='pokemon_evolution_time_of_day'), nullable
=True,
954 info
=dict(description
=u
"Required time of day, or None if it doesn't matter"))
955 known_move_id
= Column(Integer
, ForeignKey('moves.id'), nullable
=True,
956 info
=dict(description
=u
"ID of a move the pokémon must know, or None if it doesn't matter"))
957 minimum_happiness
= Column(Integer
, nullable
=True,
958 info
=dict(description
=u
"Minimum tameness value the pokémon must have, or None if it doesn't matter"))
959 minimum_beauty
= Column(Integer
, nullable
=True,
960 info
=dict(description
=u
"Minimum Beauty value the pokémon must have, or None if it doesn't matter"))
961 relative_physical_stats
= Column(Integer
, nullable
=True,
962 info
=dict(description
=u
"Relation of Attack and Defense stats the pokémon must have, as sgn(atk-def), or None if that doesn't matter"))
963 party_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=True,
964 info
=dict(description
=u
"ID of a pokémon that must be present in the party, or None if there's no such condition"))
966 class PokemonFlavorText(TableBase
):
967 u
"""In-game pokédex descrption of a pokémon.
969 __tablename__
= 'pokemon_flavor_text'
970 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
971 info
=dict(description
=u
"ID of the pokémon"))
972 version_id
= Column(Integer
, ForeignKey('versions.id'), primary_key
=True, nullable
=False, autoincrement
=False,
973 info
=dict(description
=u
"ID of the version that has this flavor text"))
974 flavor_text
= Column(Unicode(255), nullable
=False,
975 info
=dict(description
=u
"ID of the version that has this flavor text", official
=True, format
='gametext'))
977 class PokemonForm(TableBase
):
978 u
"""An individual form of a Pokémon.
980 Pokémon that do not have separate forms are still given a single row to
981 represent their single form.
983 __tablename__
= 'pokemon_forms'
984 __singlename__
= 'pokemon_form'
985 id = Column(Integer
, primary_key
=True, nullable
=False,
986 info
=dict(description
=u
'A unique ID for this form.'))
987 name
= Column(Unicode(16), nullable
=True,
988 info
=dict(description
=u
"This form's name, e.g. \"Plant\" for Plant Cloak Burmy.", official
=True, format
='plaintext'))
989 form_base_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False, autoincrement
=False,
990 info
=dict(description
=u
'The ID of the base Pokémon for this form.'))
991 unique_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), autoincrement
=False,
992 info
=dict(description
=u
'The ID of a Pokémon that represents specifically this form, for Pokémon with functionally-different forms like Wormadam.'))
993 introduced_in_version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), autoincrement
=False,
994 info
=dict(description
=u
'The ID of the version group in which this form first appeared.'))
995 is_default
= Column(Boolean
, nullable
=False,
996 info
=dict(description
=u
'Set for exactly one form used as the default for each species.'))
997 order
= Column(Integer
, nullable
=False, autoincrement
=False,
998 info
=dict(description
=u
'The order in which forms should be sorted. Multiple forms may have equal order, in which case they should fall back on sorting by name.'))
1001 def full_name(self
):
1002 u
"""Returns the full name of this form, e.g. "Plant Cloak"."""
1006 elif self
.form_group
and self
.form_group
.term
:
1007 return '{0} {1}'.format(self
.name
, self
.form_group
.term
)
1012 def pokemon_name(self
):
1013 u
"""Returns the name of this Pokémon with this form, e.g. "Plant
1018 return '{0} {1}'.format(self
.name
, self
.form_base_pokemon
.name
)
1020 return self
.form_base_pokemon
.name
1022 class PokemonFormGroup(TableBase
):
1023 u
"""Information about a Pokémon's forms as a group."""
1024 __tablename__
= 'pokemon_form_groups'
1025 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1026 info
=dict(description
=u
"ID of the base form Pokémon"))
1027 term
= Column(Unicode(16), nullable
=True,
1028 info
=dict(description
=u
"The term for this Pokémon's forms, e.g. \"Cloak\" for Burmy or \"Forme\" for Deoxys.", official
=True, format
='plaintext'))
1029 is_battle_only
= Column(Boolean
, nullable
=False,
1030 info
=dict(description
=u
"Set iff the forms only change in battle"))
1031 description
= Column(markdown
.MarkdownColumn(1024), nullable
=False,
1032 info
=dict(description
=u
"English description of how the forms work", format
='markdown'))
1034 class PokemonHabitat(TableBase
):
1035 u
"""The habitat of a pokémon, as given in the FireRed/LeafGreen version pokédex
1037 __tablename__
= 'pokemon_habitats'
1038 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1039 info
=dict(description
=u
"A numeric ID"))
1040 name
= Column(Unicode(16), nullable
=False,
1041 info
=dict(description
=u
"The English name of the habitat", official
=True, format
='plaintext'))
1043 class PokemonInternalID(TableBase
):
1044 u
"""The number of a pokémon a game uses internally
1046 __tablename__
= 'pokemon_internal_ids'
1047 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, autoincrement
=False, nullable
=False,
1048 info
=dict(description
=u
"Database ID of the pokémon"))
1049 generation_id
= Column(Integer
, ForeignKey('generations.id'), primary_key
=True, autoincrement
=False, nullable
=False,
1050 info
=dict(description
=u
"Database ID of the generation"))
1051 internal_id
= Column(Integer
, nullable
=False,
1052 info
=dict(description
=u
"Internal ID the generation's games use for the pokémon"))
1054 class PokemonItem(TableBase
):
1055 u
"""Record of an item a pokémon can hold in the wild
1057 __tablename__
= 'pokemon_items'
1058 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1059 info
=dict(description
=u
"ID of the pokémon"))
1060 version_id
= Column(Integer
, ForeignKey('versions.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1061 info
=dict(description
=u
"ID of the version this applies to"))
1062 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1063 info
=dict(description
=u
"ID of the item"))
1064 rarity
= Column(Integer
, nullable
=False,
1065 info
=dict(description
=u
"Chance of the pokémon holding the item, in percent"))
1067 class PokemonMove(TableBase
):
1068 u
"""Record of a move a pokémon can learn
1070 __tablename__
= 'pokemon_moves'
1071 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False, index
=True,
1072 info
=dict(description
=u
"ID of the pokémon"))
1073 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False, index
=True,
1074 info
=dict(description
=u
"ID of the version group this applies to"))
1075 move_id
= Column(Integer
, ForeignKey('moves.id'), nullable
=False, index
=True,
1076 info
=dict(description
=u
"ID of the move"))
1077 pokemon_move_method_id
= Column(Integer
, ForeignKey('pokemon_move_methods.id'), nullable
=False, index
=True,
1078 info
=dict(description
=u
"ID of the method this move is learned by"))
1079 level
= Column(Integer
, nullable
=True, index
=True,
1080 info
=dict(description
=u
"Level the move is learned at, if applicable"))
1081 order
= Column(Integer
, nullable
=True,
1082 info
=dict(description
=u
"A sort key to produce the correct ordering when all else is equal")) # XXX: This needs a better description
1085 PrimaryKeyConstraint('pokemon_id', 'version_group_id', 'move_id', 'pokemon_move_method_id', 'level'),
1089 class PokemonMoveMethod(TableBase
):
1090 u
"""A method a move can be learned by, such as "Level up" or "Tutor".
1092 __tablename__
= 'pokemon_move_methods'
1093 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1094 info
=dict(description
=u
"A numeric ID"))
1095 name
= Column(Unicode(64), nullable
=False,
1096 info
=dict(description
=u
"An English name of the method", format
='plaintext'))
1097 description
= Column(Unicode(255), nullable
=False,
1098 info
=dict(description
=u
"A detailed description of how the method works", format
='plaintext'))
1100 class PokemonName(TableBase
):
1101 u
"""A non-English name of a pokémon.
1103 __tablename__
= 'pokemon_names'
1104 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1105 info
=dict(description
=u
"ID of the pokémon"))
1106 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1107 info
=dict(description
=u
"ID of the language"))
1108 name
= Column(Unicode(16), nullable
=False,
1109 info
=dict(description
=u
"Name of the pokémon in the language", foreign
=True, format
='plaintext'))
1111 class PokemonShape(TableBase
):
1112 u
"""The shape of a pokémon's body, as used in generation IV pokédexes.
1114 __tablename__
= 'pokemon_shapes'
1115 id = Column(Integer
, primary_key
=True, nullable
=False,
1116 info
=dict(description
=u
"A numeric ID"))
1117 name
= Column(Unicode(24), nullable
=False,
1118 info
=dict(description
=u
"A boring English name of the body shape", format
='plaintext'))
1119 awesome_name
= Column(Unicode(16), nullable
=False,
1120 info
=dict(description
=u
"A splendiferous, technically English, name of the body shape", format
='plaintext'))
1122 class PokemonStat(TableBase
):
1123 u
"""A stat value of a pokémon
1125 __tablename__
= 'pokemon_stats'
1126 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1127 info
=dict(description
=u
"ID of the pokémon"))
1128 stat_id
= Column(Integer
, ForeignKey('stats.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1129 info
=dict(description
=u
"ID of the stat"))
1130 base_stat
= Column(Integer
, nullable
=False,
1131 info
=dict(description
=u
"The base stat"))
1132 effort
= Column(Integer
, nullable
=False,
1133 info
=dict(description
=u
"The effort increase in this stat gained when this pokémon is defeated"))
1135 class PokemonType(TableBase
):
1136 u
"""Maps a type to a pokémon. Each pokémon has 1 or 2 types.
1138 __tablename__
= 'pokemon_types'
1139 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1140 info
=dict(description
=u
"ID of the pokémon"))
1141 type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=False,
1142 info
=dict(description
=u
"ID of the type"))
1143 slot
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1144 info
=dict(description
=u
"The type's slot, 1 or 2, used to sort types if there are two of them"))
1146 class Region(TableBase
):
1147 u
"""Major areas of the world: Kanto, Johto, etc.
1149 __tablename__
= 'regions'
1150 id = Column(Integer
, primary_key
=True, nullable
=False,
1151 info
=dict(description
=u
"A numeric ID"))
1152 name
= Column(Unicode(16), nullable
=False,
1153 info
=dict(description
=u
"The English name of the region", official
=True, format
='plaintext'))
1155 class Stat(TableBase
):
1156 u
"""A Stat, such as Attack or Speed
1158 __tablename__
= 'stats'
1159 id = Column(Integer
, primary_key
=True, nullable
=False,
1160 info
=dict(description
=u
"A numeric ID"))
1161 damage_class_id
= Column(Integer
, ForeignKey('move_damage_classes.id'), nullable
=True,
1162 info
=dict(description
=u
"For offensive and defensive stats, the damage this stat relates to; otherwise None (the NULL value)"))
1163 name
= Column(Unicode(16), nullable
=False,
1164 info
=dict(description
=u
"The English name of the stat", official
=True, format
='plaintext'))
1166 class SuperContestCombo(TableBase
):
1167 u
"""Combo of two moves in a Super Contest.
1169 __tablename__
= 'super_contest_combos'
1170 first_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1171 info
=dict(description
=u
"ID of the first move"))
1172 second_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1173 info
=dict(description
=u
"ID of the second and last move"))
1175 class SuperContestEffect(TableBase
):
1176 u
"""An effect a move can have when used in the Super Contest
1178 __tablename__
= 'super_contest_effects'
1179 id = Column(Integer
, primary_key
=True, nullable
=False,
1180 info
=dict(description
=u
"A numeric ID"))
1181 appeal
= Column(SmallInteger
, nullable
=False,
1182 info
=dict(description
=u
"Number of hearts the user will get when executing a move with this effect"))
1183 flavor_text
= Column(Unicode(64), nullable
=False,
1184 info
=dict(description
=u
"An English description of the effect", format
='plaintext'))
1186 class TypeEfficacy(TableBase
):
1187 u
"""The effectiveness of damage of one type against pokémon of another type
1189 __tablename__
= 'type_efficacy'
1190 damage_type_id
= Column(Integer
, ForeignKey('types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1191 info
=dict(description
=u
"ID of the damage type; most commonly this is the same as the attack type"))
1192 target_type_id
= Column(Integer
, ForeignKey('types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1193 info
=dict(description
=u
"ID of the defending pokémon's type"))
1194 damage_factor
= Column(Integer
, nullable
=False,
1195 info
=dict(description
=u
"The effectiveness, in percent"))
1197 class Type(TableBase
):
1198 u
"""An elemental type, such as Grass or Steel
1200 __tablename__
= 'types'
1201 __singlename__
= 'type'
1202 id = Column(Integer
, primary_key
=True, nullable
=False,
1203 info
=dict(description
=u
"A numeric ID"))
1204 name
= Column(Unicode(8), nullable
=False,
1205 info
=dict(description
=u
"The English name.", format
='plaintext')) # XXX: Is this official? The games don't spell "Electric" in full...
1206 abbreviation
= Column(Unicode(3), nullable
=False,
1207 info
=dict(description
=u
"An arbitrary 3-letter abbreviation of the type", format
='plaintext')) # XXX: Or is it not arbitrary?
1208 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
1209 info
=dict(description
=u
"ID of the generation this type first appeared in"))
1210 damage_class_id
= Column(Integer
, ForeignKey('move_damage_classes.id'), nullable
=False,
1211 info
=dict(description
=u
"ID of the damage class this type's moves had before generation IV, or None for the ??? type"))
1213 class TypeName(TableBase
):
1214 u
"""Non-English name of an elemental type
1216 __tablename__
= 'type_names'
1217 type_id
= Column(Integer
, ForeignKey('types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1218 info
=dict(description
=u
"ID of the type"))
1219 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1220 info
=dict(description
=u
"ID of the language"))
1221 name
= Column(Unicode(16), nullable
=False,
1222 info
=dict(description
=u
"Name of the type in that language", foreign
=True, format
='plaintext'))
1224 class VersionGroup(TableBase
):
1225 u
"""A group of related game versions
1227 __tablename__
= 'version_groups'
1228 id = Column(Integer
, primary_key
=True, nullable
=False,
1229 info
=dict(description
=u
"A numeric ID"))
1230 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
1231 info
=dict(description
=u
"ID of the generation the games of this group belong to"))
1233 class VersionGroupRegion(TableBase
):
1234 u
"""Maps a region to a game version group that features it
1236 __tablename__
= 'version_group_regions'
1237 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False,
1238 info
=dict(description
=u
"ID of the version"))
1239 region_id
= Column(Integer
, ForeignKey('regions.id'), primary_key
=True, nullable
=False,
1240 info
=dict(description
=u
"ID of the region"))
1242 class Version(TableBase
):
1243 u
"""A version of a mainline pokémon game
1245 __tablename__
= 'versions'
1246 id = Column(Integer
, primary_key
=True, nullable
=False,
1247 info
=dict(description
=u
"A numeric ID"))
1248 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False,
1249 info
=dict(description
=u
"ID of the version group this game belongs to"))
1250 name
= Column(Unicode(32), nullable
=False,
1251 info
=dict(description
=u
'The English name of the game, without the "Pokémon" prefix', official
=True, format
='plaintext'))
1254 ### Relations down here, to avoid ordering problems
1255 Ability
.flavor_text
= relation(AbilityFlavorText
, order_by
=AbilityFlavorText
.version_group_id
, backref
='ability')
1256 Ability
.foreign_names
= relation(AbilityName
, backref
='ability')
1257 Ability
.generation
= relation(Generation
, backref
='abilities')
1258 Ability
.pokemon
= relation(Pokemon
,
1259 secondary
=PokemonAbility
.__table__
,
1262 AbilityFlavorText
.version_group
= relation(VersionGroup
)
1264 AbilityName
.language
= relation(Language
)
1266 Berry
.berry_firmness
= relation(BerryFirmness
, backref
='berries')
1267 Berry
.firmness
= association_proxy('berry_firmness', 'name')
1268 Berry
.flavors
= relation(BerryFlavor
, order_by
=BerryFlavor
.contest_type_id
, backref
='berry')
1269 Berry
.natural_gift_type
= relation(Type
)
1271 BerryFlavor
.contest_type
= relation(ContestType
)
1273 ContestCombo
.first
= relation(Move
, primaryjoin
=ContestCombo
.first_move_id
==Move
.id,
1274 backref
='contest_combo_first')
1275 ContestCombo
.second
= relation(Move
, primaryjoin
=ContestCombo
.second_move_id
==Move
.id,
1276 backref
='contest_combo_second')
1278 Encounter
.location_area
= relation(LocationArea
, backref
='encounters')
1279 Encounter
.pokemon
= relation(Pokemon
, backref
='encounters')
1280 Encounter
.version
= relation(Version
, backref
='encounters')
1281 Encounter
.slot
= relation(EncounterSlot
, backref
='encounters')
1283 EncounterConditionValue
.condition
= relation(EncounterCondition
, backref
='values')
1285 Encounter
.condition_value_map
= relation(EncounterConditionValueMap
, backref
='encounter')
1286 Encounter
.condition_values
= association_proxy('condition_value_map', 'condition_value')
1287 EncounterConditionValueMap
.condition_value
= relation(EncounterConditionValue
,
1288 backref
='encounter_map')
1290 EncounterSlot
.terrain
= relation(EncounterTerrain
, backref
='slots')
1292 EncounterSlot
.condition_map
= relation(EncounterSlotCondition
, backref
='slot')
1293 EncounterSlot
.conditions
= association_proxy('condition_map', 'condition')
1294 EncounterSlotCondition
.condition
= relation(EncounterCondition
,
1297 EvolutionChain
.growth_rate
= relation(GrowthRate
, backref
='evolution_chains')
1298 EvolutionChain
.baby_trigger_item
= relation(Item
, backref
='evolution_chains')
1300 Experience
.growth_rate
= relation(GrowthRate
, backref
='experience_table')
1302 Generation
.canonical_pokedex
= relation(Pokedex
, backref
='canonical_for_generation')
1303 Generation
.versions
= relation(Version
, secondary
=VersionGroup
.__table__
)
1304 Generation
.main_region
= relation(Region
)
1306 GrowthRate
.max_experience_obj
= relation(Experience
, primaryjoin
=and_(Experience
.growth_rate_id
== GrowthRate
.id, Experience
.level
== 100), uselist
=False)
1307 GrowthRate
.max_experience
= association_proxy('max_experience_obj', 'experience')
1309 Item
.berry
= relation(Berry
, uselist
=False, backref
='item')
1310 Item
.flags
= relation(ItemFlag
, secondary
=ItemFlagMap
.__table__
)
1311 Item
.flavor_text
= relation(ItemFlavorText
, order_by
=ItemFlavorText
.version_group_id
.asc(), backref
='item')
1312 Item
.fling_effect
= relation(ItemFlingEffect
, backref
='items')
1313 Item
.foreign_names
= relation(ItemName
, backref
='item')
1314 Item
.machines
= relation(Machine
, order_by
=Machine
.version_group_id
.asc())
1315 Item
.category
= relation(ItemCategory
)
1316 Item
.pocket
= association_proxy('category', 'pocket')
1318 ItemCategory
.items
= relation(Item
, order_by
=Item
.name
)
1319 ItemCategory
.pocket
= relation(ItemPocket
)
1321 ItemFlavorText
.version_group
= relation(VersionGroup
)
1323 ItemInternalID
.item
= relation(Item
, backref
='internal_ids')
1324 ItemInternalID
.generation
= relation(Generation
)
1326 ItemName
.language
= relation(Language
)
1328 ItemPocket
.categories
= relation(ItemCategory
, order_by
=ItemCategory
.name
)
1330 Location
.region
= relation(Region
, backref
='locations')
1332 LocationArea
.location
= relation(Location
, backref
='areas')
1334 LocationInternalID
.location
= relation(Location
, backref
='internal_ids')
1335 LocationInternalID
.generation
= relation(Generation
)
1337 Machine
.item
= relation(Item
)
1338 Machine
.version_group
= relation(VersionGroup
)
1340 Move
.contest_effect
= relation(ContestEffect
, backref
='moves')
1341 Move
.contest_combo_next
= association_proxy('contest_combo_first', 'second')
1342 Move
.contest_combo_prev
= association_proxy('contest_combo_second', 'first')
1343 Move
.contest_type
= relation(ContestType
, backref
='moves')
1344 Move
.damage_class
= relation(MoveDamageClass
, backref
='moves')
1345 Move
.flags
= association_proxy('move_flags', 'flag')
1346 Move
.flavor_text
= relation(MoveFlavorText
, order_by
=MoveFlavorText
.version_group_id
, backref
='move')
1347 Move
.foreign_names
= relation(MoveName
, backref
='move')
1348 Move
.generation
= relation(Generation
, backref
='moves')
1349 Move
.machines
= relation(Machine
, backref
='move')
1350 Move
.move_effect
= relation(MoveEffect
, backref
='moves')
1351 Move
.move_flags
= relation(MoveFlag
, backref
='move')
1352 Move
.super_contest_effect
= relation(SuperContestEffect
, backref
='moves')
1353 Move
.super_contest_combo_next
= association_proxy('super_contest_combo_first', 'second')
1354 Move
.super_contest_combo_prev
= association_proxy('super_contest_combo_second', 'first')
1355 Move
.target
= relation(MoveTarget
, backref
='moves')
1356 Move
.type = relation(Type
, backref
='moves')
1358 Move
.effect
= markdown
.MoveEffectProperty('effect')
1359 Move
.short_effect
= markdown
.MoveEffectProperty('short_effect')
1361 MoveEffect
.category_map
= relation(MoveEffectCategoryMap
)
1362 MoveEffect
.categories
= association_proxy('category_map', 'category')
1363 MoveEffectCategoryMap
.category
= relation(MoveEffectCategory
)
1365 MoveFlag
.flag
= relation(MoveFlagType
)
1367 MoveFlavorText
.version_group
= relation(VersionGroup
)
1369 MoveName
.language
= relation(Language
)
1371 Nature
.foreign_names
= relation(NatureName
, backref
='nature')
1372 Nature
.decreased_stat
= relation(Stat
, primaryjoin
=Nature
.decreased_stat_id
==Stat
.id,
1373 backref
='decreasing_natures')
1374 Nature
.increased_stat
= relation(Stat
, primaryjoin
=Nature
.increased_stat_id
==Stat
.id,
1375 backref
='increasing_natures')
1376 Nature
.hates_flavor
= relation(ContestType
, primaryjoin
=Nature
.hates_flavor_id
==ContestType
.id,
1377 backref
='hating_natures')
1378 Nature
.likes_flavor
= relation(ContestType
, primaryjoin
=Nature
.likes_flavor_id
==ContestType
.id,
1379 backref
='liking_natures')
1380 Nature
.battle_style_preferences
= relation(NatureBattleStylePreference
,
1381 order_by
=NatureBattleStylePreference
.move_battle_style_id
,
1383 Nature
.pokeathlon_effects
= relation(NaturePokeathlonStat
, order_by
=NaturePokeathlonStat
.pokeathlon_stat_id
)
1385 NatureBattleStylePreference
.battle_style
= relation(MoveBattleStyle
, backref
='nature_preferences')
1387 NatureName
.language
= relation(Language
)
1389 NaturePokeathlonStat
.pokeathlon_stat
= relation(PokeathlonStat
, backref
='nature_effects')
1391 Pokedex
.region
= relation(Region
, backref
='pokedexes')
1392 Pokedex
.version_groups
= relation(VersionGroup
, secondary
=PokedexVersionGroup
.__table__
, backref
='pokedexes')
1394 Pokemon
.all_abilities
= relation(Ability
,
1395 secondary
=PokemonAbility
.__table__
,
1396 order_by
=PokemonAbility
.slot
,
1398 Pokemon
.abilities
= relation(Ability
,
1399 secondary
=PokemonAbility
.__table__
,
1401 Pokemon
.id == PokemonAbility
.pokemon_id
,
1402 PokemonAbility
.is_dream
== False,
1404 order_by
=PokemonAbility
.slot
,
1406 Pokemon
.dream_ability
= relation(Ability
,
1407 secondary
=PokemonAbility
.__table__
,
1409 Pokemon
.id == PokemonAbility
.pokemon_id
,
1410 PokemonAbility
.is_dream
== True,
1414 Pokemon
.pokemon_color
= relation(PokemonColor
, backref
='pokemon')
1415 Pokemon
.color
= association_proxy('pokemon_color', 'name')
1416 Pokemon
.dex_numbers
= relation(PokemonDexNumber
, order_by
=PokemonDexNumber
.pokedex_id
.asc(), backref
='pokemon')
1417 Pokemon
.egg_groups
= relation(EggGroup
, secondary
=PokemonEggGroup
.__table__
,
1418 order_by
=PokemonEggGroup
.egg_group_id
,
1420 Pokemon
.evolution_chain
= relation(EvolutionChain
, backref
='pokemon')
1421 Pokemon
.child_pokemon
= relation(Pokemon
,
1422 primaryjoin
=Pokemon
.id==PokemonEvolution
.from_pokemon_id
,
1423 secondary
=PokemonEvolution
.__table__
,
1424 secondaryjoin
=PokemonEvolution
.to_pokemon_id
==Pokemon
.id,
1425 backref
=backref('parent_pokemon', uselist
=False),
1427 Pokemon
.flavor_text
= relation(PokemonFlavorText
, order_by
=PokemonFlavorText
.version_id
.asc(), backref
='pokemon')
1428 Pokemon
.foreign_names
= relation(PokemonName
, backref
='pokemon')
1429 Pokemon
.forms
= relation(PokemonForm
, primaryjoin
=Pokemon
.id==PokemonForm
.form_base_pokemon_id
,
1430 order_by
=(PokemonForm
.order
.asc(), PokemonForm
.name
.asc()))
1431 Pokemon
.default_form
= relation(PokemonForm
,
1432 primaryjoin
=and_(Pokemon
.id==PokemonForm
.form_base_pokemon_id
, PokemonForm
.is_default
==True),
1435 Pokemon
.pokemon_habitat
= relation(PokemonHabitat
, backref
='pokemon')
1436 Pokemon
.habitat
= association_proxy('pokemon_habitat', 'name')
1437 Pokemon
.items
= relation(PokemonItem
, backref
='pokemon')
1438 Pokemon
.generation
= relation(Generation
, backref
='pokemon')
1439 Pokemon
.shape
= relation(PokemonShape
, backref
='pokemon')
1440 Pokemon
.stats
= relation(PokemonStat
, backref
='pokemon', order_by
=PokemonStat
.stat_id
.asc())
1441 Pokemon
.types
= relation(Type
, secondary
=PokemonType
.__table__
, order_by
=PokemonType
.slot
.asc(), backref
='pokemon')
1443 PokemonDexNumber
.pokedex
= relation(Pokedex
)
1445 PokemonEvolution
.from_pokemon
= relation(Pokemon
,
1446 primaryjoin
=PokemonEvolution
.from_pokemon_id
==Pokemon
.id,
1447 backref
='child_evolutions',
1449 PokemonEvolution
.to_pokemon
= relation(Pokemon
,
1450 primaryjoin
=PokemonEvolution
.to_pokemon_id
==Pokemon
.id,
1451 backref
=backref('parent_evolution', uselist
=False),
1453 PokemonEvolution
.child_evolutions
= relation(PokemonEvolution
,
1454 primaryjoin
=PokemonEvolution
.from_pokemon_id
==PokemonEvolution
.to_pokemon_id
,
1455 foreign_keys
=[PokemonEvolution
.to_pokemon_id
],
1456 backref
=backref('parent_evolution',
1457 remote_side
=[PokemonEvolution
.from_pokemon_id
],
1461 PokemonEvolution
.trigger
= relation(EvolutionTrigger
, backref
='evolutions')
1462 PokemonEvolution
.trigger_item
= relation(Item
,
1463 primaryjoin
=PokemonEvolution
.trigger_item_id
==Item
.id,
1464 backref
='triggered_evolutions',
1466 PokemonEvolution
.held_item
= relation(Item
,
1467 primaryjoin
=PokemonEvolution
.held_item_id
==Item
.id,
1468 backref
='required_for_evolutions',
1470 PokemonEvolution
.location
= relation(Location
, backref
='triggered_evolutions')
1471 PokemonEvolution
.known_move
= relation(Move
, backref
='triggered_evolutions')
1472 PokemonEvolution
.party_pokemon
= relation(Pokemon
,
1473 primaryjoin
=PokemonEvolution
.party_pokemon_id
==Pokemon
.id,
1474 backref
='triggered_evolutions',
1477 PokemonFlavorText
.version
= relation(Version
)
1479 PokemonForm
.form_base_pokemon
= relation(Pokemon
, primaryjoin
=PokemonForm
.form_base_pokemon_id
==Pokemon
.id)
1480 PokemonForm
.unique_pokemon
= relation(Pokemon
, backref
=backref('unique_form', uselist
=False),
1481 primaryjoin
=PokemonForm
.unique_pokemon_id
==Pokemon
.id)
1482 PokemonForm
.version_group
= relation(VersionGroup
)
1483 PokemonForm
.form_group
= association_proxy('form_base_pokemon', 'form_group')
1485 PokemonFormGroup
.pokemon
= relation(Pokemon
, backref
=backref('form_group',
1488 PokemonItem
.item
= relation(Item
, backref
='pokemon')
1489 PokemonItem
.version
= relation(Version
)
1491 PokemonMove
.pokemon
= relation(Pokemon
, backref
='pokemon_moves')
1492 PokemonMove
.version_group
= relation(VersionGroup
)
1493 PokemonMove
.machine
= relation(Machine
, backref
='pokemon_moves',
1494 primaryjoin
=and_(Machine
.version_group_id
==PokemonMove
.version_group_id
,
1495 Machine
.move_id
==PokemonMove
.move_id
),
1496 foreign_keys
=[Machine
.version_group_id
, Machine
.move_id
],
1498 PokemonMove
.move
= relation(Move
, backref
='pokemon_moves')
1499 PokemonMove
.method
= relation(PokemonMoveMethod
)
1501 PokemonName
.language
= relation(Language
)
1503 PokemonStat
.stat
= relation(Stat
)
1505 # This is technically a has-many; Generation.main_region_id -> Region.id
1506 Region
.generation
= relation(Generation
, uselist
=False)
1507 Region
.version_group_regions
= relation(VersionGroupRegion
, backref
='region',
1508 order_by
='VersionGroupRegion.version_group_id')
1509 Region
.version_groups
= association_proxy('version_group_regions', 'version_group')
1511 Stat
.damage_class
= relation(MoveDamageClass
, backref
='stats')
1513 SuperContestCombo
.first
= relation(Move
, primaryjoin
=SuperContestCombo
.first_move_id
==Move
.id,
1514 backref
='super_contest_combo_first')
1515 SuperContestCombo
.second
= relation(Move
, primaryjoin
=SuperContestCombo
.second_move_id
==Move
.id,
1516 backref
='super_contest_combo_second')
1518 Type
.damage_efficacies
= relation(TypeEfficacy
,
1520 ==TypeEfficacy
.damage_type_id
,
1521 backref
='damage_type')
1522 Type
.target_efficacies
= relation(TypeEfficacy
,
1524 ==TypeEfficacy
.target_type_id
,
1525 backref
='target_type')
1527 Type
.generation
= relation(Generation
, backref
='types')
1528 Type
.damage_class
= relation(MoveDamageClass
, backref
='types')
1529 Type
.foreign_names
= relation(TypeName
, backref
='type')
1531 TypeName
.language
= relation(Language
)
1533 Version
.version_group
= relation(VersionGroup
, backref
='versions')
1534 Version
.generation
= association_proxy('version_group', 'generation')
1536 VersionGroup
.generation
= relation(Generation
, backref
='version_groups')
1537 VersionGroup
.version_group_regions
= relation(VersionGroupRegion
, backref
='version_group')
1538 VersionGroup
.regions
= association_proxy('version_group_regions', 'region')