Ejemplo n.º 1
0
 def go(cls, game_state, parsed_command):
     new_room_name = parsed_command["room"]
     new_room = game_state.get_room_by_name(new_room_name)
     if new_room.locked is False:
         current_room = game_state.get_current_room()
         current_room.visited = True
         game_state.player.previousRoom = game_state.player.currentRoom
         game_state.player.currentRoom = new_room.roomName
         if game_state.player.status == "poisoned":
             game_state.poison_effect()
         if game_state.player.bleeding:
             game_state.bleeding_effect()
         game_state.display_current_room()
     else:
         if "masterKey" in game_state.player.inventory:
             print "You unlocked this room using the master key."
             new_room.locked = False
             current_room = game_state.get_current_room()
             current_room.visited = True
             game_state.player.previousRoom = game_state.player.currentRoom
             game_state.player.currentRoom = new_room.roomName
             if game_state.player.status == "poisoned":
                 game_state.poison_effect()
             if game_state.player.bleeding:
                 game_state.bleeding_effect()
             game_state.display_current_room()
         else:
             print "This room is locked."
Ejemplo n.º 2
0
 def take(cls, game_state, parsed_command):
     if "object" in parsed_command and parsed_command["object"] is not "":
         item_name = parsed_command["object"]
         item = game_state.get_item_by_name(item_name)
         game_state.player.add_to_inventory(item.name)
         game_state.get_current_room().remove_item(item.name)
         message = "{} is added to your inventory.".format(item.displayName)
         print message.capitalize()
     else:
         print "You cannot take that."
Ejemplo n.º 3
0
 def drop(cls, game_state, parsed_command):
     if "object" in parsed_command and parsed_command["object"] is not "":
         item_name = parsed_command["object"]
         item = game_state.get_item_by_name(item_name)
         game_state.player.remove_from_inventory(item.name)
         game_state.get_current_room().include_item(item.name)
         message = "{} is dropped from your inventory.".format(
             item.displayName)
         print message.capitalize()
     else:
         print "You cannot drop that."
Ejemplo n.º 4
0
 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."
Ejemplo n.º 5
0
 def back(cls, game_state, parsed_command):
     new_room_name = game_state.player.previousRoom
     # Update current room to visited
     current_room = game_state.get_current_room()
     current_room.visited = True
     # Update player's previous room to current room
     game_state.player.previousRoom = game_state.player.currentRoom
     # Update player's current room to the new room
     new_room = game_state.get_room_by_name(new_room_name)
     if new_room:
         game_state.player.currentRoom = new_room.roomName
         # Display new room description
         game_state.display_current_room()
         if game_state.player.status == "poisoned":
             game_state.poison_effect()
         if game_state.player.bleeding:
             game_state.bleeding_effect()
Ejemplo n.º 6
0
 def familyName(cls, game_state, parsed_command):
     if parsed_command["familyName"] == "imai":
         game_state.player.add_to_inventory("masterKey")
         game_state.get_current_room().remove_feature("zombieSteward")
         print "You befriended the zombie. He gives you the master key and then disappears."