password = "nil" help = "Commands: press button, pull lever, go to window, enter door, etc" room = "start" door_status = "closed" hatch_status = "closed" inventory = "Inventory = " "None" place = "start" examine = "nil" varword = "pass234" master = "0" 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." 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." 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." 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." 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" look_shaft = "You find yourself in a large room with some steps down to a blue painted wood and metal door with no windows." 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." lever_closet = "The lever is made of a black plastic with a small red bobble on the top of it." clock_closet = "The clock is made of mostly wood, but has metal hands. The background picture of the clock is lime green" print "Game, created by Mark Veidemanis" from Tkinter import *; class CommandButton(Button): def _on_click ( self, *args, **kw ): self.game.run_command(self.ui, self.command); #end def __init__ ( self, parent, ui, game, text, command ): Button.__init__(self, parent, text=text); self.ui = ui; self.game = game; self.command = command; self.bind("", self._on_click); #end #end class MainFrame(Frame): def _do_send ( self, *args, **kw ): self.game.run_command(self, self._invar.get()); #end def _init_widgets ( self ): self._toolbar = Frame(self); self._toolbar.pack(side=TOP, fill=X); self._outvar = StringVar(); self._textbox = Text(self); self._textbox.pack(fill=BOTH); self._entrybar = Frame(self); self._entrybar.pack(side=BOTTOM, fill=X); self._invar = StringVar(); self._entry = Entry(self._entrybar, textvariable=self._invar); self._entry.pack(side=LEFT); self._sendbutton = Button(self._entrybar, text="Execute"); self._sendbutton.pack(side=RIGHT); self._sendbutton.bind("", self._do_send); #end def output ( self, text ): self._textbox.insert("end", text + "\n"); self._invar.set(""); #end def add_button ( self, text, command ): self._button = CommandButton(self._toolbar, self, self.game, text, command); self._button.pack(side=LEFT); #end def __init__ ( self, parent, game ): Frame.__init__(self, parent); self.game = game; self._init_widgets(); self._entry.bind("", self._do_send); #end #end class Game: def run_command ( self, ui, cmd ): global inventory, room, look,door_status, hatch_status, place, examine, password, master, varword if cmd == "help": ui.output(help); if cmd == "pull lever" and room == "closet": ui.output("The hatch has been opened"); hatch_status = "open" if cmd == "inv": ui.output(inventory); if cmd == "look" and room == "start" and place == "start": ui.output(look_start); if cmd == "go to window": ui.output("You go to the window"); place = "window" if cmd == "look" and place == "window": ui.output(look_window); if cmd == "press button" and room == "start": ui.output("Door has been opened"); door_status = "open" if cmd == "enter door" and room == "start" and door_status == "closed": ui.output("The door is locked, maybe the button unlocks it"); if cmd == "enter door" and room == "start" and door_status == "open": ui.output("You have entered the door"); place = "nil" room = "closet" if cmd == "enter hatch" and room == "closet" and hatch_status == "closed": ui.output("The hatch is locked, maybe the lever unlocks it"); if cmd == "enter hatch" and room == "closet" and hatch_status == "open": ui.output("You are in the hatch"); room = "shaft" if cmd == "look" and room == "closet": ui.output(look_closet); if cmd == "examine" and room == "closet": ui.output("what would you like to examine?"); examine = "closet" if cmd == "examine" and room == "start": ui.output("what would you like to examine?"); examine = "start" if cmd == "examine" and room == "shaft": ui.output("what would you like to examine?"); examine = room if cmd == "button" and room == "start" and examine == room: ui.output(button_start); examine = "nil" if cmd == "lever" and room == "closet" and examine == room: ui.output(lever_closet); examine = "nil" if cmd == "clock" and room == "closet" and examine == room: ui.output(clock_closet); examine = "nil" if cmd == "door" and room == "shaft" and examine == room: ui.output(door_shaft); examine = "nil" if cmd == "hatch" and room == "closet" and examine == "closet": ui.output(hatch_closet); examine = "nil" if cmd == "shelf" and room == "closet" and examine == "closet": ui.output(shelf_closet); examine = "nil" if cmd == "debug" and password == varword: ui.output("DEBUG"); import test.py if cmd == varword: ui.output("PASS"); password = varword if cmd == "debug.632154879": ui.output(varword); master = "1" if cmd == "pass" and master == "1": ui.output(varword); if cmd == "normal": ui.output("NORMAL"); master = "0" password = "nil" if cmd == "terminate": exit() #end #end #end if __name__ == "__main__": mainwin = Tk(); game = Game(); mainwin.title("Game"); mainfrm = MainFrame(mainwin, game); mainfrm.add_button("Help", "help"); mainfrm.add_button("Inv", "inv"); mainfrm.add_button("Look", "look") mainfrm.add_button("Go to window", "go to window") mainfrm.add_button("Enter door", "enter door"); mainfrm.add_button("Enter hatch", "enter hatch"); mainfrm.add_button("Pull lever", "pull lever"); mainfrm.add_button("Press button", "press button"); mainfrm.add_button("Examine", "examine"); mainfrm.pack(); mainwin.mainloop(); #end