def whatsMine(self): for item in self.equipped: if self.equipped[item] == None or self.equipped[item] == []: pass else: ui.write(self.equipped[item].basicDesc[0].upper() + self.equipped[item].basicDesc[1:])
def EquipItem(self, item): if item in self.inventory: if self.equipped[item.equippable[1][0]] == None: self.equipped[item.equippable[1][0]] = item elif self.equipped[item.equippable[1][0]] == [] or isinstance( self.equipped[item.equippable[1][0]], list): #NOTE: THIS MIGHT NOT WORK self.equipped[item.equippable[1][0]].append(item) else: self.equipped[item.equippable[1][0]] = item #I'll put a swap confirmation message here when I'm bothered enough by it else: ui.write("That item is not in your inventory.")
def Close(self, using): if self.opened[0] == True: if self.opened[1] == True: for item in self.containedObjects: item.hidden = True self.location.objects.remove(item) self.opened[1] = False ui.write("You close the " + self.basicDesc) else: ui.write("This " + self.basicDesc + " is already closed.") else: ui.write("This " + self.basicDesc + " cannot be closed.")
def StopBlocking( self, tool ): # Player is attempting to make the npc stop blocking the door if self.doing[0] == 'blocking': if self.doing[1].hidden: self.doing[1].hidden = False ui.write( "The %s is moved out of the way, you can now see a %s behind it" % (self.name, self.doing[1].name.split()[-1])) ui.write("You can now see %s" % self.blocking[1].basicDesc) else: ui.write("%s stops blocking the %s" % ((self.name[0].upper() + self.name[1:]), self.doing[1].name)) self.doing = ['', None, False] return (True) else: ui.write("%s is not blocking anything!" % (self.name[0].upper() + self.name[1:])) return (False)
def TakeItem(self, item): if item in self.currentRoom.objects: if item.taken[0] == "No-one" or item.taken[0] == "you": item.taken[0] = "you" self.inventory.append(item) self.currentRoom.objects.remove(item) for furnishing in self.currentRoom.furnishings: if item in furnishing.containedObjects: furnishing.containedObjects.remove(item) ui.write(item.taken[1][0].upper() + item.taken[1][1:] + ' ' + item.name + ".") else: ui.write("That's not yours.") elif item in self.inventory: ui.write("That's already in your inventory") else: ui.write("That's not in the room.")
def SearchRoom(self): ui.write(self.currentRoom.DescribeRoom())
def ShowLocation(self): ui.write("You are in " + self.currentRoom.search)
def DisplayInventory(self): ui.write("You have in your possession: ") for item in self.inventory: ui.write(item.basicDesc[0].upper() + item.basicDesc[1:])
def DropItem(self, item): if item.droppable == False: ui.write("You need this for something.") else: self.inventory.remove(item) self.currentRoom.objects.append(item)
def Inspect(self, item, using): if isinstance(item, inventoryObject): ui.write("This " + item.name + " belongs to " + item.taken[0] + ".") ui.write(item.inspectDesc[0].upper() + item.inspectDesc[1:]) if len( set(item.equippable[1]).intersection( {"weaponRight", "weaponLeft"})) > 0: ui.write( 'It can easily be held in one hand, the %s looks like it could be used as a weapon.' % item.name) # todo add weapon type here for description if "weaponBoth" in item.equippable[1]: ui.write( 'It is quite heavy, looks like you\'ll need both hands to use this. The %s would make a mighty weapon though.' % item.name) if "clothesTorso" in item.equippable[1]: ui.write( 'The %s is quite thin and lightweight, it won\'t provide much in the way of protection. It does make a fine shirt though.' % item.name) if "clothesLegs" in item.equippable[1]: ui.write( 'It is not very thick or heavy, it won\'t be much use as protection, but the %s looks to be a good fit as trousers.' % item.name) if "armwear" in item.equippable[1]: ui.write( 'This looks like it would fit snugly on your arm, would look quite good there too.' ) if "headgear" in item.equippable[1]: ui.write( 'You feel it would for your head quite well, it\'s almost begging to be put on.' ) if "footwear" in item.equippable[1]: ui.write( 'Looks like these would make some pretty good shoes, they seem they seem about the right size for you.' % item.name) if "armourTorso" in item.equippable[1]: ui.write( 'It looks really quite sturdy, the %s looks like it could offer some serious protection for your upper body.' % item.name) if "armourLegs" in item.equippable[1]: ui.write( 'These look like some heavy duty trousers, the %s could be used to protect your lower body in combat.' % item.name) if "accessories" in item.equippable[1]: ui.write( 'The %s won\'t be much good in the way of utility, you\'re sure it would look quite pretty on you none the less.' % item.name) if item.unlocks[0]: for action in item.unlocks[1]: if action[0] == "K": ui.write( "The writing on this %s makes implies it opens some lock with the ID %s." % (item.name, item.unlocks[1][0][1:])) else: ui.write( "This looks like it could be used to %s open weak or vunerable objects, or doors." % action) elif isinstance(item, roomFurnishing): ui.write(item.inspectDesc[0].upper() + item.inspectDesc[1:]) if item.opened[0]: if item.opened[1]: ui.write('The %s is open' % item.name) if len(item.containedObjects) > 0: ui.write('It contains:') for thing in item.containedObjects: ui.write(thing.name[0].upper() + thing.name[1:]) else: ui.write('The %s is empty.' % item.name) else: ui.write('The %s is closed' % item.name) if item.locked[0]: ui.write('It appears to be locked.') for action in item.locked[1]: if action[0] == "K": ui.write( "It appears like a key or keycard of some kind could be used to unlock this" ) else: ui.write( "Given the appropriate tool, it looks like it could be %sed open with some effort." % action) else: ui.write('It doesn\'t seem to be locked in any way') if item.interactive[0] == True: for interaction in item.interactive[1]: if interaction != "open": ui.write("It looks like this could be " + interaction + "ed.") elif isinstance(item, Door): ui.write(item.description) ui.write('It is to your %s' % item.name[:-5]) if item.opened: ui.write('The door is wide open') if self.currentRoom.name != item.room1.name and item.seeThrough: ui.write('You can see this door leads to %s.' % item.room1.search) elif self.currentRoom.name != item.room2.name and item.seeThrough: ui.write('You can see this door leads to %s.' % item.room2.search) else: ui.write("It isn't clear where this leads") else: ui.write('The door is closed') if item.locked[0]: ui.write( "It seems to be locked. That or it's rusted shut.") for action in item.locked[1]: if action[0] == "K": ui.write( "It appears like a key or keycard of some kind could be used to unlock this" ) else: ui.write( "Given the appropriate tool, it looks like it could be %sed open with some effort." % action) else: ui.write( "It doesn't appear to be locked. It looks as if it could be opened with a heafty pull." ) ui.write("You aren't sure where it leads." ) # ToDo change this for previously visited rooms if item.locked[0] and item.locked[2]: ui.write( "There is a sign next to the door, it is faded but you make out the number %s" % item.locked[1][0][1:]) elif isinstance(item, nonPlayerCharacter): ui.write(item.inspectDesc) if item.hostile: ui.write("They don't look too friendly..") else: ui.write("They look quite approachable.") if item.doing[0] != '': if item.doing[2]: ui.write("They seem rather occupied with %s the %s." % (item.doing[0], item.doing[1].name)) else: ui.write( "They are %s the %s but that doesn’t seem to have their full attention." % (item.doing[0], item.doing[1].name)) else: ui.write("They don't seem to be doing much at the moment.") if len(item.talk) > 0: ui.write(item.name + " might talk to you.")
def Open(self, openTool, player, UsedWhenCalledOnDoor_ignoreButDontRemove): if self.opened[0] == True: if self.opened[1] == False: if self.locked[0] == False: self.opened[1] = True ui.write("The " + self.basicDesc + " is not locked. You open it.") elif self.locked[0] == True: if openTool is not None and openTool != '': self.Unlock(openTool) if self.locked[0] == False: self.opened[1] = True else: ui.write( "The %s won't open. It is locked tight shut, or perhaps only stuck." % self.name) if self.opened[1] == True: # if was closed but now open if len(self.containedObjects) == 0: ui.write("There was nothing inside.") else: ui.write("The " + self.basicDesc + " contains:") for item in self.containedObjects: item.hidden = False self.location.objects.append(item) ui.write(item.basicDesc) elif self.opened[1] == True: ui.write("The door is already open.") if len(self.containedObjects) == 0: ui.write("There was nothing inside.") else: ui.write("The " + self.basicDesc + " contains:") for item in self.containedObjects: ui.write(item.basicDesc) else: ui.write('The ' + self.basicDesc + ' cannot be opened.')
def Unlock(self, key): # furnishing specificUnlock = False generalUnlock = [False, None] if self.locked[0]: if isinstance(key, inventoryObject): if key in jeremy.inventory: ui.write("You attempt to open the %s using the %s." % (self.name, key.name)) if key.unlocks[0]: for item in key.unlocks[1]: if item in self.locked[1]: if item[0] == "K": specificUnlock = True else: generalUnlock = [True, item] if specificUnlock: self.locked[0] = False ui.write( "You insert the %s and the %s effortlessly clicks unlocked" % (key.name, self.name)) elif generalUnlock[0]: self.locked[0] = False self.locked[1] = [] ui.write( "You %s using the %s on the %s for some time until it can finally be opened. It is rather damaged now, doesn't look like that can be locked again" % (generalUnlock[1], key.name, self.name)) else: ui.write( "Looks like that didn't do the job, the %s is still firmly shut" % self.name) else: ui.write( "You won't be able to open anything with that") else: ui.write("You do not possess the %s" % key.name) else: if key is None or key == '': ui.write( "You're going to need something to get this open...") else: ui.write("This isn't something that can be used that way.") else: ui.write("The %s isn't locked..." % self.name) if self.locked[0] and key in jeremy.inventory: for action in self.locked[1]: if action[0] == "K": ui.write( "You think some kind of key or keycard could be used to unlock this." ) else: ui.write( "It looks like it could be %sed open with the appropriate tool." % action)
def Lock(self, key): # furnishing ui.write('lock not (fully?) implemented') if not self.locked[0]: ui.write("It doesn't look like this can be locked at all") return () if not isinstance(key, inventoryObject): if key is None or key == '': ui.write("You're going to need something to lock this with") else: ui.write("This isn't something that can be used that way.") return () if key not in jeremy.inventory: ui.write("You do not possess the %s" % key.name) return () ui.write("You attempt to lock the %s using the %s." % (self.name, key.name)) if key.unlocks[0]: for item in key.unlocks[1]: print(item, self.locked[1]) else: ui.write("You won't be able to lock anything with that") return ()