From df945eb601e8c91e2c2dad2085db72c746b21b8b Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Sat, 11 Feb 2012 16:04:25 +0100 Subject: [PATCH] Fix drain/recoil name in MoveMeta The column was named recoil, but positive values meant drain. Rename the column, and introduce a hybrid property for recoil. --- pokedex/data/csv/move_meta.csv | 2 +- pokedex/db/tables.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pokedex/data/csv/move_meta.csv b/pokedex/data/csv/move_meta.csv index 0d997fb..009d089 100644 --- a/pokedex/data/csv/move_meta.csv +++ b/pokedex/data/csv/move_meta.csv @@ -1,4 +1,4 @@ -move_id,meta_category_id,meta_ailment_id,min_hits,max_hits,min_turns,max_turns,recoil,healing,crit_rate,ailment_chance,flinch_chance,stat_chance +move_id,meta_category_id,meta_ailment_id,min_hits,max_hits,min_turns,max_turns,drain,healing,crit_rate,ailment_chance,flinch_chance,stat_chance 1,0,0,,,,,0,0,0,0,0,0 2,0,0,,,,,0,0,1,0,0,0 3,0,0,2,5,,,0,0,0,0,0,0 diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index 61b8905..138e22d 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -32,6 +32,7 @@ from functools import partial from sqlalchemy import Column, ForeignKey, MetaData, PrimaryKeyConstraint, Table, UniqueConstraint from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta from sqlalchemy.ext.associationproxy import association_proxy +from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.orm import backref, relationship from sqlalchemy.orm.session import Session from sqlalchemy.orm.interfaces import AttributeExtension @@ -1351,8 +1352,8 @@ class MoveMeta(TableBase): doc=u"Minimum number of turns the user is forced to use the move") max_turns = Column(Integer, nullable=True, index=True, doc=u"Maximum number of turns the user is forced to use the move") - recoil = Column(Integer, nullable=False, index=True, - doc=u"Recoil damage, in percent of damage done") + drain = Column(Integer, nullable=False, index=True, + doc=u"HP drain (if positive) or Recoil damage (if negative), in percent of damage done") healing = Column(Integer, nullable=False, index=True, doc=u"Healing, in percent of user's max HP") crit_rate = Column(Integer, nullable=False, index=True, @@ -1364,6 +1365,11 @@ class MoveMeta(TableBase): stat_chance = Column(Integer, nullable=False, index=True, doc=u"Chance to cause a stat change, in percent") + @hybrid_property + def recoil(self): + u"""Recoil damage or HP drain; the opposite of `drain`. """ + return -self.drain + class MoveMetaAilment(TableBase): u"""Common status ailments moves can inflict on a single Pokémon, including major ailments like paralysis and minor ailments like trapping.