Advertisement
Guest User

Bill's LPTHW ex. 43

a guest
Jul 28th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.51 KB | None | 0 0
  1.  
  2. from random import randint
  3.  
  4. class Scene(object):
  5.    
  6.     def play_scene(self, title):
  7.         text = open(str(title + ".txt"), 'r')
  8.         print text.read()
  9.         text.close()
  10.        
  11.  
  12.        
  13.      
  14. # test = SceneHandler()
  15.  
  16. # test.play_scene('room1')
  17.  
  18. class Death(object):
  19.    
  20.     deaths = {'giant': "The giant picks you up by your feet and bites off your head.",
  21.                 'starve': "You continue on. Darkness falls on the forest around you. You are not seen again.",
  22.                 'disappear': "You wander into the passage alone and wander in the darkness for the rest of your days.",
  23.                 'pit': "Wrong key! The trapdoor swings open beneath you. You enter a freefall and land on the wooden spikes.",
  24.                 'beheading': "Wrong. In a single blow, the skeleton slices off your head. Later."
  25.     }
  26.  
  27.    
  28.     def scenes(self, type):
  29.         print Death.deaths[type]
  30.          
  31.  
  32. class RoomOne(Scene):
  33.     def __init__(self):
  34.         self.play_scene('beginning')
  35.        
  36.        
  37.     def enter(self):
  38.         input = raw_input(">>>  ")
  39.         death_answers = ['keep going', 'turn around', 'pass', 'ignore']
  40.         live_answers = ['go into the house', 'walk toward the smoke']
  41.        
  42.         if input in live_answers:
  43.             return Cottage().enter()
  44.         elif input in death_answers:
  45.             Death().scenes('starve')
  46.            
  47. class Cottage(Scene):
  48.     def __init__(self):
  49.         self.play_scene('cottage')
  50.  
  51.     def enter(self):
  52.         input = raw_input(">>>  ")
  53.         death_answers = ['fight the giant', 'run away', 'do nothing']
  54.         live_answers = ['hide']
  55.        
  56.         if input in live_answers:
  57.             Dungeon().enter()
  58.         if input in death_answers:
  59.             Death().scenes('giant')
  60.        
  61. class Dungeon(Scene):
  62.     def __init__(self):
  63.         self.play_scene('dungeon')
  64.        
  65.     def enter(self):
  66.         key = randint(1,3)
  67.         print key
  68.         input = int(raw_input(">>>  "))
  69.         death_answers = ['none', 'leave']
  70.         if input in death_answers:
  71.             return Death().scenes('disappear')
  72.         if input == key:
  73.             Tunnels().enter()
  74.         else:
  75.             Death().scenes('pit')
  76.        
  77. class Tunnels(Scene):
  78.     def __init__(self):
  79.         self.play_scene('tunnels')
  80.     def enter(self):
  81.         input1 = raw_input("Riddle 1 Answer:  ")
  82.         if input1 == "Dancing in the Dark":
  83.             print "Correct!"
  84.             input2 = raw_input("Riddle 2 Answer:  ")
  85.             if input2 == "1972":
  86.                 print "Correct!"
  87.                 input3 = raw_input("Riddle 3 Answer:  ")
  88.                 if input3 == "20":
  89.                     print "Correct!"
  90.                     TreasureRoom()
  91.                 else:
  92.                     Death().scenes('beheading')
  93.             else:
  94.                 Death().scenes('beheading')
  95.         else:
  96.             Death().scenes('beheading')
  97.            
  98. class TreasureRoom(Scene):
  99.     def __init__(self):
  100.         self.play_scene('treasure_room')
  101.  
  102.        
  103.  
  104.        
  105. RoomOne().enter()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement