def drive_car(cls, game_state): car = game_state.get_feature_by_name("car") current_room = game_state.get_current_room() main_gate = game_state.get_feature_by_name("mainGate") if car.running is True: if current_room.roomName == "garage": if main_gate.locked is False: print "You drive the car out of the garage and through the gates, leaving this wretched house behind." if game_state.player.status == "poisoned": print "You've made it out alive!" print "You're driving the 90's Porche 911, pushing gas, and accelerating to the full speed." print "Suddenly the u-pin curve has appeared." print "You're under intoxicated by alcohol or something else." print "You've missed turn and fallen off the edge of the cliff with Porche 911..." print "THE END" else: print "Congratulations, you've made it out alive! THE END." exit() else: print "You drive the car out of the garage into the courtyard. Unfortunately, the gate is locked\n"\ "and you probably don't want to wreck the only vehicle into the hardened gates. You stepped\n"\ "out of the car and out into the courtyard." # Move car to courtyard courtyard = game_state.get_room_by_name("courtyard") current_room.features.remove("car") courtyard.features.append("car") # Move player to courtyard current_room.visited = True game_state.player.previousRoom = game_state.player.currentRoom game_state.player.currentRoom = courtyard.roomName elif current_room.roomName == "courtyard": if main_gate.locked is False: if game_state.player.status == "poisoned": print "You've made it out alive!" print "You're driving the 90's Porche 911, pushing gas, and accelerating to the full speed." print "Suddenly the u-pin curve has appeared." print "You're under intoxicated by alcohol or something else." print "You've missed turn and fallen off the edge of the cliff with Porche 911..." print "THE END" else: print "You drive the car through the gates, leaving this wretched house behind.\n" \ "Congratulations, you've made it out alive! THE END." exit() else: print "The gate is still locked." else: # Logically this should never happen pass else: print "You cannot drive the car; it is not running. Start the car first."
def make_life_potion(cls, game_state): metal_cabinet = game_state.get_feature_by_name("metalCabinet") if "recipeBook" in game_state.player.inventory: print "It seems that you have the recipe book, \"ALL NATURAL\"!" print "You might make something new! (press enter to leave)" # metal_cabinet.status = "redPowder" #test: once metal cabinet is look-able, this will be deleted. if metal_cabinet.status == "redPowder": print "The red power you have is a sun stone powder. " print "Sun stone is a feldspar crystal that weathers out of certain lava flows in south-central Oregon." print "Let's distill it with water.\nYou've got a life potion." game_state.player.add_to_inventory("lifePotion") print "A life potion is added to your inventory. It will automatically revive you for once." metal_cabinet.status = "locked" elif metal_cabinet.status == "bluePowder": print "The blue power you have is a benitoite power." print "Benitoite gem stone is also called as a \"blue diamond\"." print "It is a rare kind of gem and only found in California." print "Let's distill it with water.\nOh no, it started smoking here..." print "You can't mix the water with non-local items..." game_state.player.health = 100 print "Your health got recovered fully." if game_state.player.status != "poisoned": game_state.player.status = "poisoned" print "But you breathed in blue intoxicated smoke." game_state.poison_effect() metal_cabinet.status = "locked" elif metal_cabinet.status == "driedLeaves": print "The dried leaf was green tea leaves. You brewed green tea and sipped it. Not bad at all." metal_cabinet.status = "locked" else: print "You don't have no items to distill a potion." else: print "You don't know the book, \"ALL NATURAL\", do you?" print "You can't make anything. Don't waste your time here. Come back later."
def lift_bench(cls, game_state): bench = game_state.get_feature_by_name("bench") if bench.status == "not_lifted": game_state.player.add_to_inventory("carBatteryJumper") bench.status = "lifted" print "You found a car battery jumper!" else: print "There's nothing else but an old rusted broken shovel."
def open_file_cabinet(cls, game_state): file_cabinet = game_state.get_feature_by_name("fileCabinet") if file_cabinet.object: game_state.player.add_to_inventory(file_cabinet.object) file_cabinet.object = None print "You found a family heirloom of a lion!" else: print "There is nothing interesting in this file cabinet."
def open_dresser(cls, game_state): dresser = game_state.get_feature_by_name("dresser") if dresser.object: game_state.player.add_to_inventory(dresser.object) dresser.object = None print "You found a car key inside the dresser! Looks like it's for a Porsche!" else: print "There's only clothes in here. They're not in your size."
def open_piano(cls, game_state): piano = game_state.get_feature_by_name("piano") if piano.object: game_state.player.add_to_inventory(piano.object) piano.object = None print "You found a bolt cutter inside the piano. Might be useful." else: print "There's nothing in here."
def open_medicineCabinet(cls, game_state): medicine_cabinet = game_state.get_feature_by_name("medicineCabinet") if medicine_cabinet.object: game_state.player.add_to_inventory(medicine_cabinet.object) medicine_cabinet.object = None print "You found an antidote. It says it clears an intoxicated condition." print "But...it is up to you if you trust it or not." else: print "There's nothing else but deodorant and hair products."
def open_pantry(cls, game_state): pantry = game_state.get_feature_by_name("pantry") if pantry.object: game_state.player.add_to_inventory(pantry.object) pantry.object = None print "You found a recipe book, titled ALL NATURAL." print "It does seem to have cooking recipes but herbal mixing formulas." else: print "There's nothing here but rotten food and a dead mouse."
def turn_off_car(cls, game_state): car = game_state.get_feature_by_name("car") if car.running is True: game_state.player.add_to_inventory("carKey") car.running = False car.description = "A 90's Porsche 911. It's currently turned off, but it starts perfectly now." print "You turned off the car and pocket the car key." else: print "The car is already turned off."
def cut_main_gate_lock(cls, game_state): main_gate = game_state.get_feature_by_name("mainGate") if main_gate.locked is True: if "boltCutter" in game_state.player.inventory: main_gate.locked = False main_gate.description = "The gate is wide open to the darkness beyond.\nYou probably don't want " \ "to go out there; there might be killers and wolfs." print "Using the bolt cutter, you cut the chains off the gate and push the gate open to the endless\n" \ "path to darkness with creatures. Not a good idea to walk out." else: print "You cannot open the gate. It is locked with a chain and padlock." else: print "The main gate is already wide open"
def look(cls, game_state, parsed_command): if "feature" in parsed_command and parsed_command["feature"]: feature = game_state.get_feature_by_name(parsed_command["feature"]) print feature.description if feature.name == "bookshelf": cls.pick_out_a_book(game_state) if feature.name == "labTable": cls.make_life_potion(game_state) elif "object" in parsed_command and parsed_command["object"]: item = game_state.get_item_by_name(parsed_command["object"]) print item.description elif parsed_command["object"] == "" and parsed_command["feature"] == ""\ and parsed_command["preposition"] == "": print game_state.display_current_room()
def open_gun_safe(cls, game_state): gun_safe = game_state.get_feature_by_name("gunSafe") if gun_safe.object and gun_safe.locked: passcode = raw_input("Enter the 4-digit number: ") if passcode == "4624": game_state.player.add_to_inventory(gun_safe.object) gun_safe.object = None gun_safe.locked = False gun_safe.description = "The gun safe is unlocked." print "Beep! The safe unlocked and you found a handgun!" else: print "Access denied." else: print "There's nothing else in this gun safe."
def open_metal_cabinet(cls, game_state): metal_cabinet = game_state.get_feature_by_name("metalCabinet") if metal_cabinet.status == "locked": print "Somehow the metal cabinet got locked..." elif metal_cabinet.status in ["redPowder", "bluePowder", "driedLeaf"]: print "You already have selected one. Try to make a potion." cls.make_life_potion(game_state) else: print "There are a blue powder bottle, a red powder bottle and a dried leaves bottle in the each bottle." print "Which one do you need?" picked = False while not picked: picked_bottle = raw_input(">>") if picked_bottle == "": print "Not interested? Never mind." break elif picked_bottle.lower() in [ "blue", "blue powder", "blue powder bottle", "a blue powder bottle", "a blue bottle" ]: metal_cabinet.status = "bluePowder" picked = True elif picked_bottle.lower() in [ "red", "red powder", "red powder bottle", "a red powder bottle", "a red bottle" ]: metal_cabinet.status = "redPowder" picked = True elif picked_bottle.lower() in [ "dried leaves", "dried leaves bottle", "a dried leaves bottle" ]: metal_cabinet.status = "driedLeaves" picked = True else: print "Re-enter the item you need. If you don't want any of items, press ENTER to close cabinet." if picked: cls.make_life_potion(game_state)
def hit_zombie(cls, game_state, parsed_command): zombie = game_state.get_feature_by_name("zombieSteward") if zombie.status == "dead": print "You hit the zombie, it did nothing because it's beyond dead." else: if "knife" in game_state.player.inventory: print "As you charge with a knife towards toward head, she swings her fist across your jaw." print "You took -10% damage, but you successfully stuck a knife deep into her skull." print "You killed the zombie. You found a master key among his remains!" game_state.player.add_to_inventory("masterKey") game_state.player.remove_from_inventory("knife") zombie.status = "dead" else: print "You punch the zombie but it did not stagger." print "It reacted with a counter punch. You take -10% damage." print "You should find a weapon next time." game_state.player.health -= 10 if game_state.player.health <= 0: print "You died." if "lifePotion" in game_state.player.inventory: game_state.revive() else: exit()
def start_car(cls, game_state): car = game_state.get_feature_by_name("car") if car.running is False: if "carKey" in game_state.player.inventory and car.jumped is True: car.running = True game_state.player.remove_from_inventory("carKey") print "You turn the key in the ignition, and the car is now running." elif "carKey" in game_state.player.inventory and "carBatteryJumper" in game_state.player.inventory: car.running = True car.jumped = True game_state.player.remove_from_inventory("carKey") car.description = "A 90's Porsche 911. It's currently running." print "You open the door and pop the hood then attach battery jumper to the battery terminals\n" \ "in the car. Upon turning the keys the dash lights up and the car starts.\n" \ "The car is now running and you remove the batter jumper." elif "carKey" in game_state.player.inventory and car.jumped is False: car.description = "A 90's Porsche 911. Too bad the battery is dead." print "You open the door and attempt to start the car, but the car does not start, nor does the dash\n" \ "light up. The battery is probably dead." else: # Case where the play does not have the car key print "The car is locked. You can't open the car without the car key." else: # Case where the car is already running print "The car is already running."