# HG changeset patch # User KarstenBock@gmx.net # Date 1316619156 -7200 # Node ID c4c940fcbc8323f2c4532b0705f9ddf60b813a4b # Parent 915190c0cbc8b39c1459fb40ab8803368f783bf7 Added get_equipable and take_equipable functions. diff -r 915190c0cbc8 -r c4c940fcbc83 src/parpg/components/equip.py --- a/src/parpg/components/equip.py Wed Sep 21 16:48:01 2011 +0200 +++ b/src/parpg/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