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. 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."
  19. lever_closet = "The lever is made of a black plastic with a small red bobble on the top of it."
  20. clock_closet = "The clock is made of mostly wood, but has metal hands. The background picture of the clock is lime green"
  21. print "Game, created by Mark Veidemanis"
  22. from Tkinter import *;
  23. class CommandButton(Button):
  24. def _on_click ( self, *args, **kw ):
  25. self.game.run_command(self.ui, self.command);
  26. #end
  27. def __init__ ( self, parent, ui, game, text, command ):
  28. Button.__init__(self, parent, text=text);
  29. self.ui = ui;
  30. self.game = game;
  31. self.command = command;
  32. self.bind("<Button-1>", self._on_click);
  33. #end
  34. #end
  35. class MainFrame(Frame):
  36. def _do_send ( self, *args, **kw ):
  37. self.game.run_command(self, self._invar.get());
  38. #end
  39. def _init_widgets ( self ):
  40. self._toolbar = Frame(self);
  41. self._toolbar.pack(side=TOP, fill=X);
  42. self._outvar = StringVar();
  43. self._textbox = Text(self);
  44. self._textbox.pack(fill=BOTH);
  45. self._entrybar = Frame(self);
  46. self._entrybar.pack(side=BOTTOM, fill=X);
  47. self._invar = StringVar();
  48. self._entry = Entry(self._entrybar, textvariable=self._invar);
  49. self._entry.pack(side=LEFT);
  50. self._sendbutton = Button(self._entrybar, text="Execute");
  51. self._sendbutton.pack(side=RIGHT);
  52. self._sendbutton.bind("<Button-1>", self._do_send);
  53. #end
  54. def output ( self, text ):
  55. self._textbox.insert("end", text + "\n");
  56. self._invar.set("");
  57. #end
  58. def add_button ( self, text, command ):
  59. self._button = CommandButton(self._toolbar, self, self.game, text, command);
  60. self._button.pack(side=LEFT);
  61. #end
  62. def __init__ ( self, parent, game ):
  63. Frame.__init__(self, parent);
  64. self.game = game;
  65. self._init_widgets();
  66. self._entry.bind("<Return>", self._do_send);
  67. #end
  68. #end
  69. class Game:
  70. def run_command ( self, ui, cmd ):
  71. global inventory, room, look,door_status, hatch_status, place, examine, password, master, varword
  72. if cmd == "help":
  73. ui.output(help);
  74. if cmd == "pull lever" and room == "closet":
  75. ui.output("The hatch has been opened");
  76. hatch_status = "open"
  77. if cmd == "inv":
  78. ui.output(inventory);
  79. if cmd == "look" and room == "start" and place == "start":
  80. ui.output(look_start);
  81. if cmd == "go to window":
  82. ui.output("You go to the window");
  83. place = "window"
  84. if cmd == "look" and place == "window":
  85. ui.output(look_window);
  86. if cmd == "press button" and room == "start":
  87. ui.output("Door has been opened");
  88. door_status = "open"
  89. if cmd == "enter door" and room == "start" and door_status == "closed":
  90. ui.output("The door is locked, maybe the button unlocks it");
  91. if cmd == "enter door" and room == "start" and door_status == "open":
  92. ui.output("You have entered the door");
  93. place = "nil"
  94. room = "closet"
  95. if cmd == "enter hatch" and room == "closet" and hatch_status == "closed":
  96. ui.output("The hatch is locked, maybe the lever unlocks it");
  97. if cmd == "enter hatch" and room == "closet" and hatch_status == "open":
  98. ui.output("You are in the hatch");
  99. room = "shaft"
  100. if cmd == "look" and room == "closet":
  101. ui.output(look_closet);
  102. if cmd == "examine" and room == "closet":
  103. ui.output("what would you like to examine?");
  104. examine = "closet"
  105. if cmd == "examine" and room == "start":
  106. ui.output("what would you like to examine?");
  107. examine = "start"
  108. if cmd == "examine" and room == "shaft":
  109. ui.output("what would you like to examine?");
  110. examine = room
  111. if cmd == "button" and room == "start" and examine == room:
  112. ui.output(button_start);
  113. examine = "nil"
  114. if cmd == "lever" and room == "closet" and examine == room:
  115. ui.output(lever_closet);
  116. examine = "nil"
  117. if cmd == "clock" and room == "closet" and examine == room:
  118. ui.output(clock_closet);
  119. examine = "nil"
  120. if cmd == "door" and room == "shaft" and examine == room:
  121. ui.output(door_shaft);
  122. examine = "nil"
  123. if cmd == "hatch" and room == "closet" and examine == "closet":
  124. ui.output(hatch_closet);
  125. examine = "nil"
  126. if cmd == "shelf" and room == "closet" and examine == "closet":
  127. ui.output(shelf_closet);
  128. examine = "nil"
  129. if cmd == "debug" and password == varword:
  130. ui.output("DEBUG");
  131. import test.py
  132. if cmd == varword:
  133. ui.output("PASS");
  134. password = varword
  135. if cmd == "debug.632154879":
  136. ui.output(varword);
  137. master = "1"
  138. if cmd == "pass" and master == "1":
  139. ui.output(varword);
  140. if cmd == "normal":
  141. ui.output("NORMAL");
  142. master = "0"
  143. password = "nil"
  144. if cmd == "terminate":
  145. exit()
  146. #end
  147. #end
  148. #end
  149. if __name__ == "__main__":
  150. mainwin = Tk();
  151. game = Game();
  152. mainwin.title("Game");
  153. mainfrm = MainFrame(mainwin, game);
  154. mainfrm.add_button("Help", "help");
  155. mainfrm.add_button("Inv", "inv");
  156. mainfrm.add_button("Look", "look")
  157. mainfrm.add_button("Go to window", "go to window")
  158. mainfrm.add_button("Enter door", "enter door");
  159. mainfrm.add_button("Enter hatch", "enter hatch");
  160. mainfrm.add_button("Pull lever", "pull lever");
  161. mainfrm.add_button("Press button", "press button");
  162. mainfrm.add_button("Examine", "examine");
  163. mainfrm.pack();
  164. mainwin.mainloop();
  165. #end
  166.