spacepaste

  1.  
  2. password = "nil"
  3. help = "Commands: press button, pull lever, go to window, enter door, etc"
  4. room = "start"
  5. door_status = "closed"
  6. hatch_status = "closed"
  7. inventory = "Inventory = " "None"
  8. place = "start"
  9. examine = "nil"
  10. varword = "pass234"
  11. master = "0"
  12. hatch_closet = "The hatch seems big enough for you to fit through, it is made of wood and has the classic wood design, split into quarters and serarated by wood on the center horizontal and vertical line."
  13. shelf_closet = "The shelf is made from a brushed, silver metal - most likely aluminium. The bottom part of the shelf consists of a block of the metal and a small 2 cm hole in the middle. You do not see anything through the hole."
  14. look_start = "You find yourself in a dark, square room. You see a door and a small button by the side of the door. There is also a window, which is too far for you to see through it."
  15. look_window = "Through the window you can see a Mars-like terrain; red ground and sandstone type rocks. In the distance you can see a small hut with a helicopter landing pad on the roof of it."
  16. look_closet = "You find yourself in a small room that is brightly illuminated. There is a small shelf in front of you. Next to the shelf is a red lever. To the left of you is a hatch on the floor. There is a small clock on the wall to the right of you. The clock says it is 12:00"
  17. look_shaft = "You find yourself in a large room with some steps down to a blue painted wood and metal door with no windows."
  18. look_shaft_door = ""
  19. button_start = "There is a small plastic black button on a metal surface. The button is close to the door so most likely affects it."
  20. lever_closet = "The lever is made of a black plastic with a small red bobble on the top of it."
  21. clock_closet = "The clock is made of mostly wood, but has metal hands. The background picture of the clock is lime green"
  22. print "Puzzler, created by Mark Veidemanis"
  23. from Tkinter import *;
  24. class CommandButton(Button):
  25. def _on_click ( self, *args, **kw ):
  26. self.game.run_command(self.ui, self.command);
  27. #end
  28. def __init__ ( self, parent, ui, game, text, command ):
  29. Button.__init__(self, parent, text=text);
  30. self.ui = ui;
  31. self.game = game;
  32. self.command = command;
  33. self.bind("<Button-1>", self._on_click);
  34. #end
  35. #end
  36. class MainFrame(Frame):
  37. def _do_send ( self, *args, **kw ):
  38. self.game.run_command(self, self._invar.get());
  39. #end
  40. def _init_widgets ( self ):
  41. self._toolbar = Frame(self);
  42. self._toolbar.pack(side=TOP, fill=X);
  43. self._outvar = StringVar();
  44. self._textbox = Text(self);
  45. self._textbox.pack(fill=BOTH);
  46. self._entrybar = Frame(self);
  47. self._entrybar.pack(side=BOTTOM, fill=X);
  48. self._invar = StringVar();
  49. self._entry = Entry(self._entrybar, textvariable=self._invar);
  50. self._entry.pack(side=LEFT);
  51. self._sendbutton = Button(self._entrybar, text="Execute");
  52. self._sendbutton.pack(side=RIGHT);
  53. self._sendbutton.bind("<Button-1>", self._do_send);
  54. #end
  55. def output ( self, text ):
  56. self._textbox.insert("end", text + "\n");
  57. self._invar.set("");
  58. #end
  59. def add_button ( self, text, command ):
  60. self._button = CommandButton(self._toolbar, self, self.game, text, command);
  61. self._button.pack(side=LEFT);
  62. #end
  63. def __init__ ( self, parent, game ):
  64. Frame.__init__(self, parent);
  65. self.game = game;
  66. self._init_widgets();
  67. self._entry.bind("<Return>", self._do_send);
  68. #end
  69. #end
  70. class Game:
  71. def run_command ( self, ui, cmd ):
  72. global inventory, room, look,door_status, hatch_status, place, examine, password, master, varword
  73. if cmd == "help":
  74. ui.output(help);
  75. if cmd == "pull lever" and room == "closet":
  76. ui.output("The hatch has been opened");
  77. hatch_status = "open"
  78. if cmd == "inv":
  79. ui.output(inventory);
  80. if cmd == "look" and room == "start" and place == "start":
  81. ui.output(look_start);
  82. if cmd == "go to window":
  83. ui.output("You go to the window");
  84. place = "window"
  85. if cmd == "look" and place == "window":
  86. ui.output(look_window);
  87. if cmd == "press button" and room == "start":
  88. ui.output("Door has been opened");
  89. door_status = "open"
  90. if cmd == "enter door" and room == "start" and door_status == "closed":
  91. ui.output("The door is locked, maybe the button unlocks it");
  92. if cmd == "enter door" and room == "start" and door_status == "open":
  93. ui.output("You have entered the door");
  94. place = "nil"
  95. room = "closet"
  96. if cmd == "enter hatch" and room == "closet" and hatch_status == "closed":
  97. ui.output("The hatch is locked, maybe the lever unlocks it");
  98. if cmd == "enter hatch" and room == "closet" and hatch_status == "open":
  99. ui.output("You are in the hatch");
  100. room = "shaft"
  101. if cmd == "look" and room == "closet":
  102. ui.output(look_closet);
  103. if cmd == "examine" and room == "closet":
  104. ui.output("what would you like to examine?");
  105. examine = "closet"
  106. if cmd == "examine" and room == "start":
  107. ui.output("what would you like to examine?");
  108. examine = "start"
  109. if cmd == "button" and room == "start" and examine == room:
  110. ui.output(button_start);
  111. examine = "nil"
  112. if cmd == "lever" and room == "closet" and examine == room:
  113. ui.output(lever_closet);
  114. examine = "nil"
  115. if cmd == "clock" and room == "closet" and examine == room:
  116. ui.output(clock_closet);
  117. examine = "nil"
  118. if cmd == "hatch" and room == "closet" and examine == "closet":
  119. ui.output(hatch_closet);
  120. examine = "nil"
  121. if cmd == "shelf" and room == "closet" and examine == "closet":
  122. ui.output(shelf_closet);
  123. examine = "nil"
  124. if cmd == "enter door" and room == "shaft":
  125. ui.output("You have entered the door");
  126. room = "shaft_door"
  127. if cmd == "exit" and room == "shaft":
  128. ui.output("You climb out of the hatch");
  129. room = "closet"
  130. if cmd == "look" and room == "shaft_door":
  131. ui.output(look_shaft_door);
  132. if cmd == "exit" and room == "closet":
  133. ui.output("You are outside the door");
  134. room = "start"
  135. if cmd == "debug" and password == varword:
  136. ui.output("DEBUG");
  137. import test.py
  138. if cmd == varword:
  139. ui.output("PASS");
  140. password = varword
  141. if cmd == "debug.632154879":
  142. ui.output(varword);
  143. master = "1"
  144. if cmd == "pass" and master == "1":
  145. ui.output(varword);
  146. if cmd == "normal":
  147. ui.output("NORMAL");
  148. master = "0"
  149. password = "nil"
  150. if cmd == "terminate":
  151. exit()
  152. #end
  153. #end
  154. #end
  155. if __name__ == "__main__":
  156. mainwin = Tk();
  157. game = Game();
  158. mainwin.title("Puzzler");
  159. mainfrm = MainFrame(mainwin, game);
  160. mainfrm.add_button("Help", "help");
  161. mainfrm.add_button("Inv", "inv");
  162. mainfrm.add_button("Look", "look")
  163. mainfrm.add_button("Go to window", "go to window")
  164. mainfrm.add_button("Enter door", "enter door");
  165. mainfrm.add_button("Enter hatch", "enter hatch");
  166. mainfrm.add_button("Pull lever", "pull lever");
  167. mainfrm.add_button("Exit room", "exit");
  168. mainfrm.add_button("Press button", "press button");
  169. mainfrm.add_button("Examine", "examine");
  170. mainfrm.pack();
  171. mainwin.mainloop();
  172. #end
  173.