from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import backref, relation
+from sqlalchemy.sql import and_
from sqlalchemy.types import *
from sqlalchemy.databases.mysql import *
class Language(TableBase):
__tablename__ = 'languages'
id = Column(Integer, primary_key=True, nullable=False)
+ iso3166 = Column(Unicode(2), nullable=False)
name = Column(Unicode(16), nullable=False)
class Location(TableBase):
version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False, autoincrement=False)
move_id = Column(Integer, ForeignKey('moves.id'), nullable=False)
+class MoveEffectCategory(TableBase):
+ __tablename__ = 'move_effect_categories'
+ id = Column(Integer, primary_key=True, nullable=False)
+ name = Column(Unicode(64), nullable=False)
+ can_affect_user = Column(Boolean, nullable=False)
+
+class MoveEffectCategoryMap(TableBase):
+ __tablename__ = 'move_effect_category_map'
+ move_effect_id = Column(Integer, ForeignKey('move_effects.id'), primary_key=True, nullable=False)
+ move_effect_category_id = Column(Integer, ForeignKey('move_effect_categories.id'), primary_key=True, nullable=False)
+ affects_user = Column(Boolean, primary_key=True, nullable=False)
+
class MoveDamageClass(TableBase):
__tablename__ = 'move_damage_classes'
id = Column(Integer, primary_key=True, nullable=False)
Move.priority = association_proxy('move_effect', 'priority')
Move.short_effect = rst.MoveEffectProperty('short_effect')
+MoveEffect.category_map = relation(MoveEffectCategoryMap)
+MoveEffect.categories = association_proxy('category_map', 'category')
+MoveEffectCategoryMap.category = relation(MoveEffectCategory)
+
MoveFlag.flag = relation(MoveFlagType)
MoveFlavorText.generation = relation(Generation)
PokemonMove.pokemon = relation(Pokemon, backref='pokemon_moves')
PokemonMove.version_group = relation(VersionGroup)
+PokemonMove.machine = relation(Machine, backref='pokemon_moves',
+ primaryjoin=and_(Machine.version_group_id==PokemonMove.version_group_id,
+ Machine.move_id==PokemonMove.move_id),
+ foreign_keys=[Machine.version_group_id, Machine.move_id],
+ uselist=False)
PokemonMove.move = relation(Move, backref='pokemon_moves')
PokemonMove.method = relation(PokemonMoveMethod)