mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Balls. Last commit was only data. Here's move flag code.
This commit is contained in:
parent
ee73eeabda
commit
97d2b09d75
3 changed files with 33 additions and 2 deletions
|
@ -578,7 +578,7 @@ The user may still use :move:`U-Turn` to leave the :mechanic:`field`.
|
||||||
|
|
||||||
This effect can be passed with :move:`Baton Pass`."
|
This effect can be passed with :move:`Baton Pass`."
|
||||||
183,0,Lowers the user's Attack and Defense by one level after inflicting damage.,"Inflicts :mechanic:`regular damage`, then :mechanic:`lowers` the user's mechanic:`Attack` and mechanic:`Defense` by one level."
|
183,0,Lowers the user's Attack and Defense by one level after inflicting damage.,"Inflicts :mechanic:`regular damage`, then :mechanic:`lowers` the user's mechanic:`Attack` and mechanic:`Defense` by one level."
|
||||||
184,4,Reflects back any effects the target tries to use on the user this turn.,"Until the user leaves the mechanic:`field`, any non-damaging move targeting the user that inflicts mechanic:`major status effect`\ s, mechanic:`stat change`\ s, or mechanic:`trap`\ ping effects will be reflected at its user.
|
184,4,Reflects back the first effect move used on the user this turn.,"The first non-damaging move targeting the user this turn that inflicts :mechanic:`major status effect`\ s, :mechanic:`stat change`\ s, or :mechanic:`trap`\ ping effects will be reflected at its user.
|
||||||
|
|
||||||
:move:`Defog`, :move:`Memento`, and :move:`Teeter Dance` are not reflected.
|
:move:`Defog`, :move:`Memento`, and :move:`Teeter Dance` are not reflected.
|
||||||
|
|
||||||
|
|
|
|
@ -40,6 +40,8 @@ from docutils.parsers.rst import Parser, roles
|
||||||
import docutils.utils
|
import docutils.utils
|
||||||
from docutils.writers.html4css1 import Writer as HTMLWriter
|
from docutils.writers.html4css1 import Writer as HTMLWriter
|
||||||
|
|
||||||
|
import sqlalchemy.types
|
||||||
|
|
||||||
### Subclasses of bits of docutils, to munge it into doing what I want
|
### Subclasses of bits of docutils, to munge it into doing what I want
|
||||||
class HTMLFragmentWriter(HTMLWriter):
|
class HTMLFragmentWriter(HTMLWriter):
|
||||||
"""Translates reST to HTML, but only as a fragment. Enclosing <body>,
|
"""Translates reST to HTML, but only as a fragment. Enclosing <body>,
|
||||||
|
@ -138,7 +140,7 @@ class RstString(object):
|
||||||
class MoveEffectProperty(object):
|
class MoveEffectProperty(object):
|
||||||
"""Property that wraps a move effect. Used like this:
|
"""Property that wraps a move effect. Used like this:
|
||||||
|
|
||||||
MoveClass.effect = MoveEffectProperty()
|
MoveClass.effect = MoveEffectProperty('effect')
|
||||||
|
|
||||||
some_move.effect # returns an RstString
|
some_move.effect # returns an RstString
|
||||||
some_move.effect.as_html # returns a chunk of HTML
|
some_move.effect.as_html # returns a chunk of HTML
|
||||||
|
@ -162,3 +164,17 @@ class MoveEffectProperty(object):
|
||||||
return RstString(getattr(move.move_effect, self.effect_column),
|
return RstString(getattr(move.move_effect, self.effect_column),
|
||||||
document_properties=dict(
|
document_properties=dict(
|
||||||
_pokedex_handle_data=data_role_func))
|
_pokedex_handle_data=data_role_func))
|
||||||
|
|
||||||
|
class RstTextColumn(sqlalchemy.types.TypeDecorator):
|
||||||
|
"""Generic column type for reST text.
|
||||||
|
|
||||||
|
Do NOT use this for move effects! They need to know what move they belong
|
||||||
|
to so they can fill in, e.g., effect chances.
|
||||||
|
"""
|
||||||
|
impl = sqlalchemy.types.Unicode
|
||||||
|
|
||||||
|
def process_bind_param(self, value, dialect):
|
||||||
|
return unicode(value)
|
||||||
|
|
||||||
|
def process_result_value(self, value, dialect):
|
||||||
|
return RstString(value)
|
||||||
|
|
|
@ -181,6 +181,17 @@ class MoveEffect(TableBase):
|
||||||
short_effect = Column(Unicode(256), nullable=False)
|
short_effect = Column(Unicode(256), nullable=False)
|
||||||
effect = Column(Unicode(5120), nullable=False)
|
effect = Column(Unicode(5120), nullable=False)
|
||||||
|
|
||||||
|
class MoveFlag(TableBase):
|
||||||
|
__tablename__ = 'move_flags'
|
||||||
|
move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
|
||||||
|
move_flag_type_id = Column(Integer, ForeignKey('move_flag_types.id'), primary_key=True, nullable=False, autoincrement=False)
|
||||||
|
|
||||||
|
class MoveFlagType(TableBase):
|
||||||
|
__tablename__ = 'move_flag_types'
|
||||||
|
id = Column(Integer, primary_key=True, nullable=False)
|
||||||
|
name = Column(Unicode(32), nullable=False)
|
||||||
|
description = Column(rst.RstTextColumn(128), nullable=False)
|
||||||
|
|
||||||
class MoveName(TableBase):
|
class MoveName(TableBase):
|
||||||
__tablename__ = 'move_names'
|
__tablename__ = 'move_names'
|
||||||
move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
|
move_id = Column(Integer, ForeignKey('moves.id'), primary_key=True, nullable=False, autoincrement=False)
|
||||||
|
@ -409,10 +420,12 @@ LocationArea.location = relation(Location, backref='areas')
|
||||||
Machine.generation = relation(Generation)
|
Machine.generation = relation(Generation)
|
||||||
|
|
||||||
Move.damage_class = relation(MoveDamageClass, backref='moves')
|
Move.damage_class = relation(MoveDamageClass, backref='moves')
|
||||||
|
Move.flags = association_proxy('move_flags', 'flag')
|
||||||
Move.foreign_names = relation(MoveName, backref='pokemon')
|
Move.foreign_names = relation(MoveName, backref='pokemon')
|
||||||
Move.generation = relation(Generation, backref='moves')
|
Move.generation = relation(Generation, backref='moves')
|
||||||
Move.machines = relation(Machine, backref='move')
|
Move.machines = relation(Machine, backref='move')
|
||||||
Move.move_effect = relation(MoveEffect, backref='moves')
|
Move.move_effect = relation(MoveEffect, backref='moves')
|
||||||
|
Move.move_flags = relation(MoveFlag, backref='move')
|
||||||
Move.target = relation(MoveTarget, backref='moves')
|
Move.target = relation(MoveTarget, backref='moves')
|
||||||
Move.type = relation(Type, backref='moves')
|
Move.type = relation(Type, backref='moves')
|
||||||
|
|
||||||
|
@ -420,6 +433,8 @@ Move.effect = rst.MoveEffectProperty('effect')
|
||||||
Move.priority = association_proxy('move_effect', 'priority')
|
Move.priority = association_proxy('move_effect', 'priority')
|
||||||
Move.short_effect = rst.MoveEffectProperty('short_effect')
|
Move.short_effect = rst.MoveEffectProperty('short_effect')
|
||||||
|
|
||||||
|
MoveFlag.flag = relation(MoveFlagType)
|
||||||
|
|
||||||
MoveName.language = relation(Language)
|
MoveName.language = relation(Language)
|
||||||
|
|
||||||
Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
|
Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
|
||||||
|
|
Loading…
Reference in a new issue