from . import Ifc, Utl import th TYPE_NO_USE, TYPE_ESCAPE, TYPE_OFFENSE, TYPE_DEFENSE, TYPE_MISC = range(5) RETURN_TRUE, RETURN_FALSE, HANDLED_TAINTED, HANDLED_NONE = range(4) VEGETARIAN = 1 VEGAN = 2 class Item(object): def __init__(self): self.here = None self.blessed = False self.tainted = False self._living_form = None self.name = '' self.worn = False self.wielded = False self.destroyed = False living_form = Utl.WeakrefProperty('_living_form') def describe(self, article=True): ret = self.kind.adesc if article else self.kind.name if self.name: ret += ' named %s' % self.name if self.worn: ret += ' (worn)' if self.wielded: ret += ' (wielded)' return ret def destroy(self): if isinstance(self.here, th.Monster.Monster): self.here.inventory.remove(self) if self.here.wielded is self: self.here._set_unwielded(self) if self.worn: self.here._set_unworn(self) elif isinstance(self.here, th.Node.Node): self.here.items.remove(self) else: raise ValueError, 'Itm instance is being destroyed, but has no valid "here"' self.destroyed = True self.here = None