mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
De-convolute my attempt at broadening MoveEffectProperty.
This commit is contained in:
parent
d689bd3de3
commit
b3ade1ecf1
2 changed files with 11 additions and 22 deletions
|
@ -128,26 +128,18 @@ class MoveEffectProperty(object):
|
||||||
Use `MoveEffectPropertyMap` for dict-like association proxies.
|
Use `MoveEffectPropertyMap` for dict-like association proxies.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *effect_columns):
|
def __init__(self, effect_column, relationship='move_effect'):
|
||||||
self.effect_columns = effect_columns
|
self.effect_column = effect_column
|
||||||
|
self.relationship = relationship
|
||||||
|
|
||||||
def __get__(self, obj, cls):
|
def __get__(self, obj, cls):
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return self
|
return self
|
||||||
if obj.move_effect is None:
|
if obj.move_effect is None:
|
||||||
return None
|
return None
|
||||||
props = []
|
thing = getattr(obj, self.relationship)
|
||||||
for prop, column in self.effect_columns:
|
prop = getattr(thing, self.effect_column)
|
||||||
prop = getattr(obj, prop)
|
return _markdownify_effect_text(obj, prop)
|
||||||
if prop is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
column = getattr(prop, column)
|
|
||||||
if column is None:
|
|
||||||
print(prop)
|
|
||||||
props.append(column)
|
|
||||||
|
|
||||||
return _markdownify_effect_text(obj, ' '.join(prop for prop in props))
|
|
||||||
|
|
||||||
class MoveEffectPropertyMap(MoveEffectProperty):
|
class MoveEffectPropertyMap(MoveEffectProperty):
|
||||||
"""Similar to `MoveEffectProperty`, but works on dict-like association
|
"""Similar to `MoveEffectProperty`, but works on dict-like association
|
||||||
|
|
|
@ -2063,14 +2063,11 @@ ConquestMoveData.range = relationship(ConquestMoveRange,
|
||||||
innerjoin=True,
|
innerjoin=True,
|
||||||
backref='move_data')
|
backref='move_data')
|
||||||
|
|
||||||
ConquestMoveData.effect = markdown.MoveEffectProperty(('move_effect', 'effect'))
|
ConquestMoveData.effect = markdown.MoveEffectProperty('effect')
|
||||||
ConquestMoveData.effect_map = markdown.MoveEffectPropertyMap(('move_effect', 'effect_map'))
|
ConquestMoveData.effect_map = markdown.MoveEffectPropertyMap('effect_map')
|
||||||
ConquestMoveData.short_effect = markdown.MoveEffectProperty(
|
ConquestMoveData.short_effect = markdown.MoveEffectProperty('short_effect')
|
||||||
('move_effect', 'short_effect'),
|
ConquestMoveData.short_effect_map = markdown.MoveEffectPropertyMap('short_effect_map')
|
||||||
('move_displacement', 'short_effect')
|
ConquestMoveData.displacement = markdown.MoveEffectProperty('effect', relationship='move_displacement')
|
||||||
)
|
|
||||||
ConquestMoveData.short_effect_map = markdown.MoveEffectPropertyMap(('move_effect', 'short_effect_map'))
|
|
||||||
ConquestMoveData.displacement = markdown.MoveEffectProperty(('move_displacement', 'effect'))
|
|
||||||
|
|
||||||
ConquestPokemonEvolution.gender = relationship(Gender,
|
ConquestPokemonEvolution.gender = relationship(Gender,
|
||||||
backref='conquest_evolutions')
|
backref='conquest_evolutions')
|
||||||
|
|
Loading…
Reference in a new issue