D10d3

InFlightrepairs-TextAdventure

Oct 28th, 2014
550
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. In Flight Repairs V0.6 By D10d3
  3. A Text Adventure
  4.  
  5. Version History:
  6. V0.5 traversable map, inventory, and trigger-able events
  7. V0.6 Bug Fixing, discreet inventory
  8.  
  9. This is a very simple text adventure. Each room in the map is a function that can call the functions for adjacent rooms.
  10. All events and inventory are carried from room to room in a list called Status. Events in the
  11. list will be a series of 1's and 0's, 1 if the event has been triggered, 0 if not.
  12.  
  13. Plot: player wakes up from cold sleep and his ship is crippled, he needs to repair it and save the rest of his
  14. crew in cold sleep.
  15.  
  16. Solution: Player needs the suit to get in cargo hold, needs to get the tools in cargo hold to fix leak. needs to
  17. fix the engine (via a small puzzle) and get keycard to access flightdeck, and needs all of these event complete and
  18. have possession of the keycard to access the flight deck and reset flight computer. Finally return to the cryo pod.
  19.  
  20. Reactor puzzle:
  21. the main reactor needs to be restarted in order, first unlock the deuturium valves, then charge
  22. magnetic constrictors, then activate ionization lasers.
  23.  
  24. Items:
  25. key-card
  26. toolbox
  27. spacesuit
  28.  
  29. events:
  30. hull breach repaired
  31. engine fixed
  32. flight computer reset.
  33. """
  34.  
  35. status = [100,0,0,0]    #default status: Health 100, Hull breached, Engine damaged, Flight Computer off, no inventory
  36.                         #Note: Health isn't actually used in this version, it's included for future implementation
  37. inventory = ["uniform"]
  38.  
  39. #def room(status):                  #This is the template for each room
  40.     #room = """description"""       #This description is read now and can be printed at will later
  41.     #print room
  42.     #valid = False
  43.     #while not valid:               #This is the command loop, player can keep entering commands at will
  44.         #choice = raw_input ('> ')
  45.         #choice = choice.lower()
  46.         #if "statdebug" in choice:  #A debug routine that let's me see what is in Status while testing
  47.             #print status
  48.         #elif "look" in choice:     #Allows player ro redisplay the description
  49.             #print room
  50.         #elif input:                #Room specific commands
  51.             #bla bla bla
  52.         #else:                      #General error trap for unrecognised commands
  53.             #print "Command not recognized"
  54.     #return status
  55.    
  56. def error():
  57.     print "Your code sucks D10d3, try again"
  58.     quit()
  59.  
  60. def statdebug(status,inventory):
  61.             print"Status:"
  62.             print status
  63.             print " "
  64.             print "Inventory:"
  65.             print inventory
  66.    
  67. def crewquarters(status):
  68.     room = """
  69.     Crew Quarters
  70.     This room has several bunks, a set of lockers, cryotubes set against one
  71.     wall and a small bathroom at the back.
  72.     Exits:
  73.     <1> Common Room """
  74.     print room
  75.     while True:
  76.         choice = raw_input ('> ')
  77.         choice = choice.lower()
  78.         if "bunk" in choice:
  79.             print "This is no time for sleeping"
  80.         elif "statdebug" in choice:
  81.             statdebug(status,inventory)
  82.         elif "compdebug" in choice:
  83.             computer(status)
  84.         elif "cryo" in choice and status[3] == 0:
  85.             print "There is still work to be done before you can return to your cryotube"
  86.         elif "cryo" in choice and status[3] == 1:
  87.             win()
  88.         elif "locker" in choice:
  89.             print "Looking through the lockers reveals a space suit in one"
  90.         elif "suit" in choice:
  91.             print "you pull out the suit and put it on."
  92.             inventory.append("suit")
  93.         elif "bathroom" in choice:
  94.             print "You don't need to go right now"
  95.         elif choice == "1":
  96.             commonroom(status)
  97.         elif "look" in choice:
  98.             print room
  99.         elif "quit" in choice:
  100.             print "Thank you for playing."
  101.             quit()
  102.         else:
  103.             print "Command not recognized"
  104.  
  105. def commonroom(status):
  106.     room = """
  107.     Common Room
  108.     This is the central living area of the ship. There is a small kitchen with
  109.     a table and chairs securely bolted to the floor as well as several work
  110.     stations. Door here lead fore and aft as well as laterally.
  111.     The door leading aft is an airlock
  112.     Exits:
  113.     <1> Starboard - Crew Quarters
  114.     <2> Fore - Flight Deck
  115.     <3> Port - Medical Bay
  116.     <4> Aft - Cargo Hold
  117.     """
  118.     print room
  119.     while True:
  120.         choice = raw_input ('> ')
  121.         choice = choice.lower()
  122.         if choice == "1":
  123.             crewquarters(status)
  124.         elif "look" in choice:
  125.             print room
  126.         elif "quit" in choice:
  127.             print "Thank you for playing."
  128.             quit()
  129.         elif "statdebug" in choice:
  130.             statdebug(status,inventory)
  131.         elif choice == "2":
  132.             if "keycard" in inventory:
  133.                 print "The door lock beeps when you wave you keycard over it"
  134.                 flightdeck(status)
  135.             elif "keycard" not in inventory:
  136.                 print 'The door will not open. The small panel next to it reads "LOCKED"'
  137.             else:
  138.                 error()
  139.         elif choice == "3":
  140.             medbay(status)
  141.         elif choice == "4":
  142.             if "suit" in inventory and status[1]==0:
  143.                 print "You enter the airlock and cycle it. "
  144.                 print "There is a hiss and then silence as the air is pumped out"
  145.                 cargohold(status)
  146.             elif "suit" not in inventory and status[1]==0:
  147.                 print "As the air is sucked from the airlock you regret not wearing a space suit"
  148.                 print "You asphyxiate and die"
  149.                 quit()
  150.             elif status[1]==1:
  151.                 print "The airlock registers normal pressure and allows you to pass"
  152.                 cargohold(status)
  153.             else:
  154.                 error()
  155.         #...
  156.         else:
  157.             print "Command not recognized"
  158.  
  159. def cargohold(status):
  160.     room = """
  161.     Cargo Hold
  162.     This cavernous space connects the front and back of the ship. Large crates
  163.     are secured to the deck.    There is a rack of tools here and airlock doors
  164.     leading fore and aft.
  165.     Exits:
  166.     <1> Fore - Common Room
  167.     <2> Aft - Engine Room """
  168.     print room
  169.     if status[1] == 0:
  170.         print "There is a small hole in the hull where an asteroid has struck the ship"
  171.     else:
  172.         print "The repair patch is holding nicely, keeping the air where it's supposed to be"
  173.        
  174.     while True:
  175.         choice = raw_input ('> ')
  176.         choice = choice.lower()
  177.         if choice == "1":
  178.             print "You step into the forward airlock and cycle it"
  179.             commonroom(status)
  180.         elif "look" in choice:
  181.             print room
  182.         elif "quit" in choice:
  183.             print "Thank you for playing."
  184.             quit()
  185.         elif "statdebug" in choice:
  186.             statdebug(status,inventory)
  187.         elif choice == "2":
  188.             print "You step into the forward airlock and cycle it"
  189.             engineroom(status)
  190.         elif "repair" in choice and "tools" not in inventory:
  191.             print "You will need tools to repair this hole"
  192.         elif "hole" in choice and "tools" in inventory:
  193.             if status[1]==0:
  194.                 print "Using your toolkit you apply a patch to the hole and seal it"
  195.                 print "With a hiss the life support systems pump air back into the room"
  196.                 status[1] = 1
  197.             else:
  198.                 print"You've repaired this as well as you can at the moment"
  199.         elif "tools" in choice and "tools" not in inventory:
  200.             print "These tools could be useful, you get a toolbox from the rack"
  201.             inventory.append("tools")
  202.         elif "tools" in choice and "tools" in inventory:
  203.             print"You're tool box should be able to repair some of the ship's damage"
  204.        
  205.         else:
  206.             print "Command not recognized"
  207.  
  208. def medbay(status):
  209.     room = """
  210.     Med-Bay
  211.     This is a small infirmary. There is a bed with an auto-doc built into it.
  212.     The only door leads back into the Common Room
  213.     Exits:
  214.     <1> Port - Common Room"""
  215.     print room
  216.     while True:
  217.         choice = raw_input ('> ')
  218.         choice = choice.lower()
  219.         if "statdebug" in choice:
  220.             statdebug(status,inventory)
  221.         elif "look" in choice:
  222.             print room
  223.         elif "quit" in choice:
  224.             print "Thank you for playing."
  225.             quit()
  226.         elif choice == "1":
  227.             commonroom(status)
  228.         else:
  229.             print "Command not recognized"
  230.    
  231. def flightdeck(status):
  232.     room = """
  233.     Flight Deck
  234.     The main navigational and manoeuvring console is in this room.
  235.     A door leads aft.
  236.     Exits:
  237.     <1> Aft - Common Room"""
  238.     print room
  239.     if status[3] == 0:
  240.         print "The navigational computer is in standby mode, it will need to be reset to continue to your destination"
  241.     elif status[3] == 1:
  242.         print "The navigational console is in cruise mode, the ship is under way"
  243.     else:
  244.         error()
  245.     while True:
  246.         choice = raw_input ('> ')
  247.         choice = choice.lower()
  248.         if "statdebug" in choice:
  249.             statdebug(status,inventory)
  250.         elif "look" in choice:
  251.             print room
  252.         elif "quit" in choice:
  253.             print "Thank you for playing."
  254.             quit()
  255.         elif choice == "1":
  256.             commonroom(status)
  257.         #check hull breach
  258.         elif "computer" in choice and status[3] == 0 and status[1] == 0:
  259.             print "As you try to reset the navigational computer it gives you an error 'Hull Breach Detected'"
  260.             print "It is still in standby mode"
  261.         elif "reset" in choice and status[3] == 0 and status[1] == 0:
  262.             print "As you try to reset the navigational computer it gives you an error 'Hull Breach Detected'"
  263.             print "It is still in standby mode"
  264.         #check engine on
  265.         elif "computer" in choice and status[3] == 0 and status[2] == 0:
  266.             print "As you try to reset the navigational computer it gives you an error 'Drive Currently Offline'"
  267.             print "It is still in standby mode"
  268.         elif "reset" in choice and status[3] == 0 and status[2] == 0:
  269.             print "As you try to reset the navigational computer it gives you an error 'Drive Currently Offline'"
  270.             print "It is still in standby mode"
  271.         #all systems go
  272.         elif "computer" in choice and status[3] == 0 and status[2] == 1 and status[1] == 1:
  273.             print "You reset the navicomputer and reactivate the autopilot"
  274.             status[3] = 1
  275.         elif "reset" in choice and status[3] == 0 and status[2] == 1 and status[1] == 1:
  276.             print "You reset the navicomputer and reactivate the autopilot"
  277.             status[3] = 1
  278.         #Navi already on
  279.         elif "computer" in choice and status[3] == 1:
  280.             print "The navicomputer is functioning correctly, there is no need to mess with it"
  281.         elif "reset" in choice and status[3] == 1:
  282.             print "The navicomputer is functioning correctly, there is no need to mess with it"
  283.         else:
  284.             print "Command not recognized"
  285.  
  286. def engineroom(status):
  287.     room = """
  288.     Engine Room
  289.     This large room is filled almost entirely with machinery. Dominating the
  290.     center of the room is   the primary fusion reactor. The engineering control
  291.     computer screens show a variety of metrics and updates on the engines
  292.     and ship systems. An airlock leads forward to the cargo hold.
  293.     Exits:
  294.     <1> Fore - Cargo Hold
  295.     """
  296.     print room
  297.     if status[2] == 0:
  298.         print "There is a red flashing light on the Engineering Computer"
  299.     else:
  300.         print "The reactor is humming steadily."
  301.     if "keycard" not in inventory:
  302.         print "There is a keycard sitting on the Engineering Computer."
  303.     else:
  304.         print ""
  305.     while True:
  306.         choice = raw_input ('> ')
  307.         choice = choice.lower()
  308.         if "statdebug" in choice:
  309.             statdebug(status,inventory)
  310.         elif "look" in choice:
  311.             print room
  312.         elif "quit" in choice:
  313.             print "Thank you for playing."
  314.             quit()
  315.         elif choice == "1":
  316.             cargohold(status)
  317.         elif "computer" in choice and status[2] == 0:
  318.             computer(status)
  319.         elif "computer" in choice and status[2] == 1:
  320.             print "The computer is in standby mode awaiting commands from the flight computer"
  321.         elif "keycard" in choice and "keycard" not in inventory:
  322.             inventory.append("keycard")
  323.             print "You pick up the keycard and slip it in a pocket"
  324.         else:
  325.             print "Command not recognized"
  326.  
  327. def computer(status):
  328.     room = """
  329.     Engineering Computer
  330.     This computer controls the fusion drive of the ship.
  331.     """
  332.     print room
  333.     compstat = [0,0,0]
  334.     while True:
  335.         #Engineering Status Displays
  336.         print " "
  337.         print "________________________________________"
  338.         print "|    -=SYSTEMS DISPLAY=-     |"
  339.         if compstat[0] == 0:
  340.             print"|  Magnetic Constrictors: OFF     |"
  341.         elif compstat[0] ==1:
  342.             print"|  Magnetic Constrictors: ENGAGED |"
  343.         else:
  344.             error()
  345.         if compstat[1] == 0:
  346.             print"|  Deuterium Valves: LOCKED       |"
  347.         elif compstat[1] ==1:
  348.             print"|  Deuterium Valves: OPEN     |"
  349.         else:
  350.             error()
  351.         if compstat[2] == 0:
  352.             print"|  Ionization Lasers: OFF     |"
  353.         elif compstat[2] ==1:
  354.             print"|  Ionization Lasers: ACTIVE  |"
  355.         else:
  356.             error()
  357.         print"|  System Commands:           |"
  358.         print "|  <1> Engage Magnetic Constrictors  |"
  359.         print "|  <2> Open Deuterium Valves     |"
  360.         print "|  <3> Activate Ionization Lasers    |"
  361.         print "|  <4> Log Off               |"
  362.         print "----------------------------------------"
  363.         print " "
  364.         print " "
  365.         #begin command loop and logic testing
  366.         choice = raw_input ('ENTER COMMAND: ')
  367.         choice = choice.lower()
  368.         #Constrictors
  369.         if choice == "1" and compstat[1] == 0:
  370.             print "ERROR BAD STARTUP SEQUENCE"
  371.             print "RESETTING SYSTEM"
  372.             compstat = [0,0,0]
  373.         elif choice == "1" and compstat[0] == 1:
  374.             print "MAGNETIC CONSTRICTORS ALREADY ENGAGED"
  375.         elif choice == "1" and compstat[1] == 1:
  376.             print "ENGAGING MAGNETIC CONSTRICTORS"
  377.             print "(a deep hum emanates from the machinery behind you)"
  378.             compstat[0] = 1
  379.         #Valves
  380.         elif choice == "2" and compstat[1] == 0:
  381.             print "OPENING DEUTERIUM VALVES"
  382.             print "(you hear a series of clacks in the machinery overhead)"
  383.             compstat[1] = 1
  384.         elif choice == "2" and compstat[1] == 1:
  385.             print "DEUTERIUM VALVES ALREADY OPEN"
  386.         #Lasers
  387.         elif choice == "3" and compstat[0] == 1 and compstat[1] == 1:
  388.             print "IONIZATION LASERS ACTIVE"
  389.             print "START-UP SEQUENCE COMPLETE"
  390.             print "SYSTEMS NOMINAL AND RUNNING"
  391.             print "DRIVE SYSTEMS READY FOR COMMANDS FROM NAVIGATION"
  392.             status[2] = 1
  393.             engineroom(status)
  394.         else:
  395.             print "ERROR BAD STARTUP SEQUENCE"
  396.             print "RESETTING SYSTEM"
  397.             print " "
  398.            
  399.             compstat = [0,0,0]
  400.  
  401. def win():
  402.     print"""
  403.     Having repaired the ship and set it back on it's path you return to your
  404.     cryopod to continue your long journey. As the lights dim and the stasis
  405.     drugs take effect you drift off to sleep knowing the job was well done.
  406.    
  407.     You Win!
  408.     Thank you for playing In Flight Repairs
  409.    
  410.  
  411.     """
  412.     exit()
  413.    
  414. #***Game starts running here with initial description and calls the commonroom function*** 
  415. print"""
  416. ***
  417. In Flight Repairs V0.6 by D10d3
  418. A small text adventure
  419. Use keywords when interacting with objects
  420. Use <exit> numbers to change rooms
  421. Type "look" to see the room description again
  422. Type "quit" to leave this game
  423. ***
  424.  
  425. You awaken to a beeping sound in your cryopod. The small screen in the pod
  426. informs you that the ship has sustained some damage from an asteroid strike.
  427. The main drive is offline and the navicomputer is currently in standby mode.
  428. The computer has awakened you from cold-sleep to render repairs.
  429.  
  430. After taking a moment to absorb this you open the cryopod and step out"""
  431. crewquarters(status)
RAW Paste Data