def talk(self, about): if about is None: if self.properties['hasBeer']: martini = eng.getItemByName('martini') if eng.inInventory(martini): return "Margaret:\n\"Hello there. I'm Margaret. It's nice to meet you. Isn't this stuff so cool? They were about to run out of beer so I grabbed two glasses. I would offer you one, but it looks like you already have a martini.\"" else: return "Margaret:\n\"Hello there. I'm Margaret. It's nice to meet you. Isn't this stuff so cool? They were about to run out of beer so I grabbed two glasses. Take one if you want it.\"" else: return "Margaret:\n\"Wow, it must have taken them years to collect this stuff.\"" elif about.name == 'artifacts': if 'mummy\'s curse' in eng.getCurrentRoom().items: return "Margaret:\n\"I recognize this one. It's an amulet from ancient Egypt. It's said that any mortal who possesses it would be cursed. Haha, if you believe such a thing!" else: return "Margaret:\n\"So many interesting things here.\"" elif about.name == 'beer': if self.properties['hasBeer']: martini = eng.getItemByName('martini') if eng.inInventory(martini): return "Margaret:\n\"They were almost out at the bar, so I took the last two. I would offer you one, but it looks like you already have a martini.\"" else: beer = eng.getItemByName('beer') eng.addToInventory(beer) self.properties['hasBeer'] = False return "Mararet:\n\"Here, take one! I'm happy to share.\"" else: return "Margaret:\n\"That's the last beer that they had. Enjoy!\"" else: return "She pretends not to hear you. Evidentally she doesn't want to talk about that."
def take(self): #First time user tries to take the took it is in a closed tank with hungry sharks currRoom = eng.getCurrentRoom() sharks = eng.getItemByName('sharks') tank = eng.getItemByName('sharktank') if self.properties['had'] == False and tank.properties[ 'opened'] and sharks.properties['hungry'] == False: self.properties['have'] = True self.properties['had'] = True eng.addToInventory( self) # adds to inventory and removes from current room character = eng.getItemByName('self') character.properties['placesOpened'] += 1 if character.properties['placesOpened'] == 3: tank.properties['hasPlans'] = True currRoom.items.append('secret plans') currRoom.items.remove('emerald') return self.descriptions['secretPlans'] else: emerald = eng.getItemByName('emerald') emerald.visible = True return self.descriptions['underTooth'] #Must have had the tooth once elif self.properties['have'] == False and self.properties['had']: eng.addToInventory( self) # adds to inventory and removes from current room return self.descriptions['takeTooth'] elif self.properties['have']: return self.descriptions['alreadyHave'] else: return self.descriptions['cant']
def open(self): tDrawer = eng.getItemByName('top drawer') if tDrawer is not None: tDrawer.visible = True bDrawer = eng.getItemByName('bottom drawer') if bDrawer is not None: bDrawer.visible = True return self.descriptions['openFC']
def look(self): self.visible = True tDrawer = eng.getItemByName('top drawer') if tDrawer is not None: tDrawer.visible = True bDrawer = eng.getItemByName('bottom drawer') if bDrawer is not None: bDrawer.visible = True return self.descriptions['desc']
def enterRoom(self): if (self.visited == True): return self._printShortDesc() else: self.visited = True purse = eng.getItemByName('purse') purse.visible = True window = eng.getItemByName('bathroomWindow') window.visible = True return self._printLongDesc()
def look(self): torch = eng.getItemByName("torch") if eng.inInventory(torch): hole = eng.getItemByName("hole") bridge = eng.getItemByName("bridge") hole.visible = True bridge.visible = True return self.lightDescription else: return self.longDescription
def open(self): if self.properties['opened'] == True: return self.descriptions['alreadyOpened'] self.properties['opened'] = True cake = eng.getItemByName('cake') cake.visible = True tuna = eng.getItemByName('tuna') tuna.visible = True return self.descriptions['open']
def take(self): martini = eng.getItemByName('martini') if eng.inInventory(martini): return "Margaret:\n\"I would be happy to share one, but they're all out at the bar and it looks like you already have a martini.\"" else: margaret = eng.getItemByName('margaret') if margaret.properties['hasBeer']: eng.addToInventory(self) margaret.properties['hasBeer'] = False return "Margaret:\n\"Here you go. Enjoy!\"" else: return "You already took it."
def open(self): if self.properties['opened'] == True: return self.descriptions['alreadyOpenDesc'] else: self.properties['opened'] = True currRoom = eng.getCurrentRoom() suit = eng.getItemByName('suit') if suit is not None: suit.visible = True gown = eng.getItemByName('gown') if gown is not None: gown.visible = True return self.look()
def open(self): currRoom = eng.getCurrentRoom() if self.properties['drawerOpen']: return self.descriptions['alreadyOpen'] + self._printContents() self.properties['drawerOpen'] = True strop = eng.getItemByName('strop') if strop is not None: strop.visible = True toothpaste = eng.getItemByName('toothpaste') if toothpaste is not None: toothpaste.visible = True return self.descriptions['openVanity'] + self._printContents()
def use(self, ind=None): if not eng.inInventory(self): return "You don't have it" if ind == None: return "Use it on what?" door = eng.getItemByName("wooden door") chest = eng.getItemByName("chest") if ind == door: return "You try the silver key from the hole, but it doesn't fit" elif ind == chest: return chest.open(self) else: return "Thad didn't work"
def open(self, ind): if self.properties["locked"] and ind == None: return "It's locked. How will you open it?" if self.properties["locked"]: silverKey = eng.getItemByName("silver key") if ind == silverKey: self.properties["locked"] = False doorKey = eng.getItemByName("door key") doorKey.visible = True return "The silver key opened the chest. Looks like another key is inside of it. You recognize the unique shape of a door key" else: return "That didn't work" else: return "It's already open"
def touch(self): currRoom = eng.getCurrentRoom() criticA = eng.getItemByName('male critic') criticB = eng.getItemByName('female critic') if "male critic" in currRoom.items or "female critic" in currRoom.items: return self.descriptions['touchNotAlone'] else: if self.properties['hasKey']: k = eng.getItemByName('strange key') k.visible = True return self.descriptions['touchAlone'] + self.descriptions[ 'touchWithKey'] else: return self.descriptions['touchAlone']
def open(self, ind): if self.properties["locked"] and ind == None: return "It's locked. How will you open it?" if self.properties["locked"]: doorKey = eng.getItemByName("door key") silverKey = eng.getItemByName("silver key") if ind == doorKey: self.properties["locked"] = False return "You used to door key to unlock the door" elif ind == silverKey: return "You try the silver key from the hole, but it doesn't fit" else: return "That didn't work" else: return "It's already open"
def take(self): if eng.inInventory(self): return self.descriptions['alreadyTakenSP'] else: billiardTable = eng.getItemByName('billiard table') billiardTable.properties['hasPlans'] = False tank = eng.getItemByName('sharktank') tank.properties['hasPlans'] = False eng.addToInventory(self) # adds to inventory and removes from current room eng.setScore(eng.getScore() + 120) foyer = eng.getRoomByName('Foyer') porch = eng.getRoomByName('Front Porch') foyer.items.remove('old lady') porch.items.append('old lady') return self.descriptions['desc'] + self.descriptions['takeSP']
def look(self): self.visible = True currRoom = eng.getCurrentRoom() mTrap = eng.getItemByName('mousetrap') if mTrap is not None: mTrap.visible = True return self.descriptions['desc']
def look(self): if self.properties["hasKey"]: key = eng.getItemByName("silver key") key.visible = True return "A small hole in the ground. Just big enough to get your foot stuck. There a key sitting in it" else: return "A small hole in the ground"
def look(self): suit = eng.getItemByName('suit') gown = eng.getItemByName('gown') flower = eng.getItemByName('pink flower') if eng.inInventory(suit): description = "You look like a fine gentleman. " if not eng.inInventory(flower): description += "You would look even better with a boutonniere. Maybe there's a flower somewhere around here." return description elif eng.inInventory(gown): description = "You look like a fine lady. " if not eng.inInventory(flower): description += "You would look even better with an accessory. Maybe there's a flower somewhere around here." return description else: return "You check yourself out in a mirror. You look good dressed in all black. You look like you're ready for anything... except a party that is."
def look(self): self.visible = True currRoom = eng.getCurrentRoom() rDuck = eng.getItemByName('rubber duck') if rDuck is not None: rDuck.visible = True return self.descriptions['desc']
def go(self): key = eng.getItemByName('spare key') if self.properties['locked']: return self.descriptions['lockedDoor'] suit = eng.getItemByName("suit") gown = eng.getItemByName("gown") if suit.properties['wearing'] or gown.properties['wearing']: masterBed = eng.getRoomByName('Master Bedroom') hall = eng.getRoomByName('Hallway') currRoom = eng.getCurrentRoom() if currRoom == masterBed: return eng.goToRoom(hall) else: return eng.goToRoom(masterBed) else: return self.descriptions['notDressed']
def investigate(self): #if self.properties['looked']: currRoom = eng.getCurrentRoom() bonekey = eng.getItemByName('bone key') if bonekey is not None: bonekey.visible = True return self.descriptions['searched']
def _printShortDesc(self): purse = eng.getItemByName('purse') if eng.inInventory(purse): return self.descriptions['shortDesc'] else: return self.descriptions['shortDesc'] + self.descriptions[ 'purseDesc']
def enterRoom(self): fridge = eng.getItemByName('fridge') fridge.visible = True if (self.visited == True): return self._printShortDesc() else: self.visited = True return self._printLongDesc()
def use(self, ind): if ind == None: return "Use it on what?" door = eng.getItemByName("wooden door") if ind == door: return door.open(self) else: return "That didn't work"
def take(self): if eng.inInventory(self): return "You already have it" else: eng.addToInventory(self) chest = eng.getItemByName("chest") chest.properties["hasKey"] = False return "You picked up the door key"
def look(self): self.visible = True currRoom = eng.getCurrentRoom() fountainPen = eng.getItemByName('fountain pen') if fountainPen is not None: fountainPen.visible = True letterOpener = eng.getItemByName('letter opener') if letterOpener is not None: letterOpener.visible = True description = self.descriptions['desc'] if 'fountain pen' in currRoom.items and 'letter opener' in currRoom.items: description += self.descriptions['hasPenAndOpener'] elif 'fountain pen' in currRoom.items: description += self.descriptions['hasPen'] elif 'letter opener' in currRoom.items: description += self.descriptions['hasOpener'] return description
def take(self): if eng.inInventory(self): return "You already have it" else: eng.setScore(eng.getScore() + 100) eng.addToInventory(self) eng.getItemByName('billiard table').properties['hasRuby'] = False return "What a find! You slip it into your pocket. The boss will be happy to see this! Or maybe you'll just keep it to yourself. You don't get paid enough for this anyway."
def hit(self): if self.properties['broken']: return "You already broke a window. " else: self.properties['broken'] = True escape = eng.getItemByName('escape') escape.visible = True return "You smash one of the windows. Shards of glass scatter across the floor."
def open(self): if self.properties['opened']: return self.descriptions['alreadyOpened'] else: blueprints = eng.getItemByName('blueprints') if blueprints is not None: blueprints.visible = True return self.descriptions['openMe']
def touch(self): currRoom = eng.getCurrentRoom() tank = eng.getItemByName('sharktank') if self.properties['hungry']: return self.descriptions['crazy'] elif tank.properties['opened'] == False: return tank.descriptions['closedDesc'] else: return self.descriptions['swim']