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 - ripped: True for text that has been ripped from the games, and can be ripped
19 again for new versions or languages
21 See `pokedex.db.multilang` for how localizable text columns work. The session
22 classes in that module can be used to change the default language.
24 # XXX: Check if "gametext" is set correctly everywhere
27 from functools
import partial
29 from sqlalchemy
import Column
, ForeignKey
, MetaData
, PrimaryKeyConstraint
, Table
, UniqueConstraint
30 from sqlalchemy
.ext
.declarative
import declarative_base
, DeclarativeMeta
31 from sqlalchemy
.ext
.associationproxy
import association_proxy
32 from sqlalchemy
.orm
import backref
, relation
33 from sqlalchemy
.orm
.session
import Session
34 from sqlalchemy
.orm
.interfaces
import AttributeExtension
35 from sqlalchemy
.sql
import and_
36 from sqlalchemy
.schema
import ColumnDefault
37 from sqlalchemy
.types
import *
39 from pokedex
.db
import markdown
, multilang
41 class TableSuperclass(object):
42 """Superclass for declarative tables, to give them some generic niceties
45 def __unicode__(self
):
46 """Be as useful as possible. Show the primary key, and an identifier
49 typename
= u
'.'.join((__name__
, type(self
).__name__
))
51 pk_constraint
= self
.__table__
.primary_key
53 return u
"<%s object at %x>" %
(typename
, id(self
))
55 pk
= u
', '.join(unicode(getattr(self
, column
.name
))
56 for column
in pk_constraint
.columns
)
58 return u
"<%s object (%s): %s>" %
(typename
, pk
, self
.identifier
)
59 except AttributeError:
60 return u
"<%s object (%s)>" %
(typename
, pk
)
63 return unicode(self
).encode('utf8')
66 return unicode(self
).encode('utf8')
69 class TableMetaclass(DeclarativeMeta
):
70 def __init__(cls
, name
, bases
, attrs
):
71 super(TableMetaclass
, cls
).__init__(name
, bases
, attrs
)
72 if hasattr(cls
, '__tablename__'):
73 mapped_classes
.append(cls
)
74 cls
.translation_classes
= []
77 TableBase
= declarative_base(metadata
=metadata
, cls
=TableSuperclass
, metaclass
=TableMetaclass
)
80 ### Need Language first, to create the partial() below
82 class Language(TableBase
):
83 u
"""A language the Pokémon games have been translated into
85 __tablename__
= 'languages'
86 __singlename__
= 'language'
87 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
88 info
=dict(description
="A numeric ID"))
89 iso639
= Column(Unicode(2), nullable
=False,
90 info
=dict(description
="The two-letter code of the country where this language is spoken. Note that it is not unique.", format
='identifier'))
91 iso3166
= Column(Unicode(2), nullable
=False,
92 info
=dict(description
="The two-letter code of the language. Note that it is not unique.", format
='identifier'))
93 identifier
= Column(Unicode(16), nullable
=False,
94 info
=dict(description
="An identifier", format
='identifier'))
95 official
= Column(Boolean
, nullable
=False, index
=True,
96 info
=dict(description
=u
"True iff games are produced in the language."))
97 order
= Column(Integer
, nullable
=True,
98 info
=dict(description
=u
"Order for sorting in foreign name lists."))
100 create_translation_table
= partial(multilang
.create_translation_table
, language_class
=Language
)
102 create_translation_table('language_names', Language
, 'names',
103 name
= Column(Unicode(16), nullable
=False, index
=True,
104 info
=dict(description
="The name", format
='plaintext', official
=True)),
107 ### The actual tables
109 class Ability(TableBase
):
110 u
"""An ability a Pokémon can have, such as Static or Pressure.
112 __tablename__
= 'abilities'
113 __singlename__
= 'ability'
114 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
115 info
=dict(description
="This ability's unique ID; matches the games' internal ID"))
116 identifier
= Column(Unicode(24), nullable
=False,
117 info
=dict(description
="An identifier", format
='identifier'))
118 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
119 info
=dict(description
="The ID of the generation this ability was introduced in", detail
=True))
121 create_translation_table('ability_names', Ability
, 'names',
122 relation_lazy
='joined',
123 name
= Column(Unicode(24), nullable
=False, index
=True,
124 info
=dict(description
="The name", format
='plaintext', official
=True, ripped
=True)),
126 create_translation_table('ability_prose', Ability
, 'prose',
127 effect
= Column(markdown
.MarkdownColumn(5120), nullable
=True,
128 info
=dict(description
="A detailed description of this ability's effect", format
='markdown')),
129 short_effect
= Column(markdown
.MarkdownColumn(255), nullable
=True,
130 info
=dict(description
="A short summary of this ability's effect", format
='markdown')),
133 class AbilityChangelog(TableBase
):
134 """History of changes to abilities across main game versions."""
135 __tablename__
= 'ability_changelog'
136 __singlename__
= 'ability_changelog'
137 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
138 info
=dict(description
="This change's unique ID"))
139 ability_id
= Column(Integer
, ForeignKey('abilities.id'), nullable
=False,
140 info
=dict(description
="The ID of the ability that changed"))
141 changed_in_version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False,
142 info
=dict(description
="The ID of the version group in which the ability changed"))
144 create_translation_table('ability_changelog_prose', AbilityChangelog
, 'prose',
145 effect
= Column(markdown
.MarkdownColumn(255), nullable
=False,
146 info
=dict(description
="A description of the old behavior", format
='markdown'))
149 class AbilityFlavorText(TableBase
):
150 u
"""In-game flavor text of an ability
152 __tablename__
= 'ability_flavor_text'
153 ability_id
= Column(Integer
, ForeignKey('abilities.id'), primary_key
=True, nullable
=False, autoincrement
=False,
154 info
=dict(description
="The ID of the ability"))
155 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
156 info
=dict(description
="The ID of the version group this flavor text is taken from"))
157 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
158 info
=dict(description
="The language"))
159 flavor_text
= Column(Unicode(64), nullable
=False,
160 info
=dict(description
="The actual flavor text", official
=True, format
='gametext'))
162 class Berry(TableBase
):
163 u
"""A Berry, consumable item that grows on trees
165 For data common to all items, such as the name, see the corresponding item entry.
167 __tablename__
= 'berries'
168 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
169 info
=dict(description
="This Berry's in-game number"))
170 item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=False,
171 info
=dict(description
="The ID of the item that represents this Berry"))
172 firmness_id
= Column(Integer
, ForeignKey('berry_firmness.id'), nullable
=False,
173 info
=dict(description
="The ID of this Berry's firmness category"))
174 natural_gift_power
= Column(Integer
, nullable
=True,
175 info
=dict(description
="Natural Gift's power when used with this Berry"))
176 natural_gift_type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=True,
177 info
=dict(description
="The ID of the Type that Natural Gift has when used with this Berry"))
178 size
= Column(Integer
, nullable
=False,
179 info
=dict(description
=u
"The size of this Berry, in millimeters"))
180 max_harvest
= Column(Integer
, nullable
=False,
181 info
=dict(description
="The maximum number of these berries that can grow on one tree in Generation IV"))
182 growth_time
= Column(Integer
, nullable
=False,
183 info
=dict(description
="Time it takes the tree to grow one stage, in hours. Berry trees go through four of these growth stages before they can be picked."))
184 soil_dryness
= Column(Integer
, nullable
=False,
185 info
=dict(description
="The speed at which this Berry dries out the soil as it grows. A higher rate means the soil dries more quickly."))
186 smoothness
= Column(Integer
, nullable
=False,
187 info
=dict(description
="The smoothness of this Berry, used in making Pokéblocks or Poffins"))
189 class BerryFirmness(TableBase
):
190 u
"""A Berry firmness, such as "hard" or "very soft".
192 __tablename__
= 'berry_firmness'
193 __singlename__
= 'berry_firmness'
194 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
195 info
=dict(description
="A unique ID for this firmness"))
196 identifier
= Column(Unicode(10), nullable
=False,
197 info
=dict(description
="An identifier", format
='identifier'))
199 create_translation_table('berry_firmness_names', BerryFirmness
, 'names',
200 relation_lazy
='joined',
201 name
= Column(Unicode(10), nullable
=False, index
=True,
202 info
=dict(description
="The name", format
='plaintext', official
=True)),
205 class BerryFlavor(TableBase
):
206 u
"""A Berry flavor level.
208 __tablename__
= 'berry_flavors'
209 berry_id
= Column(Integer
, ForeignKey('berries.id'), primary_key
=True, nullable
=False, autoincrement
=False,
210 info
=dict(description
="The ID of the berry"))
211 contest_type_id
= Column(Integer
, ForeignKey('contest_types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
212 info
=dict(description
="The ID of the flavor"))
213 flavor
= Column(Integer
, nullable
=False,
214 info
=dict(description
="The level of the flavor in the berry"))
216 class ContestCombo(TableBase
):
217 u
"""Combo of two moves in a Contest.
219 __tablename__
= 'contest_combos'
220 first_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
221 info
=dict(description
="The ID of the first move in the combo"))
222 second_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
223 info
=dict(description
="The ID of the second and final move in the combo"))
225 class ContestEffect(TableBase
):
226 u
"""Effect of a move when used in a Contest.
228 __tablename__
= 'contest_effects'
229 __singlename__
= 'contest_effect'
230 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
231 info
=dict(description
="A unique ID for this effect"))
232 appeal
= Column(SmallInteger
, nullable
=False,
233 info
=dict(description
="The base number of hearts the user of this move gets"))
234 jam
= Column(SmallInteger
, nullable
=False,
235 info
=dict(description
="The base number of hearts the user's opponent loses"))
237 create_translation_table('contest_effect_prose', ContestEffect
, 'prose',
238 flavor_text
= Column(Unicode(64), nullable
=True,
239 info
=dict(description
="The in-game description of this effect", official
=True, format
='gametext')),
240 effect
= Column(Unicode(255), nullable
=True,
241 info
=dict(description
="A detailed description of the effect", format
='plaintext')),
244 class ContestType(TableBase
):
245 u
"""A Contest type, such as "cool" or "smart", and their associated Berry flavors and Pokéblock colors.
247 __tablename__
= 'contest_types'
248 __singlename__
= 'contest_type'
249 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
250 info
=dict(description
="A unique ID for this Contest type"))
251 identifier
= Column(Unicode(6), nullable
=False,
252 info
=dict(description
="An identifier", format
='identifier'))
254 create_translation_table('contest_type_names', ContestType
, 'names',
255 relation_lazy
='joined',
256 name
= Column(Unicode(6), nullable
=True, index
=True,
257 info
=dict(description
="The name", format
='plaintext', official
=True)),
258 flavor
= Column(Unicode(6), nullable
=True,
259 info
=dict(description
="The name of the corresponding Berry flavor", official
=True, format
='plaintext')),
260 color
= Column(Unicode(6), nullable
=True,
261 info
=dict(description
=u
"The name of the corresponding Pokéblock color", official
=True, format
='plaintext')),
264 class EggGroup(TableBase
):
265 u
"""An Egg group. Usually, two Pokémon can breed if they share an Egg Group.
267 (exceptions are the Ditto and No Eggs groups)
269 __tablename__
= 'egg_groups'
270 __singlename__
= 'egg_group'
271 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
272 info
=dict(description
="A unique ID for this group"))
273 identifier
= Column(Unicode(16), nullable
=False,
274 info
=dict(description
=u
"An identifier.", format
='identifier'))
276 create_translation_table('egg_group_prose', EggGroup
, 'names',
277 relation_lazy
='joined',
278 name
= Column(Unicode(16), nullable
=False, index
=True,
279 info
=dict(description
="The name", format
='plaintext', official
=True)),
282 class Encounter(TableBase
):
283 u
"""Encounters with wild Pokémon.
287 Within a given area in a given game, encounters are differentiated by the
288 "slot" they are in and the state of the game world.
290 What the player is doing to get an encounter, such as surfing or walking
291 through tall grass, is called terrain. Each terrain has its own set of
294 Within a terrain, slots are defined primarily by rarity. Each slot can
295 also be affected by world conditions; for example, the 20% slot for walking
296 in tall grass is affected by whether a swarm is in effect in that area.
297 "Is there a swarm?" is a condition; "there is a swarm" and "there is not a
298 swarm" are the possible values of this condition.
300 A slot (20% walking in grass) and any appropriate world conditions (no
301 swarm) are thus enough to define a specific encounter.
303 Well, okay, almost: each slot actually appears twice.
306 __tablename__
= 'encounters'
307 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
308 info
=dict(description
="A unique ID for this encounter"))
309 version_id
= Column(Integer
, ForeignKey('versions.id'), nullable
=False, autoincrement
=False,
310 info
=dict(description
="The ID of the version this applies to"))
311 location_area_id
= Column(Integer
, ForeignKey('location_areas.id'), nullable
=False, autoincrement
=False,
312 info
=dict(description
="The ID of the location of this encounter"))
313 encounter_slot_id
= Column(Integer
, ForeignKey('encounter_slots.id'), nullable
=False, autoincrement
=False,
314 info
=dict(description
="The ID of the encounter slot, which determines terrain and rarity"))
315 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False, autoincrement
=False,
316 info
=dict(description
=u
"The ID of the encountered Pokémon"))
317 min_level
= Column(Integer
, nullable
=False, autoincrement
=False,
318 info
=dict(description
=u
"The minimum level of the encountered Pokémon"))
319 max_level
= Column(Integer
, nullable
=False, autoincrement
=False,
320 info
=dict(description
=u
"The maxmum level of the encountered Pokémon"))
322 class EncounterCondition(TableBase
):
323 u
"""A conditions in the game world that affects Pokémon encounters, such as time of day.
326 __tablename__
= 'encounter_conditions'
327 __singlename__
= 'encounter_condition'
328 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
329 info
=dict(description
="A unique ID for this condition"))
330 identifier
= Column(Unicode(64), nullable
=False,
331 info
=dict(description
="An identifier", format
='identifier'))
333 create_translation_table('encounter_condition_prose', EncounterCondition
, 'prose',
334 name
= Column(Unicode(64), nullable
=False, index
=True,
335 info
=dict(description
="The name", format
='plaintext', official
=False)),
338 class EncounterConditionValue(TableBase
):
339 u
"""A possible state for a condition; for example, the state of 'swarm' could be 'swarm' or 'no swarm'.
342 __tablename__
= 'encounter_condition_values'
343 __singlename__
= 'encounter_condition_value'
344 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
345 info
=dict(description
="A numeric ID"))
346 encounter_condition_id
= Column(Integer
, ForeignKey('encounter_conditions.id'), primary_key
=False, nullable
=False, autoincrement
=False,
347 info
=dict(description
="The ID of the encounter condition this is a value of"))
348 identifier
= Column(Unicode(64), nullable
=False,
349 info
=dict(description
="An identifier", format
='identifier'))
350 is_default
= Column(Boolean
, nullable
=False,
351 info
=dict(description
='Set if this value is the default state for the condition'))
353 create_translation_table('encounter_condition_value_prose', EncounterConditionValue
, 'prose',
354 name
= Column(Unicode(64), nullable
=False, index
=True,
355 info
=dict(description
="The name", format
='plaintext', official
=False)),
358 class EncounterConditionValueMap(TableBase
):
359 u
"""Maps encounters to the specific conditions under which they occur.
361 __tablename__
= 'encounter_condition_value_map'
362 encounter_id
= Column(Integer
, ForeignKey('encounters.id'), primary_key
=True, nullable
=False, autoincrement
=False,
363 info
=dict(description
="The ID of the encounter"))
364 encounter_condition_value_id
= Column(Integer
, ForeignKey('encounter_condition_values.id'), primary_key
=True, nullable
=False, autoincrement
=False,
365 info
=dict(description
="The ID of the encounter condition value"))
367 class EncounterSlot(TableBase
):
368 u
"""An abstract "slot" within a terrain, associated with both some set of conditions and a rarity.
370 Note that there are two encounters per slot, so the rarities will only add
374 __tablename__
= 'encounter_slots'
375 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
376 info
=dict(description
="A unique ID for this slot"))
377 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False, autoincrement
=False,
378 info
=dict(description
="The ID of the version group this slot is in"))
379 encounter_terrain_id
= Column(Integer
, ForeignKey('encounter_terrain.id'), primary_key
=False, nullable
=False, autoincrement
=False,
380 info
=dict(description
="The ID of the terrain"))
381 slot
= Column(Integer
, nullable
=True,
382 info
=dict(description
="This slot's order for the location and terrain"))
383 rarity
= Column(Integer
, nullable
=False,
384 info
=dict(description
="The chance of the encounter as a percentage"))
386 class EncounterTerrain(TableBase
):
387 u
"""A way the player can enter a wild encounter, e.g., surfing, fishing, or walking through tall grass.
390 __tablename__
= 'encounter_terrain'
391 __singlename__
= __tablename__
392 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
393 info
=dict(description
="A unique ID for the terrain"))
394 identifier
= Column(Unicode(64), nullable
=False,
395 info
=dict(description
="An identifier", format
='identifier'))
397 create_translation_table('encounter_terrain_prose', EncounterTerrain
, 'prose',
398 name
= Column(Unicode(64), nullable
=False, index
=True,
399 info
=dict(description
="The name", format
='plaintext', official
=False)),
402 class EvolutionChain(TableBase
):
403 u
"""A family of Pokémon that are linked by evolution
405 __tablename__
= 'evolution_chains'
406 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
407 info
=dict(description
="A numeric ID"))
408 growth_rate_id
= Column(Integer
, ForeignKey('growth_rates.id'), nullable
=False,
409 info
=dict(description
="ID of the growth rate for this family"))
410 baby_trigger_item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=True,
411 info
=dict(description
="Item that a parent must hold while breeding to produce a baby"))
413 class EvolutionTrigger(TableBase
):
414 u
"""An evolution type, such as "level" or "trade".
416 __tablename__
= 'evolution_triggers'
417 __singlename__
= 'evolution_trigger'
418 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
419 info
=dict(description
="A numeric ID"))
420 identifier
= Column(Unicode(16), nullable
=False,
421 info
=dict(description
="An identifier", format
='identifier'))
423 create_translation_table('evolution_trigger_prose', EvolutionTrigger
, 'prose',
424 name
= Column(Unicode(16), nullable
=False, index
=True,
425 info
=dict(description
="The name", format
='plaintext', official
=False)),
428 class Experience(TableBase
):
429 u
"""EXP needed for a certain level with a certain growth rate
431 __tablename__
= 'experience'
432 growth_rate_id
= Column(Integer
, ForeignKey('growth_rates.id'), primary_key
=True, nullable
=False, autoincrement
=False,
433 info
=dict(description
="ID of the growth rate"))
434 level
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
435 info
=dict(description
="The level"))
436 experience
= Column(Integer
, nullable
=False,
437 info
=dict(description
="The number of EXP points needed to get to that level"))
439 class Generation(TableBase
):
440 u
"""A Generation of the Pokémon franchise
442 __tablename__
= 'generations'
443 __singlename__
= 'generation'
444 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
445 info
=dict(description
="A numeric ID"))
446 main_region_id
= Column(Integer
, ForeignKey('regions.id'), nullable
=False,
447 info
=dict(description
="ID of the region this generation's main games take place in"))
448 canonical_pokedex_id
= Column(Integer
, ForeignKey('pokedexes.id'), nullable
=False,
449 info
=dict(description
=u
"ID of the Pokédex this generation's main games use by default"))
450 identifier
= Column(Unicode(16), nullable
=False,
451 info
=dict(description
=u
'An identifier', format
='identifier'))
453 create_translation_table('generation_names', Generation
, 'names',
454 relation_lazy
='joined',
455 name
= Column(Unicode(16), nullable
=False, index
=True,
456 info
=dict(description
="The name", format
='plaintext', official
=True)),
459 class GrowthRate(TableBase
):
460 u
"""Growth rate of a Pokémon, i.e. the EXP → level function.
462 __tablename__
= 'growth_rates'
463 __singlename__
= 'growth_rate'
464 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
465 info
=dict(description
="A numeric ID"))
466 identifier
= Column(Unicode(20), nullable
=False,
467 info
=dict(description
="An identifier", format
='identifier'))
468 formula
= Column(Unicode(500), nullable
=False,
469 info
=dict(description
="The formula", format
='latex'))
471 create_translation_table('growth_rate_prose', GrowthRate
, 'prose',
472 name
= Column(Unicode(20), nullable
=False, index
=True,
473 info
=dict(description
="The name", format
='plaintext', official
=False)),
476 class Item(TableBase
):
477 u
"""An Item from the games, like "Poké Ball" or "Bicycle".
479 __tablename__
= 'items'
480 __singlename__
= 'item'
481 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
482 info
=dict(description
="A numeric ID"))
483 identifier
= Column(Unicode(20), nullable
=False,
484 info
=dict(description
="An identifier", format
='identifier'))
485 category_id
= Column(Integer
, ForeignKey('item_categories.id'), nullable
=False,
486 info
=dict(description
="ID of a category this item belongs to"))
487 cost
= Column(Integer
, nullable
=False,
488 info
=dict(description
=u
"Cost of the item when bought. Items sell for half this price."))
489 fling_power
= Column(Integer
, nullable
=True,
490 info
=dict(description
=u
"Power of the move Fling when used with this item."))
491 fling_effect_id
= Column(Integer
, ForeignKey('item_fling_effects.id'), nullable
=True,
492 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."))
495 def appears_underground(self
):
496 u
"""True if the item appears underground, as specified by the appropriate flag
498 return any(flag
.identifier
== u
'underground' for flag
in self
.flags
)
500 create_translation_table('item_names', Item
, 'names',
501 relation_lazy
='joined',
502 name
= Column(Unicode(20), nullable
=False, index
=True,
503 info
=dict(description
="The name", format
='plaintext', official
=True, ripped
=True)),
505 create_translation_table('item_prose', Item
, 'prose',
506 short_effect
= Column(markdown
.MarkdownColumn(256), nullable
=True,
507 info
=dict(description
="A short summary of the effect", format
='markdown')),
508 effect
= Column(markdown
.MarkdownColumn(5120), nullable
=True,
509 info
=dict(description
=u
"Detailed description of the item's effect.", format
='markdown')),
511 create_translation_table('item_flavor_summaries', Item
, 'flavor_summaries',
512 flavor_summary
= Column(Unicode(512), nullable
=True,
513 info
=dict(description
=u
"Text containing facts from all flavor texts, for languages without official game translations", official
=False, format
='plaintext', ripped
=True)),
516 class ItemCategory(TableBase
):
519 # XXX: This is fanon, right?
520 __tablename__
= 'item_categories'
521 __singlename__
= 'item_category'
522 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
523 info
=dict(description
="A numeric ID"))
524 pocket_id
= Column(Integer
, ForeignKey('item_pockets.id'), nullable
=False,
525 info
=dict(description
="ID of the pocket these items go to"))
526 identifier
= Column(Unicode(16), nullable
=False,
527 info
=dict(description
="An identifier", format
='identifier'))
529 create_translation_table('item_category_prose', ItemCategory
, 'prose',
530 relation_lazy
='joined',
531 name
= Column(Unicode(16), nullable
=False, index
=True,
532 info
=dict(description
="The name", format
='plaintext', official
=False)),
535 class ItemFlag(TableBase
):
536 u
"""An item attribute such as "consumable" or "holdable".
538 __tablename__
= 'item_flags'
539 __singlename__
= 'item_flag'
540 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
541 info
=dict(description
="A numeric ID"))
542 identifier
= Column(Unicode(24), nullable
=False,
543 info
=dict(description
="Identifier of the flag", format
='identifier'))
545 create_translation_table('item_flag_prose', ItemFlag
, 'prose',
546 name
= Column(Unicode(24), nullable
=True, index
=True,
547 info
=dict(description
="The name", format
='plaintext', official
=False)),
548 description
= Column(Unicode(64), nullable
=True,
549 info
=dict(description
="Short description of the flag", format
='plaintext')),
552 class ItemFlagMap(TableBase
):
553 u
"""Maps an item flag to its item.
555 __tablename__
= 'item_flag_map'
556 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, autoincrement
=False, nullable
=False,
557 info
=dict(description
="The ID of the item"))
558 item_flag_id
= Column(Integer
, ForeignKey('item_flags.id'), primary_key
=True, autoincrement
=False, nullable
=False,
559 info
=dict(description
="The ID of the item flag"))
561 class ItemFlavorText(TableBase
):
562 u
"""An in-game description of an item
564 __tablename__
= 'item_flavor_text'
565 __singlename__
= 'item_flavor_text'
566 summary_column
= Item
.flavor_summaries_table
, 'flavor_summary'
567 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, autoincrement
=False, nullable
=False,
568 info
=dict(description
="The ID of the item"))
569 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, autoincrement
=False, nullable
=False,
570 info
=dict(description
="ID of the version group that sports this text"))
571 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
572 info
=dict(description
="The language"))
573 flavor_text
= Column(Unicode(255), nullable
=False,
574 info
=dict(description
="The flavor text itself", official
=True, format
='gametext'))
576 class ItemFlingEffect(TableBase
):
577 u
"""An effect of the move Fling when used with a specific item
579 __tablename__
= 'item_fling_effects'
580 __singlename__
= 'item_fling_effect'
581 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
582 info
=dict(description
="A numeric ID"))
584 create_translation_table('item_fling_effect_prose', ItemFlingEffect
, 'prose',
585 effect
= Column(Unicode(255), nullable
=False,
586 info
=dict(description
="Description of the effect", format
='plaintext')),
589 class ItemGameIndex(TableBase
):
590 u
"""The internal ID number a game uses for an item
592 __tablename__
= 'item_game_indices'
593 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, autoincrement
=False, nullable
=False,
594 info
=dict(description
="The database ID of the item"))
595 generation_id
= Column(Integer
, ForeignKey('generations.id'), primary_key
=True, autoincrement
=False, nullable
=False,
596 info
=dict(description
="ID of the generation of games"))
597 game_index
= Column(Integer
, nullable
=False,
598 info
=dict(description
="Internal ID of the item in the generation"))
600 class ItemPocket(TableBase
):
601 u
"""A pocket that categorizes items
603 __tablename__
= 'item_pockets'
604 __singlename__
= 'item_pocket'
605 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
606 info
=dict(description
="A numeric ID"))
607 identifier
= Column(Unicode(16), nullable
=False,
608 info
=dict(description
="An identifier of this pocket", format
='identifier'))
610 create_translation_table('item_pocket_names', ItemPocket
, 'names',
611 relation_lazy
='joined',
612 name
= Column(Unicode(16), nullable
=False, index
=True,
613 info
=dict(description
="The name", format
='plaintext', official
=True)),
616 class Location(TableBase
):
617 u
"""A place in the Pokémon world
619 __tablename__
= 'locations'
620 __singlename__
= 'location'
621 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
622 info
=dict(description
="A numeric ID"))
623 region_id
= Column(Integer
, ForeignKey('regions.id'),
624 info
=dict(description
="ID of the region this location is in"))
625 identifier
= Column(Unicode(64), nullable
=False,
626 info
=dict(description
="An identifier", format
='identifier'))
628 create_translation_table('location_names', Location
, 'names',
629 relation_lazy
='joined',
630 name
= Column(Unicode(64), nullable
=False, index
=True,
631 info
=dict(description
="The name", format
='plaintext', official
=True)),
634 class LocationArea(TableBase
):
635 u
"""A sub-area of a location
637 __tablename__
= 'location_areas'
638 __singlename__
= 'location_area'
639 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
640 info
=dict(description
="A numeric ID"))
641 location_id
= Column(Integer
, ForeignKey('locations.id'), nullable
=False,
642 info
=dict(description
="ID of the location this area is part of"))
643 game_index
= Column(Integer
, nullable
=False,
644 info
=dict(description
="ID the games ude for this area"))
645 identifier
= Column(Unicode(64), nullable
=True,
646 info
=dict(description
="An identifier", format
='identifier'))
648 create_translation_table('location_area_prose', LocationArea
, 'prose',
649 relation_lazy
='joined',
650 name
= Column(Unicode(64), nullable
=False, index
=True,
651 info
=dict(description
="The name", format
='plaintext', official
=False)),
654 class LocationAreaEncounterRate(TableBase
):
655 # XXX: What's this exactly? Someone add the docstring & revise the descriptions
656 __tablename__
= 'location_area_encounter_rates'
657 location_area_id
= Column(Integer
, ForeignKey('location_areas.id'), primary_key
=True, nullable
=False, autoincrement
=False,
658 info
=dict(description
="ID of the area"))
659 encounter_terrain_id
= Column(Integer
, ForeignKey('encounter_terrain.id'), primary_key
=True, nullable
=False, autoincrement
=False,
660 info
=dict(description
="ID of the terrain"))
661 version_id
= Column(Integer
, ForeignKey('versions.id'), primary_key
=True, autoincrement
=False,
662 info
=dict(description
="ID of the version"))
663 rate
= Column(Integer
, nullable
=True,
664 info
=dict(description
="The encounter rate")) # units?
666 class LocationGameIndex(TableBase
):
667 u
"""IDs the games use internally for locations
669 __tablename__
= 'location_game_indices'
670 location_id
= Column(Integer
, ForeignKey('locations.id'), nullable
=False, primary_key
=True, autoincrement
=False,
671 info
=dict(description
="Database ID of the locaion"))
672 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False, primary_key
=True, autoincrement
=False,
673 info
=dict(description
="ID of the generation this entry to"))
674 game_index
= Column(Integer
, nullable
=False,
675 info
=dict(description
="Internal game ID of the location"))
677 class Machine(TableBase
):
678 u
"""A TM or HM; numbered item that can teach a move to a Pokémon
680 __tablename__
= 'machines'
681 machine_number
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
682 info
=dict(description
="Number of the machine for TMs, or 100 + the munber for HMs"))
683 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
684 info
=dict(description
="Versions this entry applies to"))
685 item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=False,
686 info
=dict(description
="ID of the corresponding Item"))
687 move_id
= Column(Integer
, ForeignKey('moves.id'), nullable
=False,
688 info
=dict(description
="ID of the taught move"))
692 u
"""True if this machine is a HM, False if it's a TM
694 return self
.machine_number
>= 100
696 class Move(TableBase
):
697 u
"""A Move: technique or attack a Pokémon can learn to use
699 __tablename__
= 'moves'
700 __singlename__
= 'move'
701 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
702 info
=dict(description
="A numeric ID"))
703 identifier
= Column(Unicode(24), nullable
=False,
704 info
=dict(description
="An identifier", format
='identifier'))
705 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
706 info
=dict(description
="ID of the generation this move first appeared in"))
707 type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=False,
708 info
=dict(description
="ID of the move's elemental type"))
709 power
= Column(SmallInteger
, nullable
=False,
710 info
=dict(description
="Base power of the move"))
711 pp
= Column(SmallInteger
, nullable
=True,
712 info
=dict(description
="Base PP (Power Points) of the move, nullable if not applicable (e.g. Struggle and Shadow moves)."))
713 accuracy
= Column(SmallInteger
, nullable
=True,
714 info
=dict(description
="Accuracy of the move; NULL means it never misses"))
715 priority
= Column(SmallInteger
, nullable
=False,
716 info
=dict(description
="The move's priority bracket"))
717 target_id
= Column(Integer
, ForeignKey('move_targets.id'), nullable
=False,
718 info
=dict(description
="ID of the target (range) of the move"))
719 damage_class_id
= Column(Integer
, ForeignKey('move_damage_classes.id'), nullable
=False,
720 info
=dict(description
="ID of the damage class (physical/special) of the move"))
721 effect_id
= Column(Integer
, ForeignKey('move_effects.id'), nullable
=False,
722 info
=dict(description
="ID of the move's effect"))
723 effect_chance
= Column(Integer
, nullable
=True,
724 info
=dict(description
="The chance for a secondary effect. What this is a chance of is specified by the move's effect."))
725 contest_type_id
= Column(Integer
, ForeignKey('contest_types.id'), nullable
=True,
726 info
=dict(description
="ID of the move's Contest type (e.g. cool or smart)"))
727 contest_effect_id
= Column(Integer
, ForeignKey('contest_effects.id'), nullable
=True,
728 info
=dict(description
="ID of the move's Contest effect"))
729 super_contest_effect_id
= Column(Integer
, ForeignKey('super_contest_effects.id'), nullable
=True,
730 info
=dict(description
="ID of the move's Super Contest effect"))
732 create_translation_table('move_names', Move
, 'names',
733 relation_lazy
='joined',
734 name
= Column(Unicode(24), nullable
=False, index
=True,
735 info
=dict(description
="The name", format
='plaintext', official
=True, ripped
=True))
737 create_translation_table('move_flavor_summaries', Move
, 'flavor_summaries',
738 flavor_summary
= Column(Unicode(512), nullable
=True,
739 info
=dict(description
=u
"Text containing facts from all flavor texts, for languages without official game translations", official
=False, format
='plaintext', ripped
=True)),
742 class MoveBattleStyle(TableBase
):
743 u
"""A battle style of a move""" # XXX: Explain better
744 __tablename__
= 'move_battle_styles'
745 __singlename__
= 'move_battle_style'
746 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
747 info
=dict(description
="A numeric ID"))
748 identifier
= Column(Unicode(8), nullable
=False,
749 info
=dict(description
="An identifier", format
='identifier'))
751 create_translation_table('move_battle_style_prose', MoveBattleStyle
, 'prose',
752 relation_lazy
='joined',
753 name
= Column(Unicode(8), nullable
=False, index
=True,
754 info
=dict(description
="The name", format
='plaintext', official
=False)),
757 class MoveChangelog(TableBase
):
758 """History of changes to moves across main game versions."""
759 __tablename__
= 'move_changelog'
760 __singlename__
= 'move_changelog'
761 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
762 info
=dict(description
="ID of the move that changed"))
763 changed_in_version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
764 info
=dict(description
="ID of the version group in which the move changed"))
765 type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=True,
766 info
=dict(description
="Prior type of the move, or NULL if unchanged"))
767 power
= Column(SmallInteger
, nullable
=True,
768 info
=dict(description
="Prior base power of the move, or NULL if unchanged"))
769 pp
= Column(SmallInteger
, nullable
=True,
770 info
=dict(description
="Prior base PP of the move, or NULL if unchanged"))
771 accuracy
= Column(SmallInteger
, nullable
=True,
772 info
=dict(description
="Prior accuracy of the move, or NULL if unchanged"))
773 effect_id
= Column(Integer
, ForeignKey('move_effects.id'), nullable
=True,
774 info
=dict(description
="Prior ID of the effect, or NULL if unchanged"))
775 effect_chance
= Column(Integer
, nullable
=True,
776 info
=dict(description
="Prior effect chance, or NULL if unchanged"))
778 class MoveDamageClass(TableBase
):
779 u
"""Any of the damage classes moves can have, i.e. physical, special, or non-damaging.
781 __tablename__
= 'move_damage_classes'
782 __singlename__
= 'move_damage_class'
783 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
784 info
=dict(description
="A numeric ID"))
785 identifier
= Column(Unicode(16), nullable
=False,
786 info
=dict(description
="An identifier", format
='identifier'))
788 create_translation_table('move_damage_class_prose', MoveDamageClass
, 'prose',
789 relation_lazy
='joined',
790 name
= Column(Unicode(16), nullable
=True, index
=True,
791 info
=dict(description
="The name", format
='plaintext', official
=False)),
792 description
= Column(Unicode(64), nullable
=True,
793 info
=dict(description
="A description of the class", format
='plaintext')),
796 class MoveEffect(TableBase
):
797 u
"""An effect of a move
799 __tablename__
= 'move_effects'
800 __singlename__
= 'move_effect'
801 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
802 info
=dict(description
="A numeric ID"))
804 create_translation_table('move_effect_prose', MoveEffect
, 'prose',
805 short_effect
= Column(Unicode(256), nullable
=True,
806 info
=dict(description
="A short summary of the effect", format
='plaintext')),
807 effect
= Column(Unicode(5120), nullable
=True,
808 info
=dict(description
="A detailed description of the effect", format
='plaintext')),
811 class MoveEffectCategory(TableBase
):
812 u
"""Category of a move effect
814 __tablename__
= 'move_effect_categories'
815 __singlename__
= 'move_effect_category'
816 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
817 info
=dict(description
="A numeric ID"))
818 identifier
= Column(Unicode(64), nullable
=False,
819 info
=dict(description
="An identifier", format
='identifier'))
820 can_affect_user
= Column(Boolean
, nullable
=False,
821 info
=dict(description
="Set if the user can be affected"))
823 create_translation_table('move_effect_category_prose', MoveEffectCategory
, 'prose',
824 name
= Column(Unicode(64), nullable
=False, index
=True,
825 info
=dict(description
="The name", format
='plaintext', official
=False)),
828 class MoveEffectCategoryMap(TableBase
):
829 u
"""Maps a move effect category to a move effect
831 __tablename__
= 'move_effect_category_map'
832 move_effect_id
= Column(Integer
, ForeignKey('move_effects.id'), primary_key
=True, nullable
=False, autoincrement
=False,
833 info
=dict(description
="ID of the move effect"))
834 move_effect_category_id
= Column(Integer
, ForeignKey('move_effect_categories.id'), primary_key
=True, nullable
=False, autoincrement
=False,
835 info
=dict(description
="ID of the category"))
836 affects_user
= Column(Boolean
, primary_key
=True, nullable
=False, autoincrement
=False,
837 info
=dict(description
="Set if the user is affected"))
839 class MoveEffectChangelog(TableBase
):
840 """History of changes to move effects across main game versions."""
841 __tablename__
= 'move_effect_changelog'
842 __singlename__
= 'move_effect_changelog'
843 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
844 info
=dict(description
="A numeric ID"))
845 effect_id
= Column(Integer
, ForeignKey('move_effects.id'), nullable
=False,
846 info
=dict(description
="The ID of the effect that changed"))
847 changed_in_version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False,
848 info
=dict(description
="The ID of the version group in which the effect changed"))
851 UniqueConstraint(effect_id
, changed_in_version_group_id
),
855 create_translation_table('move_effect_changelog_prose', MoveEffectChangelog
, 'prose',
856 effect
= Column(markdown
.MarkdownColumn(512), nullable
=False,
857 info
=dict(description
="A description of the old behavior", format
='markdown')),
860 class MoveFlag(TableBase
):
861 u
"""Maps a move flag to a move
863 # XXX: Other flags have a ___Flag class for the actual flag and ___FlagMap for the map,
864 # these, somewhat confusingly, have MoveFlagType and MoveFlag
865 __tablename__
= 'move_flags'
866 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
867 info
=dict(description
="ID of the move"))
868 move_flag_type_id
= Column(Integer
, ForeignKey('move_flag_types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
869 info
=dict(description
="ID of the flag"))
871 class MoveFlagType(TableBase
):
872 u
"""A Move attribute such as "snatchable" or "contact".
874 __tablename__
= 'move_flag_types'
875 __singlename__
= 'move_flag_type'
876 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
877 info
=dict(description
="A numeric ID"))
878 identifier
= Column(Unicode(32), nullable
=False,
879 info
=dict(description
="A short identifier for the flag", format
='identifier'))
881 create_translation_table('move_flag_type_prose', MoveFlagType
, 'prose',
882 relation_lazy
='joined',
883 name
= Column(Unicode(32), nullable
=True, index
=True,
884 info
=dict(description
="The name", format
='plaintext', official
=False)),
885 description
= Column(markdown
.MarkdownColumn(128), nullable
=True,
886 info
=dict(description
="A short description of the flag", format
='markdown')),
889 class MoveFlavorText(TableBase
):
890 u
"""In-game description of a move
892 __tablename__
= 'move_flavor_text'
893 summary_column
= Move
.flavor_summaries_table
, 'flavor_summary'
894 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
895 info
=dict(description
="ID of the move"))
896 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
897 info
=dict(description
="ID of the version group this text appears in"))
898 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
899 info
=dict(description
="The language"))
900 flavor_text
= Column(Unicode(255), nullable
=False,
901 info
=dict(description
="The flavor text", official
=True, format
='gametext'))
903 class MoveMeta(TableBase
):
904 u
"""Metadata for move effects, sorta-kinda ripped straight from the game"""
905 __tablename__
= 'move_meta'
906 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
907 info
=dict(description
="A numeric ID"))
908 meta_category_id
= Column(Integer
, ForeignKey('move_meta_categories.id'), nullable
=False,
909 info
=dict(description
="ID of the move category"))
910 meta_ailment_id
= Column(Integer
, ForeignKey('move_meta_ailments.id'), nullable
=False,
911 info
=dict(description
="ID of the caused ailment"))
912 min_hits
= Column(Integer
, nullable
=True, index
=True,
913 info
=dict(description
="Minimum number of hits per use"))
914 max_hits
= Column(Integer
, nullable
=True, index
=True,
915 info
=dict(description
="Maximum number of hits per use"))
916 min_turns
= Column(Integer
, nullable
=True, index
=True,
917 info
=dict(description
="Minimum number of turns the user is forced to use the move"))
918 max_turns
= Column(Integer
, nullable
=True, index
=True,
919 info
=dict(description
="Maximum number of turns the user is forced to use the move"))
920 recoil
= Column(Integer
, nullable
=False, index
=True,
921 info
=dict(description
="Recoil damage, in percent of damage done"))
922 healing
= Column(Integer
, nullable
=False, index
=True,
923 info
=dict(description
="Healing, in percent of user's max HP"))
924 crit_rate
= Column(Integer
, nullable
=False, index
=True,
925 info
=dict(description
="Critical hit rate bonus"))
926 ailment_chance
= Column(Integer
, nullable
=False, index
=True,
927 info
=dict(description
="Chance to cause an ailment, in percent"))
928 flinch_chance
= Column(Integer
, nullable
=False, index
=True,
929 info
=dict(description
="Chance to cause flinching, in percent"))
930 stat_chance
= Column(Integer
, nullable
=False, index
=True,
931 info
=dict(description
="Chance to cause a stat change, in percent"))
933 class MoveMetaAilment(TableBase
):
934 u
"""Common status ailments moves can inflict on a single Pokémon, including
935 major ailments like paralysis and minor ailments like trapping.
937 __tablename__
= 'move_meta_ailments'
938 __singlename__
= 'move_meta_ailment'
939 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
940 info
=dict(description
="A numeric ID"))
941 identifier
= Column(Unicode(24), nullable
=False,
942 info
=dict(description
="An identifier", format
='identifier'))
944 create_translation_table('move_meta_ailment_names', MoveMetaAilment
, 'names',
945 relation_lazy
='joined',
946 name
= Column(Unicode(24), nullable
=False, index
=True,
947 info
=dict(description
="The name", format
='plaintext', official
=True)),
950 class MoveMetaCategory(TableBase
):
951 u
"""Very general categories that loosely group move effects."""
952 __tablename__
= 'move_meta_categories'
953 __singlename__
= 'move_meta_category'
954 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
955 info
=dict(description
="A numeric ID"))
957 create_translation_table('move_meta_category_prose', MoveMetaCategory
, 'prose',
958 relation_lazy
='joined',
959 description
= Column(Unicode(64), nullable
=False,
960 info
=dict(description
="A description of the category", format
="plaintext", official
=False)),
963 class MoveMetaStatChange(TableBase
):
964 u
"""Stat changes moves (may) make."""
965 __tablename__
= 'move_meta_stat_changes'
966 move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
967 info
=dict(description
="ID of the move"))
968 stat_id
= Column(Integer
, ForeignKey('stats.id'), primary_key
=True, nullable
=False, autoincrement
=False,
969 info
=dict(description
="ID of the stat"))
970 change
= Column(Integer
, nullable
=False, index
=True,
971 info
=dict(description
="Amount of increase/decrease, in stages"))
973 class MoveTarget(TableBase
):
974 u
"""Targetting or "range" of a move, e.g. "Affects all opponents" or "Affects user".
976 __tablename__
= 'move_targets'
977 __singlename__
= 'move_target'
978 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
979 info
=dict(description
="A numeric ID"))
980 identifier
= Column(Unicode(32), nullable
=False,
981 info
=dict(description
="An identifier", format
='identifier'))
983 create_translation_table('move_target_prose', MoveTarget
, 'prose',
984 relation_lazy
='joined',
985 name
= Column(Unicode(32), nullable
=True, index
=True,
986 info
=dict(description
="The name", format
='plaintext', official
=False)),
987 description
= Column(Unicode(128), nullable
=True,
988 info
=dict(description
="A description", format
='plaintext')),
991 class Nature(TableBase
):
992 u
"""A nature a Pokémon can have, such as Calm or Brave
994 __tablename__
= 'natures'
995 __singlename__
= 'nature'
996 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
997 info
=dict(description
="A numeric ID"))
998 identifier
= Column(Unicode(8), nullable
=False,
999 info
=dict(description
="An identifier", format
='identifier'))
1000 decreased_stat_id
= Column(Integer
, ForeignKey('stats.id'), nullable
=False,
1001 info
=dict(description
="ID of the stat that this nature decreases by 10% (if decreased_stat_id is the same, the effects cancel out)"))
1002 increased_stat_id
= Column(Integer
, ForeignKey('stats.id'), nullable
=False,
1003 info
=dict(description
="ID of the stat that this nature increases by 10% (if decreased_stat_id is the same, the effects cancel out)"))
1004 hates_flavor_id
= Column(Integer
, ForeignKey('contest_types.id'), nullable
=False,
1005 info
=dict(description
=u
"ID of the Berry flavor the Pokémon hates (if likes_flavor_id is the same, the effects cancel out)"))
1006 likes_flavor_id
= Column(Integer
, ForeignKey('contest_types.id'), nullable
=False,
1007 info
=dict(description
=u
"ID of the Berry flavor the Pokémon likes (if hates_flavor_id is the same, the effects cancel out)"))
1010 def is_neutral(self
):
1011 u
"""Returns True iff this nature doesn't alter a Pokémon's stats,
1012 bestow taste preferences, etc.
1014 return self
.increased_stat_id
== self
.decreased_stat_id
1016 create_translation_table('nature_names', Nature
, 'names',
1017 relation_lazy
='joined',
1018 name
= Column(Unicode(8), nullable
=False, index
=True,
1019 info
=dict(description
="The name", format
='plaintext', official
=True, ripped
=True)),
1022 class NatureBattleStylePreference(TableBase
):
1023 u
"""Battle Palace move preference
1025 Specifies how likely a Pokémon with a specific Nature is to use a move of
1026 a particular battl style in Battle Palace or Battle Tent
1028 __tablename__
= 'nature_battle_style_preferences'
1029 nature_id
= Column(Integer
, ForeignKey('natures.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1030 info
=dict(description
=u
"ID of the Pokémon's nature"))
1031 move_battle_style_id
= Column(Integer
, ForeignKey('move_battle_styles.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1032 info
=dict(description
="ID of the battle style"))
1033 low_hp_preference
= Column(Integer
, nullable
=False,
1034 info
=dict(description
=u
"Chance of using the move, in percent, if HP is under ½"))
1035 high_hp_preference
= Column(Integer
, nullable
=False,
1036 info
=dict(description
=u
"Chance of using the move, in percent, if HP is over ½"))
1038 class NaturePokeathlonStat(TableBase
):
1039 u
"""Specifies how a Nature affects a Pokéathlon stat
1041 __tablename__
= 'nature_pokeathlon_stats'
1042 nature_id
= Column(Integer
, ForeignKey('natures.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1043 info
=dict(description
="ID of the nature"))
1044 pokeathlon_stat_id
= Column(Integer
, ForeignKey('pokeathlon_stats.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1045 info
=dict(description
="ID of the stat"))
1046 max_change
= Column(Integer
, nullable
=False,
1047 info
=dict(description
="Maximum change"))
1049 class PokeathlonStat(TableBase
):
1050 u
"""A Pokéathlon stat, such as "Stamina" or "Jump".
1052 __tablename__
= 'pokeathlon_stats'
1053 __singlename__
= 'pokeathlon_stat'
1054 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1055 info
=dict(description
="A numeric ID"))
1056 identifier
= Column(Unicode(8), nullable
=False,
1057 info
=dict(description
="An identifier", format
='identifier'))
1059 create_translation_table('pokeathlon_stat_names', PokeathlonStat
, 'names',
1060 name
= Column(Unicode(8), nullable
=False, index
=True,
1061 info
=dict(description
="The name", format
='plaintext', official
=True)),
1064 class Pokedex(TableBase
):
1065 u
"""A collection of Pokémon species ordered in a particular way
1067 __tablename__
= 'pokedexes'
1068 __singlename__
= 'pokedex'
1069 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1070 info
=dict(description
="A numeric ID"))
1071 region_id
= Column(Integer
, ForeignKey('regions.id'), nullable
=True,
1072 info
=dict(description
=u
"ID of the region this Pokédex is used in, or None if it's global"))
1073 identifier
= Column(Unicode(16), nullable
=False,
1074 info
=dict(description
=u
"An identifier", format
='identifier'))
1076 create_translation_table('pokedex_prose', Pokedex
, 'prose',
1077 relation_lazy
='joined',
1078 name
= Column(Unicode(16), nullable
=True, index
=True,
1079 info
=dict(description
="The name", format
='plaintext', official
=False)),
1080 description
= Column(Unicode(512), nullable
=True,
1081 info
=dict(description
=u
"A longer description of the Pokédex", format
='plaintext')),
1084 class Pokemon(TableBase
):
1085 u
"""A species of Pokémon. The core to this whole mess.
1087 __tablename__
= 'pokemon'
1088 __singlename__
= 'pokemon'
1089 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1090 info
=dict(description
=u
"A numeric ID"))
1091 identifier
= Column(Unicode(20), nullable
=False,
1092 info
=dict(description
=u
"An identifier", format
='identifier'))
1093 generation_id
= Column(Integer
, ForeignKey('generations.id'),
1094 info
=dict(description
=u
"ID of the generation this species first appeared in"))
1095 evolution_chain_id
= Column(Integer
, ForeignKey('evolution_chains.id'),
1096 info
=dict(description
=u
"ID of the species' evolution chain (a.k.a. family)"))
1097 height
= Column(Integer
, nullable
=False,
1098 info
=dict(description
=u
"The height of the Pokémon, in decimeters (tenths of a meter)"))
1099 weight
= Column(Integer
, nullable
=False,
1100 info
=dict(description
=u
"The weight of the Pokémon, in tenths of a kilogram (decigrams)"))
1101 color_id
= Column(Integer
, ForeignKey('pokemon_colors.id'), nullable
=False,
1102 info
=dict(description
=u
"ID of this Pokémon's Pokédex color, as used for a gimmick search function in the games."))
1103 pokemon_shape_id
= Column(Integer
, ForeignKey('pokemon_shapes.id'), nullable
=False,
1104 info
=dict(description
=u
"ID of this Pokémon's body shape, as used for a gimmick search function in the games."))
1105 habitat_id
= Column(Integer
, ForeignKey('pokemon_habitats.id'), nullable
=True,
1106 info
=dict(description
=u
"ID of this Pokémon's habitat, as used for a gimmick search function in the games."))
1107 gender_rate
= Column(Integer
, nullable
=False,
1108 info
=dict(description
=u
"The chance of this Pokémon being female, in eighths; or -1 for genderless"))
1109 capture_rate
= Column(Integer
, nullable
=False,
1110 info
=dict(description
=u
"The base capture rate; up to 255"))
1111 base_experience
= Column(Integer
, nullable
=False,
1112 info
=dict(description
=u
"The base EXP gained when defeating this Pokémon")) # XXX: Is this correct?
1113 base_happiness
= Column(Integer
, nullable
=False,
1114 info
=dict(description
=u
"The tameness when caught by a normal ball"))
1115 is_baby
= Column(Boolean
, nullable
=False,
1116 info
=dict(description
=u
"True iff the Pokémon is a baby, i.e. a lowest-stage Pokémon that cannot breed but whose evolved form can."))
1117 hatch_counter
= Column(Integer
, nullable
=False,
1118 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"))
1119 has_gender_differences
= Column(Boolean
, nullable
=False,
1120 info
=dict(description
=u
"Set iff the species exhibits enough sexual dimorphism to have separate sets of sprites in Gen IV and beyond."))
1121 order
= Column(Integer
, nullable
=False, index
=True,
1122 info
=dict(description
=u
"Order for sorting. Almost national order, except families and forms are grouped together."))
1124 ### Stuff to handle alternate Pokémon forms
1128 u
"""Returns the Pokémon's form, using its default form as fallback."""
1130 return self
.unique_form
or self
.default_form
1133 def is_base_form(self
):
1134 u
"""Returns True iff the Pokémon is the base form for its species,
1138 return self
.unique_form
is None or self
.unique_form
.is_default
1141 def form_name(self
):
1142 u
"""Returns the Pokémon's form name if it represents a particular form
1143 and that form has a name, or None otherwise.
1146 # If self.unique_form is None, the short-circuit "and" will go ahead
1147 # and return that. Otherwise, it'll return the form's name, which may
1149 return self
.unique_form
and self
.unique_form
.name
1152 def full_name(self
):
1153 u
"""Returns the Pokémon's name, including its form if applicable."""
1156 return u
'{0} {1}'.format(self
.form_name
, self
.name
)
1161 def normal_form(self
):
1162 u
"""Returns the normal form for this Pokémon; i.e., this will return
1163 regular Deoxys when called on any Deoxys form.
1166 if self
.unique_form
:
1167 return self
.unique_form
.form_base_pokemon
1172 def stat(self
, stat_name
):
1173 u
"""Returns a PokemonStat record for the given stat name (or Stat row
1174 object). Uses the normal has-many machinery, so all the stats are
1177 if isinstance(stat_name
, Stat
):
1178 stat_name
= stat_name
.name
1180 for pokemon_stat
in self
.stats
:
1181 if pokemon_stat
.stat
.name
== stat_name
:
1184 raise KeyError(u
'No stat named %s' % stat_name
)
1187 def better_damage_class(self
):
1188 u
"""Returns the MoveDamageClass that this Pokémon is best suited for,
1189 based on its attack stats.
1191 If the attack stats are about equal (within 5), returns None. The
1192 value None, not the damage class called 'None'.
1194 phys
= self
.stat(u
'Attack')
1195 spec
= self
.stat(u
'Special Attack')
1197 diff
= phys
.base_stat
- spec
.base_stat
1200 return phys
.stat
.damage_class
1202 return spec
.stat
.damage_class
1206 create_translation_table('pokemon_names', Pokemon
, 'names',
1207 relation_lazy
='joined',
1208 name
= Column(Unicode(20), nullable
=True, index
=True,
1209 info
=dict(description
="The name", format
='plaintext', official
=True, ripped
=True)),
1210 species
= Column(Unicode(16), nullable
=True,
1211 info
=dict(description
=u
'The short flavor text, such as "Seed" or "Lizard"; usually affixed with the word "Pokémon"',
1212 official
=True, format
='plaintext')),
1214 create_translation_table('pokemon_flavor_summaries', Pokemon
, 'flavor_summaries',
1215 flavor_summary
= Column(Unicode(512), nullable
=True,
1216 info
=dict(description
=u
"Text containing facts from all flavor texts, for languages without official game translations", official
=False, format
='plaintext', ripped
=True)),
1219 class PokemonAbility(TableBase
):
1220 u
"""Maps an ability to a Pokémon that can have it
1222 __tablename__
= 'pokemon_abilities'
1223 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1224 info
=dict(description
=u
"ID of the Pokémon"))
1225 ability_id
= Column(Integer
, ForeignKey('abilities.id'), nullable
=False,
1226 info
=dict(description
=u
"ID of the ability"))
1227 # XXX having both a method and a slot is kind of gross. "slot" is a
1228 # misnomer, anyway: duplicate abilities don't appear in slot 2.
1229 # Probably should replace that with "order".
1230 is_dream
= Column(Boolean
, nullable
=False, index
=True,
1231 info
=dict(description
=u
"Whether this is a Dream World ability"))
1232 slot
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1233 info
=dict(description
=u
"The ability slot, i.e. 1 or 2 for gen. IV"))
1235 class PokemonColor(TableBase
):
1236 u
"""The "Pokédex color" of a Pokémon species. Usually based on the Pokémon's color.
1238 __tablename__
= 'pokemon_colors'
1239 __singlename__
= 'pokemon_color'
1240 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1241 info
=dict(description
=u
"ID of the Pokémon"))
1242 identifier
= Column(Unicode(6), nullable
=False,
1243 info
=dict(description
=u
"An identifier", format
='identifier'))
1245 create_translation_table('pokemon_color_names', PokemonColor
, 'names',
1246 relation_lazy
='joined',
1247 name
= Column(Unicode(6), nullable
=False, index
=True,
1248 info
=dict(description
="The name", format
='plaintext', official
=True)),
1251 class PokemonDexNumber(TableBase
):
1252 u
"""The number of a Pokémon in a particular Pokédex (e.g. Jigglypuff is #138 in Hoenn's 'dex)
1254 __tablename__
= 'pokemon_dex_numbers'
1255 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1256 info
=dict(description
=u
"ID of the Pokémon"))
1257 pokedex_id
= Column(Integer
, ForeignKey('pokedexes.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1258 info
=dict(description
=u
"ID of the Pokédex"))
1259 pokedex_number
= Column(Integer
, nullable
=False,
1260 info
=dict(description
=u
"Number of the Pokémon in that the Pokédex"))
1262 class PokemonEggGroup(TableBase
):
1263 u
"""Maps an Egg group to a Pokémon; each Pokémon belongs to one or two egg groups
1265 __tablename__
= 'pokemon_egg_groups'
1266 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1267 info
=dict(description
=u
"ID of the Pokémon"))
1268 egg_group_id
= Column(Integer
, ForeignKey('egg_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1269 info
=dict(description
=u
"ID of the egg group"))
1271 class PokemonEvolution(TableBase
):
1272 u
"""A required action ("trigger") and the conditions under which the trigger
1273 must occur to cause a Pokémon to evolve.
1275 Any condition may be null if it does not apply for a particular Pokémon.
1277 __tablename__
= 'pokemon_evolution'
1278 from_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False,
1279 info
=dict(description
=u
"The ID of the pre-evolution Pokémon."))
1280 to_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1281 info
=dict(description
=u
"The ID of the post-evolution Pokémon."))
1282 evolution_trigger_id
= Column(Integer
, ForeignKey('evolution_triggers.id'), nullable
=False,
1283 info
=dict(description
=u
"The ID of the evolution trigger."))
1284 trigger_item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=True,
1285 info
=dict(description
=u
"The ID of the item that must be used on the Pokémon."))
1286 minimum_level
= Column(Integer
, nullable
=True,
1287 info
=dict(description
=u
"The minimum level for the Pokémon."))
1288 gender
= Column(Enum('male', 'female', name
='pokemon_evolution_gender'), nullable
=True,
1289 info
=dict(description
=u
"The Pokémon's required gender, or None if gender doesn't matter"))
1290 location_id
= Column(Integer
, ForeignKey('locations.id'), nullable
=True,
1291 info
=dict(description
=u
"The ID of the location the evolution must be triggered at."))
1292 held_item_id
= Column(Integer
, ForeignKey('items.id'), nullable
=True,
1293 info
=dict(description
=u
"The ID of the item the Pokémon must hold."))
1294 time_of_day
= Column(Enum('day', 'night', name
='pokemon_evolution_time_of_day'), nullable
=True,
1295 info
=dict(description
=u
"The required time of day."))
1296 known_move_id
= Column(Integer
, ForeignKey('moves.id'), nullable
=True,
1297 info
=dict(description
=u
"The ID of the move the Pokémon must know."))
1298 minimum_happiness
= Column(Integer
, nullable
=True,
1299 info
=dict(description
=u
"The minimum happiness value the Pokémon must have."))
1300 minimum_beauty
= Column(Integer
, nullable
=True,
1301 info
=dict(description
=u
"The minimum Beauty value the Pokémon must have."))
1302 relative_physical_stats
= Column(Integer
, nullable
=True,
1303 info
=dict(description
=u
"The required relation between the Pokémon's Attack and Defense stats, as sgn(atk-def)."))
1304 party_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=True,
1305 info
=dict(description
=u
"The ID of the Pokémon that must be present in the party."))
1306 trade_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=True,
1307 info
=dict(description
=u
"The ID of the Pokémon for which this Pokémon must be traded."))
1309 class PokemonFlavorText(TableBase
):
1310 u
"""In-game Pokédex descrption of a Pokémon.
1312 __tablename__
= 'pokemon_flavor_text'
1313 summary_column
= Pokemon
.flavor_summaries_table
, 'flavor_summary'
1314 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1315 info
=dict(description
=u
"ID of the Pokémon"))
1316 version_id
= Column(Integer
, ForeignKey('versions.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1317 info
=dict(description
=u
"ID of the version that has this flavor text"))
1318 language_id
= Column(Integer
, ForeignKey('languages.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1319 info
=dict(description
="The language"))
1320 flavor_text
= Column(Unicode(255), nullable
=False,
1321 info
=dict(description
=u
"The flavor text", official
=True, format
='gametext'))
1323 class PokemonForm(TableBase
):
1324 u
"""An individual form of a Pokémon.
1326 Pokémon that do not have separate forms are still given a single row to
1327 represent their single form.
1329 __tablename__
= 'pokemon_forms'
1330 __singlename__
= 'pokemon_form'
1331 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1332 info
=dict(description
=u
'A unique ID for this form.'))
1333 identifier
= Column(Unicode(16), nullable
=True,
1334 info
=dict(description
=u
"An identifier", format
='identifier'))
1335 form_base_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False, autoincrement
=False,
1336 info
=dict(description
=u
'The ID of the base Pokémon for this form.'))
1337 unique_pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), autoincrement
=False,
1338 info
=dict(description
=u
'The ID of a Pokémon that represents specifically this form, for Pokémon with functionally-different forms like Wormadam.'))
1339 introduced_in_version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), autoincrement
=False,
1340 info
=dict(description
=u
'The ID of the version group in which this form first appeared.'))
1341 is_default
= Column(Boolean
, nullable
=False,
1342 info
=dict(description
=u
'Set for exactly one form used as the default for each species.'))
1343 order
= Column(Integer
, nullable
=False, autoincrement
=False,
1344 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.'))
1348 u
"""Returns the Pokémon for this form, using the form base as fallback.
1351 return self
.unique_pokemon
or self
.form_base_pokemon
1354 def full_name(self
):
1355 u
"""Returns the full name of this form, e.g. "Plant Cloak"."""
1359 elif self
.form_group
and self
.form_group
.term
:
1360 return u
'{0} {1}'.format(self
.name
, self
.form_group
.term
)
1365 def pokemon_name(self
):
1366 u
"""Returns the name of this Pokémon with this form, e.g. "Plant
1371 return u
'{0} {1}'.format(self
.name
, self
.form_base_pokemon
.name
)
1373 return self
.form_base_pokemon
.name
1375 create_translation_table('pokemon_form_names', PokemonForm
, 'names',
1376 relation_lazy
='joined',
1377 name
= Column(Unicode(16), nullable
=False, index
=True,
1378 info
=dict(description
="The name", format
='plaintext', official
=True)),
1381 class PokemonFormGroup(TableBase
):
1382 u
"""Information about a Pokémon's forms as a group."""
1383 __tablename__
= 'pokemon_form_groups'
1384 __singlename__
= 'pokemon_form_group'
1385 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1386 info
=dict(description
=u
"ID of the base form Pokémon"))
1387 is_battle_only
= Column(Boolean
, nullable
=False,
1388 info
=dict(description
=u
"Set iff the forms only change in battle"))
1390 PokemonFormGroup
.id = PokemonFormGroup
.pokemon_id
1392 create_translation_table('pokemon_form_group_prose', PokemonFormGroup
, 'prose',
1393 term
= Column(Unicode(16), nullable
=True,
1394 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')),
1395 description
= Column(markdown
.MarkdownColumn(1024), nullable
=True,
1396 info
=dict(description
=u
"Description of how the forms work", format
='markdown')),
1399 class PokemonFormPokeathlonStat(TableBase
):
1400 u
"""A Pokémon form's performance in one Pokéathlon stat."""
1401 __tablename__
= 'pokemon_form_pokeathlon_stats'
1402 pokemon_form_id
= Column(Integer
, ForeignKey('pokemon_forms.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1403 info
=dict(description
=u
'The ID of the Pokémon form.'))
1404 pokeathlon_stat_id
= Column(Integer
, ForeignKey('pokeathlon_stats.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1405 info
=dict(description
=u
'The ID of the Pokéathlon stat.'))
1406 minimum_stat
= Column(Integer
, nullable
=False, autoincrement
=False,
1407 info
=dict(description
=u
'The minimum value for this stat for this Pokémon form.'))
1408 base_stat
= Column(Integer
, nullable
=False, autoincrement
=False,
1409 info
=dict(description
=u
'The default value for this stat for this Pokémon form.'))
1410 maximum_stat
= Column(Integer
, nullable
=False, autoincrement
=False,
1411 info
=dict(description
=u
'The maximum value for this stat for this Pokémon form.'))
1413 class PokemonGameIndex(TableBase
):
1414 u
"""The number of a Pokémon a game uses internally
1416 __tablename__
= 'pokemon_game_indices'
1417 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, autoincrement
=False, nullable
=False,
1418 info
=dict(description
=u
"Database ID of the Pokémon"))
1419 generation_id
= Column(Integer
, ForeignKey('generations.id'), primary_key
=True, autoincrement
=False, nullable
=False,
1420 info
=dict(description
=u
"Database ID of the generation"))
1421 game_index
= Column(Integer
, nullable
=False,
1422 info
=dict(description
=u
"Internal ID the generation's games use for the Pokémon"))
1424 class PokemonHabitat(TableBase
):
1425 u
"""The habitat of a Pokémon, as given in the FireRed/LeafGreen version Pokédex
1427 __tablename__
= 'pokemon_habitats'
1428 __singlename__
= 'pokemon_habitat'
1429 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1430 info
=dict(description
=u
"A numeric ID"))
1431 identifier
= Column(Unicode(16), nullable
=False,
1432 info
=dict(description
=u
"An identifier", format
='identifier'))
1434 create_translation_table('pokemon_habitat_names', PokemonHabitat
, 'names',
1435 relation_lazy
='joined',
1436 name
= Column(Unicode(16), nullable
=False, index
=True,
1437 info
=dict(description
="The name", format
='plaintext', official
=True)),
1440 class PokemonItem(TableBase
):
1441 u
"""Record of an item a Pokémon can hold in the wild
1443 __tablename__
= 'pokemon_items'
1444 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1445 info
=dict(description
=u
"ID of the Pokémon"))
1446 version_id
= Column(Integer
, ForeignKey('versions.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1447 info
=dict(description
=u
"ID of the version this applies to"))
1448 item_id
= Column(Integer
, ForeignKey('items.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1449 info
=dict(description
=u
"ID of the item"))
1450 rarity
= Column(Integer
, nullable
=False,
1451 info
=dict(description
=u
"Chance of the Pokémon holding the item, in percent"))
1453 class PokemonMove(TableBase
):
1454 u
"""Record of a move a Pokémon can learn
1456 __tablename__
= 'pokemon_moves'
1457 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), nullable
=False, index
=True,
1458 info
=dict(description
=u
"ID of the Pokémon"))
1459 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False, index
=True,
1460 info
=dict(description
=u
"ID of the version group this applies to"))
1461 move_id
= Column(Integer
, ForeignKey('moves.id'), nullable
=False, index
=True,
1462 info
=dict(description
=u
"ID of the move"))
1463 pokemon_move_method_id
= Column(Integer
, ForeignKey('pokemon_move_methods.id'), nullable
=False, index
=True,
1464 info
=dict(description
=u
"ID of the method this move is learned by"))
1465 level
= Column(Integer
, nullable
=True, index
=True,
1466 info
=dict(description
=u
"Level the move is learned at, if applicable"))
1467 order
= Column(Integer
, nullable
=True,
1468 info
=dict(description
=u
"A sort key to produce the correct ordering when all else is equal")) # XXX: This needs a better description
1471 PrimaryKeyConstraint('pokemon_id', 'version_group_id', 'move_id', 'pokemon_move_method_id', 'level'),
1475 class PokemonMoveMethod(TableBase
):
1476 u
"""A method a move can be learned by, such as "Level up" or "Tutor".
1478 __tablename__
= 'pokemon_move_methods'
1479 __singlename__
= 'pokemon_move_method'
1480 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1481 info
=dict(description
=u
"A numeric ID"))
1482 identifier
= Column(Unicode(64), nullable
=False,
1483 info
=dict(description
=u
"An identifier", format
='identifier'))
1485 create_translation_table('pokemon_move_method_prose', PokemonMoveMethod
, 'prose',
1486 relation_lazy
='joined',
1487 name
= Column(Unicode(64), nullable
=True, index
=True,
1488 info
=dict(description
="The name", format
='plaintext', official
=False)),
1489 description
= Column(Unicode(255), nullable
=True,
1490 info
=dict(description
=u
"A detailed description of how the method works", format
='plaintext')),
1493 class PokemonShape(TableBase
):
1494 u
"""The shape of a Pokémon's body, as used in generation IV Pokédexes.
1496 __tablename__
= 'pokemon_shapes'
1497 __singlename__
= 'pokemon_shape'
1498 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1499 info
=dict(description
=u
"A numeric ID"))
1500 identifier
= Column(Unicode(24), nullable
=False,
1501 info
=dict(description
=u
"An identifier", format
='identifier'))
1503 create_translation_table('pokemon_shape_prose', PokemonShape
, 'prose',
1504 relation_lazy
='joined',
1505 name
= Column(Unicode(24), nullable
=True, index
=True,
1506 info
=dict(description
="The name", format
='plaintext', official
=False)),
1507 awesome_name
= Column(Unicode(16), nullable
=True,
1508 info
=dict(description
=u
"A splendiferous name of the body shape", format
='plaintext')),
1511 class PokemonStat(TableBase
):
1512 u
"""A stat value of a Pokémon
1514 __tablename__
= 'pokemon_stats'
1515 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1516 info
=dict(description
=u
"ID of the Pokémon"))
1517 stat_id
= Column(Integer
, ForeignKey('stats.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1518 info
=dict(description
=u
"ID of the stat"))
1519 base_stat
= Column(Integer
, nullable
=False,
1520 info
=dict(description
=u
"The base stat"))
1521 effort
= Column(Integer
, nullable
=False,
1522 info
=dict(description
=u
"The effort increase in this stat gained when this Pokémon is defeated"))
1524 class PokemonType(TableBase
):
1525 u
"""Maps a type to a Pokémon. Each Pokémon has 1 or 2 types.
1527 __tablename__
= 'pokemon_types'
1528 pokemon_id
= Column(Integer
, ForeignKey('pokemon.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1529 info
=dict(description
=u
"ID of the Pokémon"))
1530 type_id
= Column(Integer
, ForeignKey('types.id'), nullable
=False,
1531 info
=dict(description
=u
"ID of the type"))
1532 slot
= Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1533 info
=dict(description
=u
"The type's slot, 1 or 2, used to sort types if there are two of them"))
1535 class Region(TableBase
):
1536 u
"""Major areas of the world: Kanto, Johto, etc.
1538 __tablename__
= 'regions'
1539 __singlename__
= 'region'
1540 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1541 info
=dict(description
=u
"A numeric ID"))
1542 identifier
= Column(Unicode(16), nullable
=False,
1543 info
=dict(description
=u
"An identifier", format
='identifier'))
1545 create_translation_table('region_names', Region
, 'names',
1546 relation_lazy
='joined',
1547 name
= Column(Unicode(16), nullable
=False, index
=True,
1548 info
=dict(description
="The name", format
='plaintext', official
=True)),
1551 class Stat(TableBase
):
1552 u
"""A Stat, such as Attack or Speed
1554 __tablename__
= 'stats'
1555 __singlename__
= 'stat'
1556 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1557 info
=dict(description
=u
"A numeric ID"))
1558 damage_class_id
= Column(Integer
, ForeignKey('move_damage_classes.id'), nullable
=True,
1559 info
=dict(description
=u
"For offensive and defensive stats, the damage this stat relates to; otherwise None (the NULL value)"))
1560 identifier
= Column(Unicode(16), nullable
=False,
1561 info
=dict(description
=u
"An identifier", format
='identifier'))
1562 is_battle_only
= Column(Boolean
, nullable
=False,
1563 info
=dict(description
=u
"Whether this stat only exists within a battle"))
1565 create_translation_table('stat_names', Stat
, 'names',
1566 relation_lazy
='joined',
1567 name
= Column(Unicode(16), nullable
=False, index
=True,
1568 info
=dict(description
="The name", format
='plaintext', official
=True)),
1571 class StatHint(TableBase
):
1572 u
"""Flavor text for genes that appears in a Pokémon's summary. Sometimes
1573 called "characteristics".
1575 __tablename__
= 'stat_hints'
1576 __singlename__
= 'stat_hint'
1577 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1578 info
=dict(description
=u
"A numeric ID"))
1579 stat_id
= Column(Integer
, ForeignKey('stats.id'), nullable
=False,
1580 info
=dict(description
=u
"ID of the highest stat"))
1581 gene_mod_5
= Column(Integer
, nullable
=False, index
=True,
1582 info
=dict(description
=u
"Value of the highest stat modulo 5"))
1584 create_translation_table('stat_hint_names', StatHint
, 'names',
1585 relation_lazy
='joined',
1586 message
= Column(Unicode(24), nullable
=False, index
=True,
1587 info
=dict(description
=u
"The text displayed", official
=True, format
='plaintext')),
1590 class SuperContestCombo(TableBase
):
1591 u
"""Combo of two moves in a Super Contest.
1593 __tablename__
= 'super_contest_combos'
1594 first_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1595 info
=dict(description
=u
"The ID of the first move in the combo."))
1596 second_move_id
= Column(Integer
, ForeignKey('moves.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1597 info
=dict(description
=u
"The ID of the second and last move."))
1599 class SuperContestEffect(TableBase
):
1600 u
"""An effect a move can have when used in the Super Contest
1602 __tablename__
= 'super_contest_effects'
1603 __singlename__
= 'super_contest_effect'
1604 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1605 info
=dict(description
=u
"This effect's unique ID."))
1606 appeal
= Column(SmallInteger
, nullable
=False,
1607 info
=dict(description
=u
"The number of hearts the user gains."))
1609 create_translation_table('super_contest_effect_prose', SuperContestEffect
, 'prose',
1610 flavor_text
= Column(Unicode(64), nullable
=False,
1611 info
=dict(description
=u
"A description of the effect.", format
='plaintext', official
=True)),
1614 class Type(TableBase
):
1615 u
"""Any of the elemental types Pokémon and moves can have."""
1616 __tablename__
= 'types'
1617 __singlename__
= 'type'
1618 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1619 info
=dict(description
=u
"A unique ID for this type."))
1620 identifier
= Column(Unicode(12), nullable
=False,
1621 info
=dict(description
=u
"An identifier", format
='identifier'))
1622 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
1623 info
=dict(description
=u
"The ID of the generation this type first appeared in."))
1624 damage_class_id
= Column(Integer
, ForeignKey('move_damage_classes.id'), nullable
=True,
1625 info
=dict(description
=u
"The ID of the damage class this type's moves had before Generation IV, null if not applicable (e.g. ???)."))
1627 create_translation_table('type_names', Type
, 'names',
1628 relation_lazy
='joined',
1629 name
= Column(Unicode(12), nullable
=False, index
=True,
1630 info
=dict(description
="The name", format
='plaintext', official
=True)),
1633 class TypeEfficacy(TableBase
):
1634 u
"""The damage multiplier used when a move of a particular type damages a
1635 Pokémon of a particular other type.
1637 __tablename__
= 'type_efficacy'
1638 damage_type_id
= Column(Integer
, ForeignKey('types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1639 info
=dict(description
=u
"The ID of the damaging type."))
1640 target_type_id
= Column(Integer
, ForeignKey('types.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1641 info
=dict(description
=u
"The ID of the defending Pokémon's type."))
1642 damage_factor
= Column(Integer
, nullable
=False,
1643 info
=dict(description
=u
"The multiplier, as a percentage of damage inflicted."))
1645 class Version(TableBase
):
1646 u
"""An individual main-series Pokémon game."""
1647 __tablename__
= 'versions'
1648 __singlename__
= 'version'
1649 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1650 info
=dict(description
=u
"A unique ID for this version."))
1651 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), nullable
=False,
1652 info
=dict(description
=u
"The ID of the version group this game belongs to."))
1653 identifier
= Column(Unicode(32), nullable
=False,
1654 info
=dict(description
=u
'And identifier', format
='identifier'))
1656 create_translation_table('version_names', Version
, 'names',
1657 relation_lazy
='joined',
1658 name
= Column(Unicode(32), nullable
=False, index
=True,
1659 info
=dict(description
="The name", format
='plaintext', official
=True)),
1662 class VersionGroup(TableBase
):
1663 u
"""A group of versions, containing either two paired versions (such as Red
1664 and Blue) or a single game (such as Yellow.)
1666 __tablename__
= 'version_groups'
1667 id = Column(Integer
, primary_key
=True, nullable
=False, autoincrement
=False,
1668 info
=dict(description
=u
"This version group's unique ID."))
1669 generation_id
= Column(Integer
, ForeignKey('generations.id'), nullable
=False,
1670 info
=dict(description
=u
"The ID of the generation the games in this group belong to."))
1671 pokedex_id
= Column(Integer
, ForeignKey('pokedexes.id'), nullable
=False,
1672 info
=dict(description
=u
"The ID of the regional Pokédex used in this version group."))
1674 class VersionGroupRegion(TableBase
):
1675 u
"""Maps a version group to a region that appears in it."""
1676 __tablename__
= 'version_group_regions'
1677 version_group_id
= Column(Integer
, ForeignKey('version_groups.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1678 info
=dict(description
=u
"The ID of the version group."))
1679 region_id
= Column(Integer
, ForeignKey('regions.id'), primary_key
=True, nullable
=False, autoincrement
=False,
1680 info
=dict(description
=u
"The ID of the region."))
1683 ### Relations down here, to avoid dependency ordering problems
1685 Ability
.changelog
= relation(AbilityChangelog
,
1686 order_by
=AbilityChangelog
.changed_in_version_group_id
.desc(),
1687 backref
=backref('ability', innerjoin
=True, lazy
='joined'))
1688 Ability
.flavor_text
= relation(AbilityFlavorText
,
1689 order_by
=AbilityFlavorText
.version_group_id
,
1690 backref
=backref('ability', innerjoin
=True, lazy
='joined'))
1691 Ability
.generation
= relation(Generation
,
1693 backref
='abilities')
1695 AbilityChangelog
.changed_in
= relation(VersionGroup
,
1696 innerjoin
=True, lazy
='joined',
1697 backref
='ability_changelog')
1699 AbilityFlavorText
.version_group
= relation(VersionGroup
,
1701 AbilityFlavorText
.language
= relation(Language
,
1702 innerjoin
=True, lazy
='joined')
1705 Berry
.berry_firmness
= relation(BerryFirmness
,
1708 Berry
.firmness
= association_proxy('berry_firmness', 'name')
1709 Berry
.flavors
= relation(BerryFlavor
,
1710 order_by
=BerryFlavor
.contest_type_id
,
1711 backref
=backref('berry', innerjoin
=True))
1712 Berry
.natural_gift_type
= relation(Type
, innerjoin
=True)
1714 BerryFlavor
.contest_type
= relation(ContestType
, innerjoin
=True)
1717 ContestCombo
.first
= relation(Move
,
1718 primaryjoin
=ContestCombo
.first_move_id
==Move
.id,
1719 innerjoin
=True, lazy
='joined',
1720 backref
='contest_combo_first')
1721 ContestCombo
.second
= relation(Move
,
1722 primaryjoin
=ContestCombo
.second_move_id
==Move
.id,
1723 innerjoin
=True, lazy
='joined',
1724 backref
='contest_combo_second')
1727 Encounter
.condition_value_map
= relation(EncounterConditionValueMap
,
1728 backref
='encounter')
1729 Encounter
.condition_values
= association_proxy('condition_value_map', 'condition_value')
1730 Encounter
.location_area
= relation(LocationArea
,
1731 innerjoin
=True, lazy
='joined',
1732 backref
='encounters')
1733 Encounter
.pokemon
= relation(Pokemon
,
1734 innerjoin
=True, lazy
='joined',
1735 backref
='encounters')
1736 Encounter
.version
= relation(Version
,
1737 innerjoin
=True, lazy
='joined',
1738 backref
='encounters')
1739 Encounter
.slot
= relation(EncounterSlot
,
1740 innerjoin
=True, lazy
='joined',
1741 backref
='encounters')
1743 EncounterConditionValue
.condition
= relation(EncounterCondition
,
1744 innerjoin
=True, lazy
='joined',
1746 EncounterConditionValueMap
.condition_value
= relation(EncounterConditionValue
,
1747 innerjoin
=True, lazy
='joined',
1748 backref
='encounter_map')
1750 EncounterSlot
.terrain
= relation(EncounterTerrain
,
1751 innerjoin
=True, lazy
='joined',
1753 EncounterSlot
.version_group
= relation(VersionGroup
, innerjoin
=True)
1756 EvolutionChain
.growth_rate
= relation(GrowthRate
,
1758 backref
='evolution_chains')
1759 EvolutionChain
.baby_trigger_item
= relation(Item
,
1760 backref
='evolution_chains')
1763 Experience
.growth_rate
= relation(GrowthRate
,
1764 innerjoin
=True, lazy
='joined',
1765 backref
='experience_table')
1768 Generation
.canonical_pokedex
= relation(Pokedex
,
1769 backref
='canonical_for_generation')
1770 Generation
.versions
= relation(Version
,
1771 secondary
=VersionGroup
.__table__
,
1773 Generation
.main_region
= relation(Region
, innerjoin
=True)
1776 GrowthRate
.max_experience_obj
= relation(Experience
,
1778 Experience
.growth_rate_id
== GrowthRate
.id,
1779 Experience
.level
== 100),
1780 uselist
=False, innerjoin
=True)
1781 GrowthRate
.max_experience
= association_proxy('max_experience_obj', 'experience')
1784 Item
.berry
= relation(Berry
,
1787 Item
.flags
= relation(ItemFlag
,
1788 secondary
=ItemFlagMap
.__table__
)
1789 Item
.flavor_text
= relation(ItemFlavorText
,
1790 order_by
=ItemFlavorText
.version_group_id
.asc(),
1791 backref
=backref('item', innerjoin
=True, lazy
='joined'))
1792 Item
.fling_effect
= relation(ItemFlingEffect
,
1794 Item
.machines
= relation(Machine
,
1795 order_by
=Machine
.version_group_id
.asc())
1796 Item
.category
= relation(ItemCategory
,
1798 backref
=backref('items', order_by
=Item
.identifier
.asc()))
1799 Item
.pocket
= association_proxy('category', 'pocket')
1801 ItemCategory
.pocket
= relation(ItemPocket
, innerjoin
=True)
1803 ItemFlavorText
.version_group
= relation(VersionGroup
,
1804 innerjoin
=True, lazy
='joined')
1805 ItemFlavorText
.language
= relation(Language
,
1806 innerjoin
=True, lazy
='joined')
1808 ItemGameIndex
.item
= relation(Item
,
1809 innerjoin
=True, lazy
='joined',
1810 backref
='game_indices')
1811 ItemGameIndex
.generation
= relation(Generation
,
1812 innerjoin
=True, lazy
='joined')
1814 ItemPocket
.categories
= relation(ItemCategory
,
1816 order_by
=ItemCategory
.identifier
.asc())
1819 Location
.region
= relation(Region
,
1821 backref
='locations')
1823 LocationArea
.location
= relation(Location
,
1824 innerjoin
=True, lazy
='joined',
1827 LocationGameIndex
.location
= relation(Location
,
1828 innerjoin
=True, lazy
='joined',
1829 backref
='game_indices')
1830 LocationGameIndex
.generation
= relation(Generation
,
1831 innerjoin
=True, lazy
='joined')
1834 Machine
.item
= relation(Item
)
1835 Machine
.version_group
= relation(VersionGroup
,
1836 innerjoin
=True, lazy
='joined')
1839 Move
.changelog
= relation(MoveChangelog
,
1840 order_by
=MoveChangelog
.changed_in_version_group_id
.desc(),
1841 backref
=backref('move', innerjoin
=True, lazy
='joined'))
1842 Move
.contest_effect
= relation(ContestEffect
,
1844 Move
.contest_combo_next
= association_proxy('contest_combo_first', 'second')
1845 Move
.contest_combo_prev
= association_proxy('contest_combo_second', 'first')
1846 Move
.contest_type
= relation(ContestType
,
1848 Move
.damage_class
= relation(MoveDamageClass
,
1851 Move
.flags
= association_proxy('move_flags', 'flag')
1852 Move
.flavor_text
= relation(MoveFlavorText
,
1853 order_by
=MoveFlavorText
.version_group_id
, backref
='move')
1854 Move
.generation
= relation(Generation
,
1857 Move
.machines
= relation(Machine
,
1859 Move
.meta
= relation(MoveMeta
,
1860 uselist
=False, innerjoin
=True,
1862 Move
.meta_stat_changes
= relation(MoveMetaStatChange
)
1863 Move
.move_effect
= relation(MoveEffect
,
1866 Move
.move_flags
= relation(MoveFlag
,
1868 Move
.super_contest_effect
= relation(SuperContestEffect
,
1870 Move
.super_contest_combo_next
= association_proxy('super_contest_combo_first', 'second')
1871 Move
.super_contest_combo_prev
= association_proxy('super_contest_combo_second', 'first')
1872 Move
.target
= relation(MoveTarget
,
1875 Move
.type = relation(Type
,
1879 Move
.effect
= markdown
.MoveEffectProperty('effect')
1880 Move
.effect_map
= markdown
.MoveEffectPropertyMap('effect_map')
1881 Move
.short_effect
= markdown
.MoveEffectProperty('short_effect')
1882 Move
.short_effect_map
= markdown
.MoveEffectPropertyMap('short_effect_map')
1884 MoveChangelog
.changed_in
= relation(VersionGroup
,
1885 innerjoin
=True, lazy
='joined',
1886 backref
='move_changelog')
1887 MoveChangelog
.move_effect
= relation(MoveEffect
,
1888 backref
='move_changelog')
1889 MoveChangelog
.type = relation(Type
,
1890 backref
='move_changelog')
1892 MoveChangelog
.effect
= markdown
.MoveEffectProperty('effect')
1893 MoveChangelog
.effect_map
= markdown
.MoveEffectPropertyMap('effect_map')
1894 MoveChangelog
.short_effect
= markdown
.MoveEffectProperty('short_effect')
1895 MoveChangelog
.short_effect_map
= markdown
.MoveEffectPropertyMap('short_effect_map')
1897 MoveEffect
.category_map
= relation(MoveEffectCategoryMap
)
1898 MoveEffect
.categories
= association_proxy('category_map', 'category')
1899 MoveEffect
.changelog
= relation(MoveEffectChangelog
,
1900 order_by
=MoveEffectChangelog
.changed_in_version_group_id
.desc(),
1901 backref
='move_effect')
1902 MoveEffectCategoryMap
.category
= relation(MoveEffectCategory
)
1904 MoveEffectChangelog
.changed_in
= relation(VersionGroup
,
1905 innerjoin
=True, lazy
='joined',
1906 backref
='move_effect_changelog')
1908 MoveFlag
.flag
= relation(MoveFlagType
, innerjoin
=True, lazy
='joined')
1910 MoveFlavorText
.version_group
= relation(VersionGroup
,
1911 innerjoin
=True, lazy
='joined')
1912 MoveFlavorText
.language
= relation(Language
,
1913 innerjoin
=True, lazy
='joined')
1915 MoveMeta
.category
= relation(MoveMetaCategory
,
1916 innerjoin
=True, lazy
='joined',
1917 backref
='move_meta')
1918 MoveMeta
.ailment
= relation(MoveMetaAilment
,
1919 innerjoin
=True, lazy
='joined',
1920 backref
='move_meta')
1922 MoveMetaStatChange
.stat
= relation(Stat
,
1923 innerjoin
=True, lazy
='joined',
1924 backref
='move_meta_stat_changes')
1927 Nature
.decreased_stat
= relation(Stat
,
1928 primaryjoin
=Nature
.decreased_stat_id
==Stat
.id,
1930 backref
='decreasing_natures')
1931 Nature
.increased_stat
= relation(Stat
,
1932 primaryjoin
=Nature
.increased_stat_id
==Stat
.id,
1934 backref
='increasing_natures')
1935 Nature
.hates_flavor
= relation(ContestType
,
1936 primaryjoin
=Nature
.hates_flavor_id
==ContestType
.id,
1938 backref
='hating_natures')
1939 Nature
.likes_flavor
= relation(ContestType
,
1940 primaryjoin
=Nature
.likes_flavor_id
==ContestType
.id,
1942 backref
='liking_natures')
1943 Nature
.battle_style_preferences
= relation(NatureBattleStylePreference
,
1944 order_by
=NatureBattleStylePreference
.move_battle_style_id
.asc(),
1946 Nature
.pokeathlon_effects
= relation(NaturePokeathlonStat
,
1947 order_by
=NaturePokeathlonStat
.pokeathlon_stat_id
.asc())
1949 NatureBattleStylePreference
.battle_style
= relation(MoveBattleStyle
,
1950 innerjoin
=True, lazy
='joined',
1951 backref
='nature_preferences')
1953 NaturePokeathlonStat
.pokeathlon_stat
= relation(PokeathlonStat
,
1954 innerjoin
=True, lazy
='joined',
1955 backref
='nature_effects')
1958 Pokedex
.region
= relation(Region
,
1960 backref
='pokedexes')
1961 Pokedex
.version_groups
= relation(VersionGroup
,
1963 order_by
=VersionGroup
.id.asc(),
1967 Pokemon
.all_abilities
= relation(Ability
,
1968 secondary
=PokemonAbility
.__table__
,
1969 order_by
=PokemonAbility
.slot
.asc(),
1971 backref
=backref('all_pokemon',
1972 order_by
=Pokemon
.order
.asc(),
1975 Pokemon
.abilities
= relation(Ability
,
1976 secondary
=PokemonAbility
.__table__
,
1978 Pokemon
.id == PokemonAbility
.pokemon_id
,
1979 PokemonAbility
.is_dream
== False,
1982 order_by
=PokemonAbility
.slot
.asc(),
1983 backref
=backref('pokemon',
1984 order_by
=Pokemon
.order
.asc(),
1987 Pokemon
.dream_ability
= relation(Ability
,
1988 secondary
=PokemonAbility
.__table__
,
1990 Pokemon
.id == PokemonAbility
.pokemon_id
,
1991 PokemonAbility
.is_dream
== True,
1994 backref
=backref('dream_pokemon',
1995 order_by
=Pokemon
.order
,
1998 Pokemon
.pokemon_color
= relation(PokemonColor
,
2001 Pokemon
.color
= association_proxy('pokemon_color', 'name')
2002 Pokemon
.dex_numbers
= relation(PokemonDexNumber
,
2004 order_by
=PokemonDexNumber
.pokedex_id
.asc(),
2006 Pokemon
.egg_groups
= relation(EggGroup
,
2007 secondary
=PokemonEggGroup
.__table__
,
2009 order_by
=PokemonEggGroup
.egg_group_id
.asc(),
2010 backref
=backref('pokemon', order_by
=Pokemon
.order
.asc()))
2011 Pokemon
.evolution_chain
= relation(EvolutionChain
,
2013 backref
=backref('pokemon', order_by
=Pokemon
.order
.asc()))
2014 Pokemon
.child_pokemon
= relation(Pokemon
,
2015 primaryjoin
=Pokemon
.id==PokemonEvolution
.from_pokemon_id
,
2016 secondary
=PokemonEvolution
.__table__
,
2017 secondaryjoin
=PokemonEvolution
.to_pokemon_id
==Pokemon
.id,
2018 backref
=backref('parent_pokemon', uselist
=False))
2019 Pokemon
.flavor_text
= relation(PokemonFlavorText
,
2020 order_by
=PokemonFlavorText
.version_id
.asc(),
2022 Pokemon
.forms
= relation(PokemonForm
,
2023 primaryjoin
=Pokemon
.id==PokemonForm
.form_base_pokemon_id
,
2024 order_by
=(PokemonForm
.order
.asc(), PokemonForm
.identifier
.asc()))
2025 Pokemon
.default_form
= relation(PokemonForm
,
2027 Pokemon
.id==PokemonForm
.form_base_pokemon_id
,
2028 PokemonForm
.is_default
==True),
2030 Pokemon
.pokemon_habitat
= relation(PokemonHabitat
,
2032 Pokemon
.habitat
= association_proxy('pokemon_habitat', 'name')
2033 Pokemon
.items
= relation(PokemonItem
,
2035 Pokemon
.generation
= relation(Generation
,
2038 Pokemon
.shape
= relation(PokemonShape
,
2041 Pokemon
.stats
= relation(PokemonStat
,
2043 order_by
=PokemonStat
.stat_id
.asc(),
2045 Pokemon
.types
= relation(Type
,
2046 secondary
=PokemonType
.__table__
,
2048 order_by
=PokemonType
.slot
.asc(),
2049 backref
=backref('pokemon', order_by
=Pokemon
.order
))
2051 PokemonDexNumber
.pokedex
= relation(Pokedex
,
2052 innerjoin
=True, lazy
='joined')
2054 PokemonEvolution
.from_pokemon
= relation(Pokemon
,
2055 primaryjoin
=PokemonEvolution
.from_pokemon_id
==Pokemon
.id,
2057 backref
='child_evolutions')
2058 PokemonEvolution
.to_pokemon
= relation(Pokemon
,
2059 primaryjoin
=PokemonEvolution
.to_pokemon_id
==Pokemon
.id,
2061 backref
=backref('parent_evolution', uselist
=False))
2062 PokemonEvolution
.child_evolutions
= relation(PokemonEvolution
,
2063 primaryjoin
=PokemonEvolution
.from_pokemon_id
==PokemonEvolution
.to_pokemon_id
,
2064 foreign_keys
=[PokemonEvolution
.to_pokemon_id
],
2065 backref
=backref('parent_evolution',
2066 remote_side
=[PokemonEvolution
.from_pokemon_id
],
2068 PokemonEvolution
.trigger
= relation(EvolutionTrigger
,
2069 innerjoin
=True, lazy
='joined',
2070 backref
='evolutions')
2071 PokemonEvolution
.trigger_item
= relation(Item
,
2072 primaryjoin
=PokemonEvolution
.trigger_item_id
==Item
.id,
2073 backref
='triggered_evolutions')
2074 PokemonEvolution
.held_item
= relation(Item
,
2075 primaryjoin
=PokemonEvolution
.held_item_id
==Item
.id,
2076 backref
='required_for_evolutions')
2077 PokemonEvolution
.location
= relation(Location
,
2078 backref
='triggered_evolutions')
2079 PokemonEvolution
.known_move
= relation(Move
,
2080 backref
='triggered_evolutions')
2081 PokemonEvolution
.party_pokemon
= relation(Pokemon
,
2082 primaryjoin
=PokemonEvolution
.party_pokemon_id
==Pokemon
.id,
2083 backref
='triggered_evolutions')
2084 PokemonEvolution
.trade_pokemon
= relation(Pokemon
,
2085 primaryjoin
=PokemonEvolution
.trade_pokemon_id
==Pokemon
.id)
2087 PokemonFlavorText
.version
= relation(Version
, innerjoin
=True, lazy
='joined')
2088 PokemonFlavorText
.language
= relation(Language
, innerjoin
=True, lazy
='joined')
2090 PokemonForm
.form_base_pokemon
= relation(Pokemon
,
2091 primaryjoin
=PokemonForm
.form_base_pokemon_id
==Pokemon
.id,
2093 PokemonForm
.unique_pokemon
= relation(Pokemon
,
2094 primaryjoin
=PokemonForm
.unique_pokemon_id
==Pokemon
.id,
2095 backref
=backref('unique_form', uselist
=False))
2096 PokemonForm
.version_group
= relation(VersionGroup
,
2098 PokemonForm
.form_group
= association_proxy('form_base_pokemon', 'form_group')
2099 PokemonForm
.pokeathlon_stats
= relation(PokemonFormPokeathlonStat
,
2100 order_by
=PokemonFormPokeathlonStat
.pokeathlon_stat_id
,
2101 backref
='pokemon_form')
2103 PokemonFormGroup
.pokemon
= relation(Pokemon
,
2105 backref
=backref('form_group', uselist
=False))
2107 PokemonFormPokeathlonStat
.pokeathlon_stat
= relation(PokeathlonStat
,
2108 innerjoin
=True, lazy
='joined')
2110 PokemonItem
.item
= relation(Item
,
2111 innerjoin
=True, lazy
='joined',
2113 PokemonItem
.version
= relation(Version
,
2114 innerjoin
=True, lazy
='joined')
2116 PokemonMove
.pokemon
= relation(Pokemon
,
2117 innerjoin
=True, lazy
='joined',
2118 backref
='pokemon_moves')
2119 PokemonMove
.version_group
= relation(VersionGroup
,
2120 innerjoin
=True, lazy
='joined')
2121 PokemonMove
.machine
= relation(Machine
,
2123 Machine
.version_group_id
==PokemonMove
.version_group_id
,
2124 Machine
.move_id
==PokemonMove
.move_id
),
2125 foreign_keys
=[Machine
.version_group_id
, Machine
.move_id
],
2127 backref
='pokemon_moves')
2128 PokemonMove
.move
= relation(Move
,
2129 innerjoin
=True, lazy
='joined',
2130 backref
='pokemon_moves')
2131 PokemonMove
.method
= relation(PokemonMoveMethod
,
2132 innerjoin
=True, lazy
='joined')
2134 PokemonStat
.stat
= relation(Stat
,
2135 innerjoin
=True, lazy
='joined')
2138 Region
.generation
= relation(Generation
, uselist
=False)
2139 Region
.version_group_regions
= relation(VersionGroupRegion
,
2140 order_by
=VersionGroupRegion
.version_group_id
.asc(),
2142 Region
.version_groups
= association_proxy('version_group_regions', 'version_group')
2145 Stat
.damage_class
= relation(MoveDamageClass
,
2148 StatHint
.stat
= relation(Stat
,
2153 SuperContestCombo
.first
= relation(Move
,
2154 primaryjoin
=SuperContestCombo
.first_move_id
==Move
.id,
2155 innerjoin
=True, lazy
='joined',
2156 backref
='super_contest_combo_first')
2157 SuperContestCombo
.second
= relation(Move
,
2158 primaryjoin
=SuperContestCombo
.second_move_id
==Move
.id,
2159 innerjoin
=True, lazy
='joined',
2160 backref
='super_contest_combo_second')
2163 Type
.damage_efficacies
= relation(TypeEfficacy
,
2164 primaryjoin
=Type
.id==TypeEfficacy
.damage_type_id
,
2165 backref
=backref('damage_type', innerjoin
=True, lazy
='joined'))
2166 Type
.target_efficacies
= relation(TypeEfficacy
,
2167 primaryjoin
=Type
.id==TypeEfficacy
.target_type_id
,
2168 backref
=backref('target_type', innerjoin
=True, lazy
='joined'))
2170 Type
.generation
= relation(Generation
,
2173 Type
.damage_class
= relation(MoveDamageClass
,
2177 Version
.generation
= association_proxy('version_group', 'generation')
2179 VersionGroup
.versions
= relation(Version
,
2181 order_by
=Version
.id,
2182 backref
=backref('version_group', lazy
='joined'))
2183 VersionGroup
.generation
= relation(Generation
,
2184 innerjoin
=True, lazy
='joined',
2185 backref
='version_groups')
2186 VersionGroup
.version_group_regions
= relation(VersionGroupRegion
,
2187 backref
='version_group')
2188 VersionGroup
.regions
= association_proxy('version_group_regions', 'region')