mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Made short_effect also an rST column, so effect chance works.
Added support for types in move effects.
This commit is contained in:
parent
fc18219158
commit
774b69f5bd
2 changed files with 9 additions and 5 deletions
|
@ -63,12 +63,13 @@ class UnicodeOutput(Output):
|
||||||
### Text roles
|
### Text roles
|
||||||
|
|
||||||
def generic_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
def generic_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
node = docutils.nodes.strong(text, rawtext, **options)
|
node = docutils.nodes.emphasis(rawtext, text, **options)
|
||||||
return [node], []
|
return [node], []
|
||||||
|
|
||||||
roles.register_local_role('ability', generic_role)
|
roles.register_local_role('ability', generic_role)
|
||||||
roles.register_local_role('item', generic_role)
|
roles.register_local_role('item', generic_role)
|
||||||
roles.register_local_role('move', generic_role)
|
roles.register_local_role('move', generic_role)
|
||||||
|
roles.register_local_role('type', generic_role)
|
||||||
roles.register_local_role('pokemon', generic_role)
|
roles.register_local_role('pokemon', generic_role)
|
||||||
roles.register_local_role('mechanic', generic_role)
|
roles.register_local_role('mechanic', generic_role)
|
||||||
|
|
||||||
|
@ -147,6 +148,9 @@ class MoveEffectProperty(object):
|
||||||
lie and it doesn't yet.
|
lie and it doesn't yet.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, effect_column):
|
||||||
|
self.effect_column = effect_column
|
||||||
|
|
||||||
def __get__(self, move, move_class):
|
def __get__(self, move, move_class):
|
||||||
# Attach a function for handling the `data` role
|
# Attach a function for handling the `data` role
|
||||||
# XXX make this a little more fault-tolerant.. maybe..
|
# XXX make this a little more fault-tolerant.. maybe..
|
||||||
|
@ -155,6 +159,6 @@ class MoveEffectProperty(object):
|
||||||
newtext = getattr(move, text[5:])
|
newtext = getattr(move, text[5:])
|
||||||
return docutils.nodes.Text(newtext, rawtext)
|
return docutils.nodes.Text(newtext, rawtext)
|
||||||
|
|
||||||
return RstString(move.move_effect.effect,
|
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))
|
||||||
|
|
|
@ -178,7 +178,7 @@ class MoveEffect(TableBase):
|
||||||
__tablename__ = 'move_effects'
|
__tablename__ = 'move_effects'
|
||||||
id = Column(Integer, primary_key=True, nullable=False)
|
id = Column(Integer, primary_key=True, nullable=False)
|
||||||
priority = Column(SmallInteger, nullable=False)
|
priority = Column(SmallInteger, nullable=False)
|
||||||
short_effect = Column(Unicode(128), nullable=False)
|
short_effect = Column(Unicode(256), nullable=False)
|
||||||
effect = Column(Unicode(5120), nullable=False)
|
effect = Column(Unicode(5120), nullable=False)
|
||||||
|
|
||||||
class MoveTarget(TableBase):
|
class MoveTarget(TableBase):
|
||||||
|
@ -409,9 +409,9 @@ Move.machines = relation(Machine, 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')
|
||||||
|
|
||||||
Move.effect = rst.MoveEffectProperty()
|
Move.effect = rst.MoveEffectProperty('effect')
|
||||||
Move.priority = association_proxy('move_effect', 'priority')
|
Move.priority = association_proxy('move_effect', 'priority')
|
||||||
Move.short_effect = association_proxy('move_effect', 'short_effect')
|
Move.short_effect = rst.MoveEffectProperty('short_effect')
|
||||||
|
|
||||||
Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
|
Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
|
||||||
order_by=PokemonAbility.slot,
|
order_by=PokemonAbility.slot,
|
||||||
|
|
Loading…
Reference in a new issue