Mercurial > parpg-source
changeset 69:c1959525efda
Added get_equipable and take_equipable functions.
author | KarstenBock@gmx.net |
---|---|
date | Wed, 21 Sep 2011 17:32:36 +0200 |
parents | 8915ff6183b0 |
children | 1b1ab906e76e |
files | components/equip.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/components/equip.py Wed Sep 21 16:48:01 2011 +0200 +++ b/components/equip.py Wed Sep 21 17:32:36 2011 +0200 @@ -41,4 +41,19 @@ except AttributeError: raise SlotInvalidError(slot) return None + +def get_equipable(wearer, slot): + """Return the equipable in the given slot""" + try: + item = getattr(wearer, slot) + return item + except AttributeError: + raise SlotInvalidError(slot) + +def take_equipable(wearer, slot): + """Remove equipable from the given slot and return it""" + item = get_equipable(wearer, slot) + setattr(wearer, slot, None) + return item + \ No newline at end of file