Advertisement
Guest User

tinderbox text game

a guest
Jun 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.35 KB | None | 0 0
  1. import ex45_dialogue
  2.  
  3. class LifeQuality(object):
  4.  
  5. def __init__(self):
  6.  
  7. self.adjectives = ['no', 'some', 'plenty of', 'a lot of', 'tons of',
  8. 'countless amount of']
  9. def counter(self, index):
  10. return self.adjectives[index]
  11.  
  12. class Engine(object):
  13.  
  14. def __init__(self, scene_map):
  15. self.scene_map = scene_map
  16. # self.decision = decision
  17.  
  18. def play(self):
  19. current_scene = self.scene_map.opening_scene()
  20. last_scene = self.scene_map.next_scene('Finished')
  21.  
  22. # current_decision = self.decision.next_decision('Witch')
  23.  
  24. while current_scene != last_scene:
  25.  
  26. # next_scene_name = current_scene.enter(current_decision)
  27. next_scene_name = current_scene.enter()
  28. # current_decision = self.decision.next_decision(next_scene_name)
  29. current_scene = self.scene_map.next_scene(next_scene_name)
  30.  
  31. current_scene.enter()
  32.  
  33.  
  34.  
  35. #class Action(object):
  36.  
  37. # def Life_or_Lose(self, scene):
  38. # if scene == 'witch':
  39. # print 'you may enter'
  40.  
  41.  
  42. # scene_actions = {
  43. # 'Witch': Life_or_Lose('witch'),
  44. # 'Copper_Room': 'Copper_Room()',
  45. # 'Silver_Room': "move the cat and take as much silver as you can.",
  46. # 'Gold_Room': "move the three magical dogs and take as much gold as you can",
  47. # 'Life': "whatchu gon do?",
  48. # 'Hanging': "what's your final request?",
  49. # 'Lose': "dead up",
  50. # 'Finished': "you win."
  51. # }
  52.  
  53.  
  54. # def __init__(self):
  55. # pass
  56.  
  57. # def next_decision(self, scene):
  58. # val = Action.scene_actions.get(scene)
  59. # return val
  60.  
  61.  
  62. class Scene(object):
  63.  
  64. def enter(self):
  65. pass
  66.  
  67. class Witch(Scene):
  68.  
  69. def enter(self):
  70. print
  71. print "*" * 20
  72. print ex45_dialogue.witch_opener
  73. response = raw_input("Yes or No?\n\t>")
  74.  
  75. ## insert a loop here to ask again if response == 'No'
  76. attempts = 0
  77. while response != 'Yes':
  78. if attempts == 0:
  79. print "'No?' You can be richer than you ever imagined."
  80. elif attempts == 1:
  81. print "Are you sure? This is your last chance"
  82. else:
  83. print "'Fuck this dealer.' he says and continues home."
  84. return 'Lose'
  85.  
  86. attempts +=1
  87. response = raw_input("Yes or No?\n\t>")
  88.  
  89. print ex45_dialogue.witch_response
  90. return 'Copper_Room'
  91.  
  92. class CopperRoom(Scene):
  93.  
  94. def enter(self):
  95. print
  96. print "*" * 20
  97. print ex45_dialogue.copperroom_opener
  98. response = raw_input("What do you want to do?\n\t>")
  99.  
  100. ## insert a loop here to ask again if response == 'mouse'
  101. attempts = 0
  102. while not 'mouse' in response:
  103. if attempts == 0:
  104. print "'{}' didn't work. Try something else.".format(response)
  105. elif attempts == 1:
  106. print "'{}' doesn't work either. Hmmmm.".format(response)
  107. else:
  108. print "'Fuck this dealer.' he says and continues home."
  109. return 'Lose'
  110.  
  111. attempts +=1
  112. response = raw_input("What do you want to do?\n\t>")
  113.  
  114. print ex45_dialogue.copperroom_response
  115. return 'Silver_Room'
  116.  
  117.  
  118. class SilverRoom(Scene):
  119.  
  120. def enter(self):
  121. print
  122. print "*" * 20
  123. print ex45_dialogue.silverroom_opener
  124.  
  125. ## insert a loop here to ask again if response == 'cat'
  126.  
  127. response = raw_input("What do you do?\n\t>")
  128. attempts = 0
  129. while not 'cat' in response:
  130. if attempts == 0:
  131. print "'{}' didn't work. Try something else.".format(response)
  132. elif attempts == 1:
  133. print "'{}' doesn't work either. Hmmmm.".format(response)
  134. else:
  135. print "'Fuck this dealer.' he says and continues home."
  136. return 'Lose'
  137.  
  138. attempts +=1
  139. response = raw_input("What do you want to do?\n\t>")
  140.  
  141. print ex45_dialogue.silverroom_response
  142. return 'Gold_Room'
  143.  
  144.  
  145. class GoldRoom(Scene):
  146.  
  147. def enter(self):
  148. print
  149. print "*" * 20
  150. print ex45_dialogue.goldroom_opener
  151.  
  152. response = raw_input("What do you do?\n\t>")
  153. attempts = 0
  154. while not 'dog' in response:
  155. if attempts == 0:
  156. print "'{}' didn't work. Try something else.".format(response)
  157. elif attempts == 1:
  158. print "'{}' doesn't work either. Hmmmm.".format(response)
  159. else:
  160. print "'Fuck this dealer.' he says and continues home."
  161. return 'Lose'
  162.  
  163. attempts +=1
  164. response = raw_input("What do you want to do?\n\t>")
  165.  
  166. print ex45_dialogue.goldroom_response
  167. return 'Life'
  168.  
  169. class Life(Scene):
  170.  
  171. def enter(self):
  172. print
  173. print "*" * 20
  174. print ex45_dialogue.life_opener
  175.  
  176.  
  177. ## create condition that counts loops
  178. ## after 2 loops introduce knowledge of princess
  179. ## as non-dog responses increase, get better adjectives for returns
  180. ## if non-dog respones = 5 make money == 0
  181. ## dogs can get more money
  182. ## dogs can get princess
  183. ## use a keyword list to customize returns.
  184.  
  185. counter = 0
  186. dogs = False
  187. princess = False
  188.  
  189.  
  190. while not princess:
  191. money = LifeQuality()
  192. money_index = max(0, min(5-counter, 5))
  193. print 'money_index, ',money_index
  194. money_amt = money.counter(money_index)
  195. friends = LifeQuality()
  196. friends_index = max(0, min(0 + counter, 5))
  197. print 'friends_index, ',friends_index
  198. friends_amt = friends.counter(friends_index)
  199.  
  200. response = raw_input("What does the young soldier do?\n\t>")
  201.  
  202. counter += 1
  203.  
  204. if any(word in response for word in ['dog','tinderbox']) :
  205. print "The dogs from the Gold Room appear."
  206. dogs = True
  207. elif dogs and (word in response for word in ['money', 'coin', 'treasure']):
  208. print "The dogs go to the rooms with the treasure chests and bring back gold"
  209.  
  210. elif 'princess' in response and dogs:
  211. print "The dogs go to the tower where the princess is being held and bring her to you."
  212. princess = True
  213. elif 'princess' in response and not dogs:
  214. print "How? She's in the unreachable tower."
  215. else:
  216. if money_amt != 'no':
  217. print "The soldier goes hard."
  218. print "He {}. He's living life.".format(response)
  219. else:
  220. print "He can't {} anymore. He's broke".format(response)
  221. print "He's got {} friends and {} money".format(friends_amt, money_amt)
  222.  
  223.  
  224.  
  225. # while True:
  226. # response = raw_input("What do you do?\n\t>" )
  227. # if 'buy' in response:
  228. # print Life.buy[buy_count]
  229. # buy_count += 1
  230. # elif 'girl' in response:
  231. # print Life.girl[girl_count]
  232. # girl_count += 1
  233. # elif 'dogs' in response:
  234. # print 'The magical dogs arrive. They await your orders.'
  235. # dogs = True
  236. # elif 'princess' in response and dogs == False:
  237. # print "You don't know how to get to her yet."
  238. # elif 'princess' in response and dogs == True:
  239. # print "The dogs bring you the princess from her tower."
  240. # break
  241. # else:
  242. # print "I don't know what '{}' is but I ain't balling like you.".format(response)
  243.  
  244. return 'Hanging'
  245.  
  246. class Hanging(Scene):
  247.  
  248. def enter(self):
  249. print
  250. print "*" * 20
  251. print ex45_dialogue.hanging_opener
  252. response = raw_input("What would is your final wish?\n\t")
  253. if 'smoke' or 'cigarette' in response:
  254. print """
  255. The king agrees. He uses your tinder box and unknowingly summons the magical
  256. dogs. They kill the king and queen. The crowd is frightened and release you to
  257. spare their lives.
  258. """
  259. return 'Finished'
  260. else:
  261. print "They allow you to {}. You savour your final moment of freedom."
  262. return 'Lose'
  263.  
  264. class Lose(Scene):
  265. def enter(self):
  266. print
  267. print "*" * 20
  268. print "Dead up.\n\n The end."
  269. exit(0)
  270.  
  271. class Finished(Scene):
  272. def enter(self):
  273. print
  274. print "*" * 20
  275. print "You marry the princess. You become king. You win.\n\n The end."
  276. exit (0)
  277.  
  278.  
  279. class Map(object):
  280.  
  281. scenes = {
  282. 'Witch': Witch(),
  283. 'Copper_Room': CopperRoom(),
  284. 'Silver_Room': SilverRoom(),
  285. 'Gold_Room': GoldRoom(),
  286. 'Life': Life(),
  287. 'Hanging': Hanging(),
  288. 'Lose': Lose(),
  289. 'Finished': Finished()
  290. }
  291.  
  292. def __init__(self, start_scene):
  293. self.start_scene = start_scene
  294.  
  295.  
  296. def next_scene(self, scene_name):
  297. val = Map.scenes.get(scene_name)
  298. return val
  299.  
  300. def opening_scene(self):
  301. return self.next_scene(self.start_scene)
  302.  
  303. #a_action = Action()
  304. a_map = Map('Witch')
  305. a_game = Engine(a_map)
  306. a_game.play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement