def takeOutOf (player, arguments): """ takes item out of another item """ itemstr = arguments[0] binstr = arguments[1] inv = player.inventory room = player.location bins = callAdressables(binstr,inv.items + room.items) if not bins: raise ItemNotFound("") allitems = [] for bin in bins: if not "callItems" in dir(bin): raise NotABin("") items = bin.callItems(itemstr) allitems += items if not allitems: raise ItemNotFound for item in allitems: item.takeOut(player)
def leave(self, actor, keyword): """ This method is called, when a player decides to exit the room by direction keyword. """ # TODO: party autofollow exits = callAdressables(keyword, self.exits) if not exits: raise NoSuchDirection("") if len(exits) > 1: raise AmbigousDirection("") newplace = exits[0].direction # quest dungeons if newplace.dungeon and self.dungeon != newplace.dungeon: partyident = actor.party.identifier clone = newplace.dungeon.getClone(partyident) # reattach room # TODO: sure backRefs are index safe ? if clone != newplace.dungeon : rindex = newplace.dungeon.rooms.index(newplace) newplace = clone.rooms[rindex] self.removeCharacter(actor) newplace.addCharacter(actor) actor.locationChanged(self, newplace, keyword) for item in actor.inventory.items: item.locationChanged(self, newplace, keyword)
def callItems (self, keyword): """ Calls every item in collection by keyword and returns responding items @rtype: list<Item> """ items = callAdressables(keyword, self.items) return items
def callCharacters (self, keyword): """ Calls every character in collection by keyword and returns responding characters @rtype: list<Character> """ chars = callAdressables(keyword, self.characters) return chars
def callAttributes(self, keyword): """ Calls every attribute in collection by keyword and returns responding attributes @param keyword: keyword, that should be checked @rtype: list<Attribute> """ attributes = callAdressables(keyword, self.attributes) return attributes
def examine (player, arguments): """ examines something in the room or inventory """ room = player.location exstr = arguments[0] addrspace = [] addrspace += room.details addrspace += player.inventory.items addrspace += room.items addrspace += room.characters things = callAdressables(exstr, addrspace) if not things : raise DetailNotFound("") for obj in things: obj.showLong(player)
def callBodyParts (self, keyword): return callAdressables(keyword, self.bodyparts)