Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.10 KB | None | 0 0
  1. from sys import exit
  2. from random import randint
  3. from textwrap import dedent
  4.  
  5. class Scene(object):
  6.  
  7.     def enter(self):
  8.         print("This scene is not yet configured")
  9.         print("Subclass it and implement enter().")
  10.         exit(1)
  11.  
  12. class Engine(oject):
  13.  
  14.     def __init__(self, scene_map):
  15.         self.scene_map = scene_map
  16.  
  17.     def play(self):
  18.         current_scene = self.scene_map.opening_scene()
  19.         last_scene = self.scene_map.next_scene('finished')
  20.  
  21.         while current_scene != last_scene:
  22.             next_scene_name = current_scene.enter()
  23.             current_scene = self.scene_map.next_scene(next_scene_name)
  24.  
  25.  
  26.         current_scene.enter()
  27.  
  28. class Death(Scene):
  29.  
  30.     quips = [
  31.     "You died. You kinda suck at this.",
  32.     "Your Mom would e proud...if she were smarter.",
  33.     "Such a luser.",
  34.     "I have a small puppy that's better at this.",
  35.     "You're worse than your dad's joes."
  36.  
  37.     ]
  38.  
  39.     def enter(self):
  40.         print(Death.quips[randint(0, len(self.quips)-1)])
  41.         exit(1)
  42.  
  43.  
  44. class CentralCorridor(scene):
  45.  
  46.     def enter(self):
  47.         print(dedent("""
  48.              The Gothons of Planet Percal #25 have invaded your ship and
  49.              destroyed your entire crew. You are the last surviving
  50.              member and your last mission is to get the neutreon destruct
  51.              bomb from the Weapons Armory, put it in the bridge, and
  52.              blow the ship up after getting into an escape pod.
  53.  
  54.              You're running down the central corridor to the Weapons
  55.              Armory when a Gothon jumps out, red scaly skin, dark grimy
  56.              teeth, and evil clown costume flowing around his hate
  57.              filled body. He's blocking the door to the Armory and
  58.              about to pull a weapon to blast you.
  59.              """))
  60.  
  61.         action = input("> ")
  62.  
  63. if action == "shoot!":
  64.     print(dedent("""
  65.            Quick on the draw you yank out your blaster and fire
  66.            it at the Gothon. His clown costume is flowing and
  67.            moving around his body, wich throws off your aim.
  68.            Your laser hits his costume but misses him entirely.
  69.            This completely ruins his brand new costume his mother
  70.            bought him, wich makes him fly into an insane rage
  71.            and blast you repeatedly in the face until you are
  72.            dead. Then he eats you.
  73.            """))
  74.     return 'death'
  75.  
  76. elif action == "dodge!":
  77.       print(dedent("""
  78.            Like a world class boxer you dodge, weave, slip and
  79.            slide right as the Gothon's blaster cranks a laser
  80.            past your head. In the middle of your artful dodge
  81.            your foot slips and you bang your head on the metal
  82.            wall and pass out. You wake up shortly after only to
  83.            die as the Gothon stomps your head and eats you.
  84.            """))
  85.      return 'death'
  86.  
  87.             elif action == "tell a joke":
  88.                 print(dedent("""
  89.                      Lucky for you they made you learn Gothon insults in
  90.                      the academy. You tell the one Gothon joke you know:
  91.                      Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr,
  92.                      fur fvgf nebhaq gur ubhfr. The Gothon stops, tries
  93.                      not to laugh, then busts out laughing and can't move.
  94.                      the head putting him down, then jump through the
  95.                      Weapon Armory door.
  96.                      """))
  97.                 return 'laser_weapon_armory'
  98.  
  99.             else:
  100.                 print("DOES NOT COMPUTE!")
  101.                 return 'central_corridor'
  102.  
  103. class LaserWeaponArmory(scene):
  104.  
  105.     def enter(self):
  106.         print(dedent("""
  107.              You do a dive roll into the Weapon Armory, crouch and scan
  108.              the room for more Gothons that might be hiding. It's dead
  109.              quiet, too quiet. You stand up and run to the far side of
  110.              the room and find the neutreon bomb in its container.
  111.              There's a keypad lock on the box and you need the code to
  112.              get the bomb out. If you get the code wrong 10 times then
  113.              the lock closes forever and you can't get the bomb. The
  114.              code is 3 digits.
  115.              """))
  116.  
  117. code = f"{randint(1,9)}{randint(1,9)}{randint(1,9)}"
  118. guess = input("[keypad]> ")
  119. guesses = 0
  120.  
  121. while guess != code and guesses < 10:
  122.     print("BZZZZEDDD!")
  123.     guesses += 1
  124.     guess = input("[keypad]> ")
  125.  
  126. if guess == code:
  127.     print(dedent("""
  128.          The container clicks open and the seal breaks, letting
  129.          gas out. You grab the neutron bomb and run as fast as
  130.          you can to the bridge where you must place it in the
  131.          right spot.
  132.          """))
  133.     return 'the_bridge'
  134. else:
  135.     print(dedent("""
  136.          The lock buzzes one last time and then you hear a
  137.          sickening melting sound as the mechanics is fused
  138.          together. You decide to sit there, and finally the
  139.          Gothons blow up the ship from their ship and you die.
  140.          """))
  141.     return 'death'
  142.  
  143.  
  144.  
  145. class TheBridge(scene):
  146.  
  147.     def enter(self):
  148.         print(dedent("""
  149.              You burst onto the bridge with the neutron destruct bomb
  150.              under your arm and surprise 5 Gothons who are trying to
  151.              take control of the ship. Each of them has an even uglier
  152.              clown costume then the last, They haven't pulled their
  153.              weapons out yet, as they see the active bomb under your
  154.              arm and don't want to set it off.
  155.              """))
  156.  
  157.         action = input("> ")
  158.  
  159.         if action == "throw the bomb":
  160.             print(dedent("""
  161.                  In a panic you throw the bomb at the group of Gothons
  162.                  and make a leap for the door. Right as you drop it a
  163.                  Gothon shoots you right in the back killing you. As
  164.                  you die you see another Gothon frantically try to
  165.                  disarm the bomb. You die knowing they will probably
  166.                  blow up when it goes off.
  167.                  """))
  168.             return 'death'
  169.  
  170.         elif action == "slowly place the bomb":
  171.             print(dedent("""
  172.                  You point your blaster at the bomb under your arm and
  173.                  the Gothons put their hands up and start to sweat.
  174.                  You inch backward to the door, open it, and then
  175.                  carefully place the bomb on the floor, pointing your
  176.                  blaster at it. You then jump back through the door,
  177.                  punch the close button and blast the lock so the
  178.                  Gothons can't get out. Now that the bomb is placed
  179.                  you run to the escape pod to get off this tin can.
  180.                  """))
  181.  
  182.             return 'escape_pod'
  183.         else:
  184.             print("DOES NOT COMPUTE!")
  185.             return "the_bridge"
  186.  
  187.  
  188. class EscapePod(scene):
  189.  
  190.     def enter(self):
  191.         print(dedent("""
  192.              You rush through the ship desperately trying to make it to
  193.              the escape pod before the whole ship explodes. It seems
  194.              like hardly any Gothons are on the ship, so your run is
  195.              clear of interference. You get to the chamber with the
  196.              escape pods, and now need to pick one to take. Some of
  197.              them could be damaged but you don't have the time to look.
  198.              There's 5 pods, wich one do you take?
  199.              """))
  200.  
  201.         good_pod = randint(1,5)
  202.         guess = input("[pod #]> ")
  203.  
  204.  
  205.         if int(guess) != good_pod:
  206.             print(dedent("""
  207.                  You jump into pod {guess} and hit the eject button.
  208.                  The pod escapes out into the void of space, then
  209.                  implodes as the hull ruptures, crushing your body into
  210.                  jam jelly.
  211.                  """))
  212.             return 'death'
  213.         else:
  214.             print(dedent("""
  215.                  You jump into pod {guess} and hit the eject button.
  216.                  The pod easilly slides out into space heading to the
  217.                  planet below. As if flies to the planet, you look
  218.                  back and see your ship implode then explode like a
  219.                  bright star, taking out the Gothon ship at the same
  220.                  time. You won!
  221.                  """))
  222.  
  223.             return 'finished'
  224.  
  225. class Finished(scene):
  226.  
  227.     def enter(self):
  228.         print("You won! Good job.")
  229.         return 'finished'
  230.  
  231. class Map(object):
  232.  
  233.     scenes = {
  234.          'central_corridor': CentralCorridor(),
  235.          'laser_weapon_armory': LaserWeaponArmory(),
  236.          'the_bridge': TheBridge(),
  237.          'escape_pod': EscapePod(),
  238.          'death': Death(),
  239.          'finished': Finished(),
  240.          }
  241.  
  242.          def __init__(self, start_scene):
  243.              self.start_scene = start_scene
  244.  
  245.          def next_scene(self, scene_name):
  246.              val = Map.scenes.get(scene_name)
  247.              return val
  248.  
  249.          def opening_scene(self):
  250.              return self.next_scene(self.start_scene)
  251.  
  252. a_map = Map('central_corridor')
  253. a_game = Engine(a_map)
  254. a_game.play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement