# HG changeset patch # User KarstenBock@gmx.net # Date 1316619156 -7200 # Node ID c1959525efda619fefd0dadcdb571d7c70e79125 # Parent 8915ff6183b00fcd5431f1adff8167c06b296bb8 Added get_equipable and take_equipable functions. diff -r 8915ff6183b0 -r c1959525efda components/equip.py --- 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