#!/usr/bin/env python ###Nicholas McConnell is becoming a more advanced text-based game writer. ## Liam wants to be one too. He's gradually learning. ## This is metadunnet[3]. It is more educative and has all 12 directions. ## It is suitable for anyone above six years of age. ## Started December 15, 2010. ## This game should work in a DOS window. If not, use IDLE instead. # Liam is making simple games. Hopefully, by next year, he will have learned # how this game was made. # This game is longer than metadunnet[2].py. #******************************************************************************* ##Also notice how the player scores 90 points in the game and 100 points in the ##finale. This means that (s)he gets a better record in the finale, because ##of a useful notice of a 50-dollar bill getting into [his/her] way. import os import random import time numcommands = 0 numsaves = 0 visited = [] ##The descriptions of all sections. section_desc = [ [ """You are in a finale's room in the north end of a long hallway.""", "N Finale's Room" #0 ], [ """You are at the dead end of a road. The road goes to the south. In the distance you see it will eventually fork off. Near you is a tall pole which is higher than your head, and it is very cylindrical.""", "Dead end" ], [ """You are on the continuation of a road which goes north and south.""", "N/S road" ], [ """You have reached a fork of two passages, one to the southeast, and one to the southwest. You can also go back north.""", "Fork" ], [ """You are on a southeast-northwest road.""", "SE/NW road" ], [ """You are at the front of a building to the east. You can also go back northwest.""", "Building front" #5 ], [ """You are on a northeast-southwest road.""", "NE/SW road" ], [ """You are at the southwest end of the road. Steps lead down from here, and you can also go back northeast.""", "SW end of road" ], [ """You are in the hallway of a building. There are rooms to the north and south, and doors leading to the east and west.""", "Building hallway" ], [ """You are in a room in which mail bins are usually kept. The exit is to the north.""", "Mail area" ], [ """You are in a computer room. There is a computer here with one of the drawers wide open in front of you. On the computer is a label called 'entry', and there is a keyboard here, which you would be suitable using. The exit is to the south. Use the 'type' command to type on the console.""", "Computer room" #10 ], [ """You are in a round stone room with a path to the east. There is writing on the stone beside you, which reads 'Results'.""", "Results" ], [ """You are at the west end of a hallway which continues east and west. Paths lead off to the west and south.""", "W end of E/W hallway" ], [ """You are in a room. There is a button here which reads 'transferation'. The exit is to the north.""", "Transferation button room" ], [ """You are at the east end of a hallway which continues east and west. A path leads north.""", "E end of E/W hallway" ], [ """You are at the north end of a hall. You can go back south, and stairs lead down from here. On the ground nearby is a chute, which says 'put items here for points'.""", "N end of hall" #15 ], [ """You are in the entrance of a desert. Stairs lead up from here, and the ground here seems like sandy dirt.""", "Desert entrance" ], [ """You are in the swiss passages of a desert right around you.""", "Desert" ], [ """You are in the smooth passages of a desert right around you.""", "Desert" ], [ """You are in the sixty passages of a desert right around you.""", "Desert" ], [ """You are in the swiss cabbages of a desert right around you.""", "Desert" #20 ], [ """You are at the north end of a long north/south hallway. It looks as if this place has just finished being built. The hallway goes south, and in a distance you see a large donator. A misty view appers to the northeast.""", "N end of long N/S hallway" ], [ """You are 2/3 of the way towards the north end of the long hallway.""", "2/3 north" ], [ """You are 2/3 of the way towards the south end of the long hallway. There is a path to the east.""", "2/3 south" ], [ """You are at the south end of the long hallway. Surprisingly, there is another opening to the south.""", "S end of long N/S hallway" ], [ """You have gone very far. There is a large donator wide open in front of you. There is an opening to the north, and a hole in the ground, which you would perfectly fit in.""", "Donation area" #25 ], [ """You are in a hallway which continues east and west. The walls here look very smooth, which makes you think about the cylindrical pole.""", "Entry E/W hallway" ], [ """You have reached a dead end. The hallway goes west.""", "E end of entry hallway" ], [ """You have reached a rocky place. You realize that the stone here is painted lavender. Steps lead up out of sight.""", "Rocky place" ], [ """You are in a room which is completely blank. There is a path to the east.""", "Blank room" ], [ """You are in a stone room. Surprisingly, all the stones here are painted aqua. A path leads to the west.""", "Aqua room" #30 ], [ """You are at the southwest end of a hall. There is a PC on the floor here. The PC reads: Use the 'reset' command to type on the PC. A path leads northeast.""", "PC area" ], [ """You are at the northeast end of a northeast-southwest hallway. A stairwell leads up from here.""", "NE end of NE/SW hallway" ], [ """You are at the bottom of a stairwell where the stairs continue up and down from your view.""", "Stair landing" ], [ """You are in the middle of a staircase which continues up and down.""", "Up/down staircase" ], [ """You are at the top of the staircase. There is a path to the northwest, and you can also go back down the stairs.""", "Top of staircase." #35 ], [ """You are on a bridge which continues southeast and northwest. The bridge is not very strong or stable, and you notice yourself somewhat swinging back and forth.""", "SE/NW bridge passageway" ], [ """You are at the northwest end of a southeast-northwest bridge passageway. There is a door to the northwest.""", "NW end of SE/NW bridge passageway" ], [ """You are in an Entry Computing Center. There is a computer here which sort of looks like entry. There is a telephone wire coming out from the ceiling, but you cannot see where it's leading. The exit is to the southeast. There is no console on which you could type.""", "Entry Computing Center" ], [ """You are in a field in the back of a building. Paths lead off to the north and west.""", "Field" ], [ """You are in a post office. There is a mail drop in front of you, and paths lead off to the northwest and south.""", "Post office" #40 ], [ """You are at the southeast of a long road which goes southeast and northwest. You notice all the signs are gone, and all that's left is rocks on the ground. In the distance to the northwest you see a gate.""", "SE end of SE/NW road" ], [ """You are 3/4 of the way towards the southeast end of the road.""", "3/4 SE" ], [ """You are in the middle of the long SE/NW road. There is a large pithole off to the southwest.""", "Long SE/NW road" ], [ """You are 3/4 of the way towards the northwest end of the road. The ground here seems very thin.""", "3/4 NW" ], [ """You are the northwest end of the long road. There is a gate off to the northwest which guards a building.""", "NW end of SE/NW road" #45 ], [ """You are in the parking garage of a monument based on kings and queens. There is a door to the north, and a path to the southeast.""", "Monument entrance" ], [ """You are in the lobby of the monument. A path leads to the east, and the exit is to the south.""", "Monument lobby" ], [ """You are in a diner where the kings and queens often have meals. There are lots of tables here, but the chairs have all been removed due to retiring situations. Paths lead off to the north, west, and east.""", "Diner" ], [ """You are in the area where the monument director gives speeches. Unfortunately, all the chairs got removed due to retiring situations, but the desk where the director stands behind is still here. Paths lead off to the east and south.""", "Speech area" ], [ """You are in a special monument area for the kings and queens. You notice several decorated flags on the ceiling here. Paths lead off to the west and south.""", "Special monument" #50 ], [ """You are in what appears to be a king's and queen's bedroom. There is a king-sized bed here, with ropes above. There is a door to the south with the 'EXIT' sign on it, and paths lead off to the west and north.""", "Bedroom" ], [ """You are in The Philadelphia Station of a subway. A train is on the track here waiting for a passenger.""", "Philadelphia Station" ], [ """You are in a monument station. A passage leads off to the west.""", "Monument station" ], [ """You are in an east-west tunnel passage.""", "E/W tunnel passage" ], [ """You are at the west end of the tunnel passage. There is a door to the north and stairs lead down from here. You can also go back east. There is a kjos storage here.""", "W end of E/W tunnel passage" #55 ], [ """You are at the bottom of the subway stairs. There is a path to the northeast, and you can also go back up the stairs.""", "Bottom of subway stairs" ], [ """You are in a north-south hallway.""", "Finale N/S Hallway" ], [ """You have reached a question room. You must answer a question properly in order to get by. Use the 'answer' command to answer the question.""", "Question room 1" ], [ """You are in a north-south hallway.""", "Finale N/S Hallway" ], [ """You are in a second question room.""", "Question room 2" #60 ], [ """You are in a north-south hallway.""", "Finale N/S Hallway" ], [ """You are in a third question room.""", "Question room 3" ], [ """You are in a finale's room in the south end of a long hallway. There is a door to the south.""", "S Finale's Room" ], [ """You are in a winner's room. A door leads to the north.""", "Winner's room" ], [ """You are in a Finale Computer Room. There is a computer here which is the largest you have ever seen. It has no one's name on it, but it does have a sign on the top that says: The machine's name is 'Finale'. The exit is to the southwest. There is no console on which you could type.""", "Finale Computer Room" ] ] ##This is how the game remembers what to call the rooms. sect = { "n-finales-room": 0, "dead-end": 1, "n-s-road": 2, "fork": 3, "se-nw-road": 4, "building-front": 5, "ne-sw-road": 6, "sw-end-of-road": 7, "building-hallway": 8, "mail-area": 9, "computer-room": 10, "results": 11, "w-end-of-e-w-hallway": 12, "transferation-button-room": 13, "e-end-of-e-w-hallway": 14, "n-end-of-hall": 15, "desert-entrance": 16, "swiss-desert": 17, "smooth-desert": 18, "sixty-desert": 19, "desert-cabbages": 20, "n-end-of-long-n-s-hallway": 21, "2-3-north": 22, "2-3-south": 23, "s-end-of-long-n-s-hallway": 24, "donation-area": 25, "entry-e-w-hallway": 26, "e-end-of-entry-hallway": 27, "rocky-place": 28, "blank-room": 29, "aqua-room": 30, "pc-area": 31, "ne-end-of-ne-sw-hallway": 32, "stair-landing": 33, "up-down-staircase": 34, "top-of-staircase": 35, "se-nw-bridge-passageway": 36, "nw-end-of-se-nw-bridge-passageway": 37, "entry-computing-center": 38, "field": 39, "post-office": 40, "se-end-of-se-nw-road": 41, "3-4-se": 42, "long-se-nw-road": 43, "3-4-nw": 44, "nw-end-of-se-nw-road": 45, "monument-entrance": 46, "monument-lobby": 47, "diner": 48, "speech-area": 49, "special-monument": 50, "bedroom": 51, "philadelphia-station": 52, "monument-station": 53, "e-w-tunnel-passage": 54, "w-end-of-e-w-tunnel-passage": 55, "bottom-of-subway-stairs": 56, "finale-n-s-hallway-1": 57, "question-room-1": 58, "finale-n-s-hallway-2": 59, "question-room-2": 60, "finale-n-s-hallway-3": 61, "question-room-3": 62, "s-finales-room": 63, "winners-room": 64, "finale-computer-room": 65 } ##Now make the dungeon map, giving each direction an index. directs = { "north": 0, "south": 1, "east": 2, "west": 3, "n": 0, "s": 1, "e": 2, "w": 3, "northeast": 4, "northwest": 5, "southeast": 6, "southwest": 7, "ne": 4, "nw": 5, "se": 6, "sw": 7, "up": 8, "down": 9, "u": 8, "d": 9, "in": 10, "out": 11, "enter": 10, "exit": 11, "on": 10, "off": 11, "board": 10, "leave": 11 } dungeon_map = [ # nort sout east west ne nw se sw up down in out [-1, 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #0 [-1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #1 [1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #2 [2, -1, -1, -1, -1, -1, 4, 6, -1, -1, -1, -1 ], #3 [-1, -1, -1, -1, -1, 3, 5, -1, -1, -1, -1, -1 ], #4 [-1, -1, 255, -1, -1, 4, -1, -1, -1, -1, 255, -1 ], #5 [-1, -1, -1, -1, 3, -1, -1, 7, -1, -1, -1, -1 ], #6 [-1, -1, -1, -1, 6, -1, -1, -1, -1, 28, -1, -1 ], #7 [10, 9, 255, 5, -1, -1, -1, -1, -1, -1, -1, 5 ], #8 [8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #9 [-1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #10 [-1, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #11 [-1, 13, 14, 11, -1, -1, -1, -1, -1, -1, -1, -1 ], #12 [12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #13 [15, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1 ], #14 [-1, 14, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1 ], #15 [16, 17, 16, 16, 16, 16, 16, 16, 15, -1, -1, -1 ], #16 [16, 17, 17, 17, 17, 17, 18, 17, -1, -1, -1, -1 ], #17 [18, 18, 18, 19, 18, 17, 18, 18, -1, -1, -1, -1 ], #18 [19, 19, 18, 19, 19, 20, 19, 19, -1, -1, -1, -1 ], #19 [20, 20, 20, 20, 20, 20, 19, 255, -1, -1, -1, -1 ], #20 [-1, 22, -1, -1, 20, -1, -1, -1, -1, -1, -1, -1 ], #21 [21, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #22 [22, 24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #23 [23, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #24 [24, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1 ], #25 [-1, -1, 27, 23, -1, -1, -1, -1, -1, -1, -1, -1 ], #26 [-1, -1, -1, 26, -1, -1, -1, -1, -1, -1, -1, -1 ], #27 [-1, 255, -1, 255, -1, -1, -1, 255, 7, 255, -1, -1 ], #28 [-1, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #29 [-1, -1, -1, 29, -1, -1, -1, -1, -1, 255, -1, -1 ], #30 [-1, -1, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1 ], #31 [-1, -1, -1, -1, -1, -1, -1, 31, 33, -1, -1, -1 ], #32 [-1, -1, -1, -1, -1, -1, -1, -1, 34, 32, -1, -1 ], #33 [-1, -1, -1, -1, -1, -1, -1, -1, 35, 33, -1, -1 ], #34 [-1, -1, -1, -1, -1, 36, -1, -1, -1, 34, -1, -1 ], #35 [-1, -1, -1, -1, -1, 37, 35, -1, -1, -1, -1, -1 ], #36 [-1, -1, -1, -1, -1, 255, 36, -1, -1, -1, 255, -1 ], #37 [-1, -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, 37 ], #38 [40, -1, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1 ], #39 [-1, 39, -1, -1, -1, 41, -1, -1, -1, -1, 255, 255], #40 [-1, -1, -1, -1, -1, 42, 40, -1, -1, -1, 255, 255], #41 [-1, -1, -1, -1, -1, 43, 41, -1, -1, -1, 255, 255], #42 [-1, -1, -1, -1, -1, 44, 42, 255, -1, -1, 255, 255], #43 [-1, -1, -1, -1, -1, 45, 43, -1, -1, 255, 255, 255], #44 [-1, -1, -1, -1, -1, 255, 44, -1, -1, -1, 255, 255], #45 [47, -1, -1, -1, -1, -1, 45, -1, -1, -1, 255, 255], #46 [-1, 46, 48, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #47 [49, -1, 51, 47, -1, -1, -1, -1, -1, -1, -1, -1 ], #48 [-1, 48, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #49 [-1, 51, -1, 49, -1, -1, -1, -1, -1, -1, -1, -1 ], #50 [50, 255, -1, 48, -1, -1, -1, -1, -1, -1, -1, -1 ], #51 [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 255, -1 ], #52 [-1, -1, -1, 54, -1, -1, -1, -1, -1, -1, -1, -1 ], #53 [-1, -1, 53, 55, -1, -1, -1, -1, -1, -1, -1, -1 ], #54 [51, -1, 54, -1, -1, -1, -1, -1, -1, 56, -1, -1 ], #55 [-1, -1, -1, -1, 65, -1, -1, -1, 55, -1, -1, -1 ], #56 [0, 255, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #57 [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #58 [58, 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #59 [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #60 [60, 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #61 [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #62 [255, 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #63 [63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ], #64 [-1, -1, -1, -1, -1, -1, -1, 56, -1, -1, -1, -1 ] #65 # nort sout east west ne nw se sw up down in out ] current_section = 1 # Which sections will get you into a grue and which won't? light_sections = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 28, 39, 40, 41, 42, 43, 44, 45, 46] ##How the user references /all/ objects, takable and non-takable. obj = { "chip": 0, "metal": 1, "pot": 1, "key": 2, "slip": 3, "paper": 3, "lantern": 4, "armband": 5, "arm": 5, "band": 5, "rock": 6, "stone": 6, "ball": 7, "rubber": 7, "mango": 8, "strawberry": 9, "berry": 9, "blanket": 10, "cloth": 10, "cleaver": 11, "knife": 11, "license": 12, "steel": 13, "aluminum": 14, "copper": 15, "handlebar": 16, "handlebars": 16, "handle": 16, "bar": 16, "bars": 16, "box": 17, "plastic": 17, "straw": 18, "straws": 18, "fork": 19, "$50": 20, "50-dollar": 20, "bill": 20, "floppy": 21, "disk": 21, "pole": -1, "lion": -2, "bin": -3, "bins": -3, "computer": -4, "drawer": -4, "machine": -4, "button": -5, "chute": -6, "donator": -7, "pc": -8, "drive": -8, "container": -9, "slit": -9, "telephone": -10, "wire": -10, "maildrop": -11, "mail": -11, "drop": -11, "car": -12, "pithole": -13, "gate": -14, "desk": -15, "table": -16, "tables": -16, "bed": -17, "train": -18, "kjos": -19, "storage": -19, "brick": -20, "bricks": -20 } # Searches of all items. tk_objects = [ ["There is a computer chip here.", "A computer chip"], ["There is a metal pot here.", "A metal pot"], ["There is a shiny brass key here.", "A brass key"], ["There is a slip of paper here.", "A slip of paper"], ["There is a lantern nearby.", "A lantern"], ["There is an arm band here.", "An arm band"], ["There is a rough rock here.", "A rock"], ["There is a shining rubber ball here.", "A rubber ball"], ["There is a mango here.", "A mango"], ["There is a ripe strawberry here.", "A strawberry"], ["There is a cloth blanket on the ground here.", "A cloth blanket"], ["There is a sharp cleaver here.", "A cleaver"], ["There is a driver's license here.", "A license"], ["There is a steel cube here.", "A steel cube"], ["There is an aluminum cube here.", "An aluminum cube"], ["There is a copper cube here.", "A copper cube"], ["There is a pair of 5 pound handlebars here.", "A pair of handlebars"], ["There is a thin plastic box here.", "A plastic box"], ["There is a wrapped bundle of straws here.", "A bundle of straws"], ["There is a fork here.", "A fork"], ["There is a 50-dollar bill here.", "A $50 bill"], ["There is a floppy disk here.", "A floppy disk"] ] ntk_objects = [ None, None, "A ferocious lion is here!", None, None, None, None, None, None, "There is a container with a slit on it, attached to the wall here.", None, None, "There is a car here.", None, None, None, None, None, None, None, None ] # Descriptions of objects. tk_desc = [ "It is a normal computer chip with 2 Megabytes of ENTRY onboard.", "It looks like a cooking pot. Sounds noisy.", None, """The paper says: Don't forget to type 'help' if you need help. Also, remember this word: 'snail'""", "The lantern was crafted by Geppetto.", "It says 'HAVE FUN WITH YOUR HOBBIES'.", "It looks like quartz to me.", None, None, None, "It has a picture of Sponge Bob on it.", None, "It has your own picture on it!", None, None, None, "You observe that the handlebars are quite heavy.", "It appears to have no lid on it.", None, None, None, None ] ntk_desc = [ None, "It is a rather tall pole with a tray of bricks on top of it.", "Ohh! It looks mean.", """All of the bins are identical and spaced evenly from each other. Most of the bins have names which are faded away so that you cannot read them. You can only make out of three of the names: David Gordon Daniel Deutsch Samantha Bassler """, None, None, None, """From here, the donator is very large and up near the ceiling before your eyes. But a small hole is on the donator right in front of you, and you would probably be able to put things in there.""", "It is a personal computer which has only one floppy disk drive.", """It is an opaque container with a slit on the front, and this written in cursive writing: 'For key upgrade, put key here.'""", None, "It says 'express mail' on it.", "It is a normal CAMRY vehicle.", "It is a DEEP pithole.", "It is a gate which is too tall for one to climb over.", None, None, "It is king-sized bed, with a very firm matress.", "It is a passenger train that is ready to move.", None, None ] # How do you earn points? obj_pts = [0, 0, 0, 0, 0, 10, 0, 10, 10, 10, 0, 0, 0, 10, 10, 10, 0, 0, 10, 10, 0, 0] # How heavy is your load? obj_lbs = [1, 2, 0, 0, 2, 1, 1, 1, 1, 1, 0, 0, 1, 2, 2, 2, 5, 0, 1, 1, 0, 1] nochute = False nomail = False incar = False hole = False gotten = False logged = False computer = False wizard = False pc = False entry = True finale = False true = True false = False none = None key_level = 0 mode = "normal" dir_take = "south" box = [] bins = [] inventory = [] items = [ [], [obj["pole"], obj["bricks"], obj["chip"]], #dead-end [], [obj["pot"]], #fork [], [], [], [], [], [obj["bins"]], #mail-area [obj["computer"]], #computer-room [], [obj["lantern"]], #w-end-of-e-w-hallway [obj["button"]], #transferation-button-room [obj["band"]], #e-end-of-e-w-hallway [obj["chute"]], #n-end-of-hall [], [], [obj["rock"], obj["floppy"]], #smooth-desert [], [], [obj["mango"]], #n-end-of-long-n-s-hallway [], [], [], [obj["donator"]], #donation-area [], [obj["strawberry"]], #e-end-of-entry-hallway [obj["lion"]], #rocky-place [], [obj["blanket"]], #aqua-room [obj["pc"]], #pc-area [], [obj["container"]], #stair-landing [], [], [], [obj["cleaver"]], #nw-end-of-se-nw-bridge-passageway [obj["wire"], obj["computer"]], #entry-computing-center [obj["lantern"], obj["license"], obj["steel"]], #field [obj["mail"]], #post-office [obj["car"]], #se-end-of-se-nw-road [], [obj["aluminum"], obj["pithole"]], #long-se-nw-road [], [obj["gate"]], #nw-end-of-se-nw-road [], [], [obj["tables"]], #diner [obj["bars"], obj["desk"]], #speech-area [obj["box"]], #special-monument [obj["straws"], obj["bed"]], #bedroom [obj["train"]], #philadelphia-station [], [], [obj["storage"]], #w-end-of-e-w-tunnel-passage [obj["fork"]], #bottom-of-subway-stairs [], [], [], [], [], [], [], [obj["bill"]], #winners-room [obj["computer"]] #finale-computer-room ] # Questions and the answers that can be accepted from the user. questions = [ ["How many pounds did the handlebars weigh?", ["5", "five"]], ["Excluding the finale, how many places can you put things to score points?", ["4", "four"]], ["How many megabytes of ENTRY were on the computer chip?", ["2"]], ["What cartoon character was on the blanket?", ["sponge", "bob", "sponge-bob"]], ["What kind of car were you driving on the road?", ["camry"]], ["How many sections were on the road (excluding that with the post office)?", ["5", "five"]], ["What was the login on the 'entry' machine?", ["deutsch"]], ["What was the password on the 'entry' machine?", ["daniel"]], ["What type of rock did you transfer into a rubber ball?", ["quartz"]], ["Name either of the two last names in the mail area, other than the original.", ["gordon", "bassler"]], ["What was the name of the first section you ended up when going to entry?", ["results"]] ] # Everything random. items[random.randrange(41, 46)].append(obj["copper"]) combination = "%d%d%d" % (random.randrange(10), random.randrange(10), random.randrange(10)) current_question = random.randrange(len(questions)) # Now? Start reading. def score(args): if not finale: points = sum([obj_pts[x] for x in xrange(22) if x in items[sect["n-finales-room"]]]) print "You have scored %d out of a possible 90 points." % points else: points = sum([obj_pts[x] for x in xrange(22) if x in items[sect["s-finales-room"]]]) if obj["bill"] in items[sect["s-finales-room"]]: points += 10 print "You have scored %d finale points out of a possible 100." % points if points == 100: print "\n\nCongratulations! You have won. The wizard pass is 'netta'" def die(args): global numcommands print if len(args) > 0: print "You are dead." if finale and sum([obj_pts[x] for x in xrange(22) if x in items[sect["s-finales-room"]]]) == 90 and obj["bill"] in items[sect["s-finales-room"]]: #Winning score doScore = "killed by %s at winning score" % args[0] else: doScore = "killed by %s" % args[0] else: if finale and sum([obj_pts[x] for x in xrange(22) if x in items[sect["s-finales-room"]]]) == 90 and obj["bill"] in items[sect["s-finales-room"]]: doScore = "won" else: doScore = "quit" score([]) for i in xrange(45): raw_input() print "Last score: Player %s at %s\n" % (doScore, section_desc[current_section][1]) if not finale: points = sum([obj_pts[x] for x in xrange(22) if x in items[sect["n-finales-room"]]]) print "Points: %d" % points else: points = sum([obj_pts[x] for x in xrange(22) if x in items[sect["s-finales-room"]]]) if obj["bill"] in items[sect["s-finales-room"]]: points += 10 print "Points: %d" % (points + 90) print "Saves: %d" % numsaves print "Last commands: %d" % (numcommands + 1) print numcommands = -1 explainIfNew() def _quit(args): die([]) def win(args): score([]) if finale and sum([obj_pts[x] for x in xrange(22) if x in items[sect["s-finales-room"]]]) == 90 and obj["bill"] in items[sect["s-finales-room"]]: print "You /are/ at a winning score; thank you for trying to win." else: if not finale and sum([obj_pts[x] for x in xrange(22) if x in items[sect["n-finales-room"]]]) == 90: print "You still haven't yet made it to the winning score; I'm sorry." else: print "I'm afraid that you'll have to improve your score." def specialObjects(): ##Case where there are any special properties about a section. if current_section == sect["mail-area"]: if len(bins) > 0: print "Looking inside the bins:" for i in bins: print " " + tk_objects[i][0] elif current_section == sect["computer-room"]: if not computer: print "The lights are very steady and motionless." else: print "The lights are flashing in a seemingly even pattern." elif current_section == sect["aqua-room"]: if not obj["blanket"] in items[current_section]: print "There is a hole in the floor here." elif current_section == sect["3-4-nw"]: if hole: print "There is a hole in the ground here." elif current_section == sect["question-room-1"] or current_section == sect["question-room-2"] or \ current_section == sect["question-room-3"]: print "Your question is:" print questions[current_question][0] if incar: print "You are in the car." def inven(args): ##List every object in the player's inventory. # *** Special case for the box! We must include what is in it. print "You currently have:" for i in inventory: print tk_objects[i][1] if i == obj["box"] and len(box) > 0: print "The box contains:" for j in box: print " " + tk_objects[j][1] def explainShort(): if not current_section in light_sections and not obj["lantern"] in inventory and (not obj["lantern"] in box or not obj["box"] in inventory): print "It's pitch dark. You are likely to be eaten by a grue." else: print section_desc[current_section][1] specialObjects() #Special case for the box for i in items[current_section]: if i >= 0: print tk_objects[i][0] else: if isinstance(ntk_objects[-i], str): if not i == obj["car"] or not incar: print ntk_objects[-i] if i == obj["box"] and len(box) > 0: print "Looking inside the box:" for j in box: print " " + tk_objects[j][0] def explainLong(): if not current_section in light_sections and not obj["lantern"] in inventory and (not obj["lantern"] in box or not obj["box"] in inventory): print "It's pitch dark. You are likely to be eaten by a grue." else: print section_desc[current_section][1] print section_desc[current_section][0] specialObjects() #Special case for the box for i in items[current_section]: if i >= 0: print tk_objects[i][0] else: if isinstance(ntk_objects[-i], str): if not i == obj["car"] or not incar: print ntk_objects[-i] if i == obj["box"] and len(box) > 0: print "Looking inside the box:" for j in box: print " " + tk_objects[j][0] def explainIfNew(): global visited if mode == "long": explainLong() elif mode == "short": explainShort() else: if not current_section in visited: explainLong() else: explainShort() if not current_section in visited: visited.append(current_section) def specialMove(direct): ##Case where you can't go that way unless certain conditions are met. # In the following, we look for the current section and do the special. # But how do we know what direction to do this to? A 255 in the dungeon # map yields this. global current_section, nochute, nomail, incar, dir_take if current_section == sect["building-front"]: if not obj["key"] in inventory: print "You don't have a key that can open this door." else: current_section = sect["building-hallway"] explainIfNew() elif current_section == sect["building-hallway"]: if not obj["key"] in inventory or key_level == 0: print "You don't have a key that can open this door." else: current_section = sect["field"] explainIfNew() elif current_section == sect["desert-cabbages"]: current_section = sect["n-end-of-long-n-s-hallway"] nochute = True explainIfNew() elif current_section == sect["rocky-place"]: if obj["lion"] in items[current_section]: print \ """The lion is very mad that you would be so stingy as to walk right into his space. He tells you so by swallowing you. You choke to death.""" die(["a lion"]) else: print "You can't go that way." elif current_section == sect["aqua-room"]: if obj["blanket"] in items[current_section]: print "You can't go that way." else: current_section = sect["pc-area"] explainIfNew() elif current_section == sect["nw-end-of-se-nw-bridge-passageway"]: print "You must enter a 3-digit combination code number to enter this room." combination_input = raw_input("Enter it here: ") if combination_input != combination: print "Sorry, that combination is incorrect." else: current_section = sect["entry-computing-center"] explainIfNew() elif current_section >= 40 and current_section <= 46 and direct >= 10: if direct == 10: if incar: print "You are already in the car!" else: if obj["car"] in items[current_section]: if not obj["license"] in inventory: print "You are not licensed for this type of vehicle." else: print "You enter the car and buckle up in the driver's seat." nomail = True incar = True else: print "You can't go that way." else: if incar: print "You hop out of the car." incar = False else: if obj["car"] in items[current_section]: print "You are already out of the car!" else: print "You can't go that way." elif current_section == sect["long-se-nw-road"] and direct < 10: if not incar: print "You fall into the pithole and land on your forehead." die(["a pithole"]) else: print "The car zooms into the pithole, and plunges to the bottom where it explodes." die(["a car accident"]) elif current_section == sect["3-4-nw"] and direct < 10: if hole: if incar: print "The car drives into the hole in the ground and explodes." die(["a car accident"]) else: print "You slide into the hole in the ground." current_section = sect["philadelphia-station"] explainIfNew() else: print "You can't go that way." elif current_section == sect["nw-end-of-se-nw-road"] and direct < 10: if not incar: print "The gate will not open." else: print "As the car moves up, the gate opens and you drive through." items[current_section].remove(obj["car"]) items[sect["monument-entrance"]].append(obj["car"]) current_section = sect["monument-entrance"] explainIfNew() elif current_section == sect["bedroom"]: print "The door is locked." elif current_section == sect["philadelphia-station"]: print \ """As you enter the train, it immediately leaves the Philadelphia Station. The ride seems very bumpy at first. You sit down in one of the seats to be more comfortable. Finally, the train comes to a sudden stop, the doors open, and a push throws you out. The train speeds away. """ current_section = sect["monument-station"] explainIfNew() elif current_section == sect["finale-n-s-hallway-1"]: dir_take = "south" current_section = sect["question-room-1"] explainIfNew() elif current_section == sect["s-finales-room"]: dir_take = "north" current_section = sect["question-room-3"] explainIfNew() def move(args): ##Uses the dungeon map to figure out where you're going. 255 yields # a special move; -1 yields an unability to ever move that way. # *** Special case for the car, and we must include how it is driven. global current_section if args == []: print "You must supply a direction." else: if not args[0] in directs: print "I do not understand where you want me to go." else: if not current_section in light_sections and not obj["lantern"] in inventory and (not obj["lantern"] in box or not obj["box"] in inventory): print \ """You trip over a grue and fall into a pit where you break every bone in your body.""" die(["a grue"]) else: direct = directs[args[0]] newroom = dungeon_map[current_section][direct] if newroom == -1: print "You can't go that way." elif newroom == 255: specialMove(direct) else: if incar: if newroom < 40 or newroom > 46: print "The car cannot go this way." else: print "The car lurches ahead and screeches to a halt." items[current_section].remove(obj["car"]) items[newroom].append(obj["car"]) current_section = newroom else: current_section = newroom explainIfNew() def north(args): move(["north"]) def south(args): move(["south"]) def east(args): move(["east"]) def west(args): move(["west"]) def northeast(args): move(["northeast"]) def northwest(args): move(["northwest"]) def southeast(args): move(["southeast"]) def southwest(args): move(["southwest"]) def up(args): move(["up"]) def down(args): move(["down"]) def _in(args): move(["in"]) def out(args): move(["out"]) def take(args): global items, inventory, bins, box if incar: print "You can't take anything while in the car." else: if args == []: print "You must supply an object." else: if args[0] in ["all", "entire", "everything"]: takable = [x for x in items[current_section] if x >= 0] if takable == []: print "Nothing to take." else: for i in takable: print "%s:" % tk_objects[i][1] take_object(i) else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if current_section == sect["mail-area"] and objnum in bins: print "You remove it from the bins." bins.remove(objnum) inventory.append(objnum) else: if (obj["box"] in inventory or obj["box"] in items[current_section]) and \ objnum in box: print "You remove it from the box." box.remove(objnum) inventory.append(objnum) else: if not objnum in items[current_section]: print "I do not see that here." else: if objnum < 0: print "You cannot take that." else: take_object(objnum) def take_object(num): if obj_lbs[num] + sum([obj_lbs[x] for x in inventory]) > 11: print "Your load would be too heavy." else: print "Taken. " items[current_section].remove(num) inventory.append(num) if num == obj["blanket"] and current_section == sect["aqua-room"]: # Special case for the hole print "Taking the blanket reveals a hole in the floor." def drop(args): global items, inventory, box, hole if incar: print "You can't drop anything while in the car." else: if args == []: print "You must supply an object." else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if not objnum in inventory: print "You don't have that." else: print "Done." inventory.remove(objnum) items[current_section].append(objnum) # Now do a drop check for any special dropping situations. if objnum == obj["pot"] and obj["lion"] in items[current_section]: print \ """The pot makes a loud noise, which scares the lion. The lion runs up the stairs and away. He left something behind.""" items[current_section].remove(obj["lion"]) items[current_section].append(obj["key"]) if objnum == obj["box"] and obj["handlebars"] in box: print "As the box impacts the ground it breaks into many pieces." items[current_section] = items[current_section] + box box = [] items[current_section].remove(obj["box"]) if current_section == sect["3-4-nw"]: print "The impact breaks a hole in the ground right beside you." hole = True def examine(args): global items, inventory, box, hole if args == []: explainLong() else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if not objnum in inventory and not objnum in items[current_section]: print "I don't see that here." else: if objnum >= 0: if not tk_desc[objnum]: print "I see nothing special about that." else: print tk_desc[objnum] else: if not ntk_desc[-objnum]: print "I see nothing special about that." else: print ntk_desc[-objnum] def cut(args): global inventory, items, entry, current_section if not obj["cleaver"] in inventory: print "You have nothing you can use to cut things." else: if args == []: print "You must supply an object." else: if args[0] in ["me", "myself", "self", "my"]: print "You bend down and cut off your finger. Ohh!" die(["a cleaver"]) else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if not objnum in inventory and not objnum in items[current_section]: print "I don't see that here." else: if objnum == obj["cleaver"]: print "You can't cut a cleaver with itself!" else: if objnum in inventory: print \ """You examine the object in your hands and carefully lower the cleaver. Unfortunately, you miss the object and cut off your thumb. You bleed to death.""" die(["a cleaver"]) else: if objnum == obj["wire"]: print \ """As you cut the telephone wire, everything starts to blur. You begin to collapse for a moment, and then straighten yourself up. Case closed.""" items[current_section] = items[current_section] + inventory inventory = [] current_section = sect["computer-room"] entry = False entry_interface() else: if objnum >= 0: print "You try to cut the object, but it seems hard." else: print "You press hard and your cleaver just won't cut." def eat(args): global items, inventory, box, hole if args == []: print "You must supply an object." else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if not objnum in inventory: print "You don't have that." else: if objnum in [obj["mango"], obj["strawberry"]]: print "That tasted fine." inventory.remove(objnum) else: print "You shove %s down your throat, and start to choke." % tk_objects[objnum][1].lower() die(["choking"]) def lick(args): global items, inventory, box, hole if args == []: print "You must supply an object." else: if args in ["me", "myself", "self", "my"]: print "Eww." else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if not objnum in inventory: print "You don't have that." else: if objnum in [obj["mango"], obj["strawberry"]]: print "You get a fine taste on your tongue." else: print \ """You spread your tongue on %s and cut it on a sharp edge. You start whining.""" % tk_objects[objnum][1].lower() die(["a tongue cut"]) def _long(args): global mode mode = "long" def short(args): global mode mode = "short" def normal(args): global mode mode = "normal" def shake(args): global items, inventory, box, hole if args == []: print "You must supply an object." else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if objnum >= 0: if objnum in inventory: print "Shaking %s seems to have no effect." % tk_objects[objnum][1].lower() else: print "You don't have that." else: if objnum in items[current_section]: if objnum == obj["pole"]: print \ """You begin to shake the pole, and notice some bricks beginning to fall out of the tray. As you try to move your hands out and grab for them, you feel the impact as they land on your head.""" die(["bricks"]) elif objnum == obj["lion"]: print "As you go up to the lion, he swallows you into his throat." die(["a lion"]) else: print "You cannot shake that." else: print "I don't see that here." def press(args): global items, inventory, box, hole if args == []: print "You must supply an object." else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if objnum in items[current_section]: if objnum == obj["button"]: print "The button is now in the transfering position." if obj["rock"] in inventory or obj["rock"] in items[current_section]: print \ """You notice the rock being sucked up into the machine until it completely disappears. Out comes a shiny rubber ball!""" if obj["rock"] in inventory: inventory.remove(obj["rock"]) inventory.append(obj["ball"]) else: items[current_section].remove(obj["rock"]) items[current_section].append(obj["ball"]) if obj["floppy"] in inventory or obj["floppy"] in items[current_section]: print \ """You notice the floppy disk being sucked up into the machine. After it disappears, a strange sound is heard, and the sound goes away.""" if obj["floppy"] in inventory: inventory.remove(obj["floppy"]) else: items[current_section].remove(obj["floppy"]) else: print "You can't press that." else: print "I don't see that here." def put(args): global computer, pc, key_level, items, inventory if args == []: print "You must supply an object." else: if not args[0] in obj: print "I don't know what that object is." else: objnum1 = obj[args[0]] if not objnum1 in inventory: print "You don't have that." else: if not "in" in args and not "into" in args and not "on" in args and not "onto" in args and not "through" in args: print "You must supply an indirect object." else: while args[1] != "in" and args[1] != "into" and args[1] != "on" and args[1] != "onto" and args[1] != "through": args = [args[0]] + args[2:len(args)] if len(args) == 2: print "You must supply an indirect object." else: if not args[2] in obj: print "I don't know what that indirect object is." else: objnum2 = obj[args[2]] if not objnum2 in inventory and not objnum2 in items[current_section]: print "That indirect object is not here." else: if objnum1 == objnum2: print "You can't put anything in itself." else: if objnum2 == obj["box"]: #Special case! if len(box) == 4: print "There's no more room in the box for another object." else: print "Done." inventory.remove(objnum1) box.append(objnum1) elif objnum2 == obj["bins"]: print "Done." inventory.remove(objnum1) bins.append(objnum1) elif objnum1 == obj["chip"] and objnum2 == obj["computer"]: print \ """As you put the computer chip into the computer, it immediately springs to life. The lights start flashing and the fans seem to startup.""" inventory.remove(objnum1) computer = True elif objnum2 == obj["chute"]: if nochute: print "The chute is locked." else: print "You hear it slide down the chute and off into the distance." inventory.remove(objnum1) items[sect["n-finales-room"]].append(objnum1) score([]) elif objnum2 == obj["donator"]: print "Zhoooomm!!" inventory.remove(objnum1) items[sect["n-finales-room"]].append(objnum1) score([]) elif objnum1 == obj["floppy"] and objnum2 == obj["pc"]: print "Done." inventory.remove(objnum1) pc = True elif objnum2 == obj["container"]: if objnum1 != obj["key"]: print "You can't put that in the key container!" else: print \ """As you drop in the key, the container begins to shake. Finally, it explodes with a BANG! The key seems to have gone!""" inventory.remove(objnum1) items[current_section].remove(obj["container"]) items[sect["computer-room"]].append(obj["key"]) key_level += 1 elif objnum2 == obj["mail"]: if nomail: print "The mail chute is locked." else: print "You hear it slide down the chute and off into the distance." inventory.remove(objnum1) items[sect["n-finales-room"]].append(objnum1) score([]) elif objnum2 == obj["pithole"]: print "You hear it impact the bottom of the pithole." inventory.remove(objnum1) elif objnum2 == obj["storage"]: print "You hear it slide down the chute and off into the distance." inventory.remove(objnum1) items[sect["n-finales-room"]].append(objnum1) score([]) else: print "I don't know how to put that there. Maybe you should just try dropping it." def sleep(args): if current_section != sect["bedroom"]: print "You try to go to sleep while standing up here, but can't seem to do it." else: print \ """As soon as you start to doze off you begin dreaming. You picture a lot of explorers walking on a road. Then you see yourself as one of the explorers. While no one is looking, you leave the group and walk to a random spot on the road. The road is very thin and tap-type there. You see yourself putting some heavy object into a box, dropping the box to break a hole, and then sliding down the hole. After this, you immediately wake up.""" ##Now for saving and restoring. def save_val(variable): result = str([eval(variable)])[1:-1] return "%s = %s\n" % (variable, result) def save(args): global numsaves if args == []: print "You must supply a filename for the save." else: try: if not os.access("saved games", os.F_OK): os.mkdir("saved games") savepath = os.path.join("saved games", "metadunnet3") if not os.access(savepath, os.F_OK): os.mkdir(savepath) game = open(os.path.join(savepath, "%s.txt" % args[0]), "w") game.write(save_val("visited")) game.write(save_val("current_section")) game.write(save_val("nochute")) game.write(save_val("nomail")) game.write(save_val("incar")) game.write(save_val("hole")) game.write(save_val("gotten")) game.write(save_val("logged")) game.write(save_val("computer")) game.write(save_val("pc")) game.write(save_val("entry")) game.write(save_val("finale")) game.write(save_val("key_level")) game.write(save_val("mode")) game.write(save_val("dir_take")) game.write(save_val("box")) game.write(save_val("bins")) game.write(save_val("inventory")) game.write(save_val("items")) game.write(save_val("questions")) game.write(save_val("combination")) game.write(save_val("current_question")) game.write(save_val("wizard")) game.close() numsaves += 1 except Exception, error: print "Error saving to file." def restore(args): global visited, current_section, nochute, nomail, incar, hole, gotten, logged, computer, pc, entry, finale, key_level, mode, dir_take, box, bins, inventory, items, questions, combination, current_question, wizard if args == []: print "You must supply a filename." else: try: restored = open(os.path.join("saved games", "metadunnet3", "%s.txt" % args[0]), "r") command = "global visited, current_section, nochute, nomail, incar, hole, gotten, logged, computer, pc, entry, finale, key_level, mode, dir_take, box, bins, inventory, items, questions, combination, current_question, wizard\n" for line in restored: command = command + line exec command explainIfNew() except Exception, error: print "Could not load restore file." def climb(args): global items, inventory, box, hole if args == []: if current_section != sect["dead-end"]: print "There is nothing here to climb." else: climb(["pole"]) else: if not args[0] in obj: print "I don't know what that is." else: objnum = obj[args[0]] if objnum in items[current_section]: if objnum == obj["pole"]: print \ """You manage to get halfway up the pole and fall back down. You notice that the pole is very unsteady.""" else: print "You can't climb that." else: print "I don't see that here." def drive(args): if not incar: print "You cannot drive when you're not in a vehicle." else: move(args) def answer(args): global current_section, current_question, dir_take if not current_section == sect["question-room-1"] and not current_section == sect["question-room-2"] and \ not current_section == sect["question-room-3"]: print "I do not believe anyone asked you anything." else: if args == []: print "You must give the answer on the same line." else: given_answer = args[0] #There may be more than one answer to a question. Be aware. if not given_answer in questions[current_question][1]: print "That answer is incorrect." else: print "Correct." questions.remove(questions[current_question]) if questions == []: questions.append(["No more questions, just do 'answer finale'.", ["finale"]]) current_question = random.randrange(len(questions)) if dir_take == "north": current_section -= 1 else: current_section += 1 explainIfNew() def exercise(args): if obj["handlebars"] in inventory or (obj["handlebars"] in box and \ obj["box"] in inventory): print "That was hard work!" else: print "You try to exercise like this, but can't seem to do it." def _help(args): print \ """metadunnet[3].py by Nicholas McConnell started Wednesday, December 15, 2010 Welcome to the world of adventuring! Here are some tips: -If you have a key to open a door, you do not need to explicitly open it. You can just use 'in' or walk in the direction of the door. -If you have a lantern, it is always liit. -You never really earn any points unlesss you properly give up your items. Simply finding places to give them up is not good enough. You need to look for the correct spot where you can place the object for a result which is /unspoiled/ and /unharmed/. You can tell if you successfully gave up your item by looking your score, as it changes immediately. Also, after you have scored all your points, don't give up, because you'll eventually enter the finale and score more points. -You can save a game with the 'save' coommand, and restore it using the 'restore' command. -If you go down a hole without an aid, such as a staircase, you probably wouldn't be able to get back up the way you came, if at all. -There are no limits in the lengths of object names. -Directions are: north, south, east, weest, northeast, northwest, southeast, southwest, up, down, in, out. -These can be abbreviated: n, s, e, w, ne, nw, se, sw, u, d, in, out. -To run this game in batch mode (no IDLLE shell), use (in Nick): adventure NOTE: This game /should/ run in batch mode! If you have any questions about this, please go to the website http://www.bluzeandmuse.com/ and click on the Games link. """ #Now for the pc and entry. def pc_dir(args): time.sleep(2) print \ """Volume in drive A has no label. File List CII TXT - started Tues Dec 10 11:05:13 2002 JOKE TXT - started Fri Nov 25 15:46:42 2005 """ def pc_type(args): time.sleep(1) if args == []: print "File name required" else: if not args[0] in ["cii.txt", "joke.txt"]: print "Unknown file name" else: if args[0] == "cii.txt": print "\nThe combination is %s." % combination else: print \ """Hey, if your computer is still running, better chase it! - Jamie Feldman from UK """ def pc_a_drive(args): time.sleep(2) def pc_b_drive(args): time.sleep(2) print "Invalid drive for PC" def pc_c_drive(args): time.sleep(2) print "Invalid drive for PC" def pc_exit(args): print "\nYou power down the machine and step back." run_prompt() ## Verblist when using the PC in the land of Entry. pc_verblist = { "dir": pc_dir, "type": pc_type, "a:": pc_a_drive, "b:": pc_b_drive, "c:": pc_c_drive, "exit": pc_exit } def pc_interface(): time.sleep(3) print "Current time is %s" % time.asctime() newtime = raw_input("Enter new time: ") while True: pc_reply = raw_input("A:\\> ").lower().split() if len(pc_reply) > 0: if not pc_reply[0] in pc_verblist: time.sleep(2) print "Bad command to use" else: function = pc_verblist[pc_reply[0]] argset = pc_reply[1:len(pc_reply)] function(argset) def power(args): if current_section != sect["pc-area"]: print "That operation is not applicable here." else: if not pc: time.sleep(3) print "Boot sector not found" else: pc_interface() def entry_list(args): if not gotten: print \ """%d items found: => entry. deutsch restricted = list => entry. deutsch restricted = send => entry. deutsch restricted = areas => entry. deutsch restricted = get => entry. deutsch restricted = goto => entry. deutsch restricted = echo => entry. deutsch restricted = exit => entry. deutsch restricted = a slip of paper (inside)""" % (8 + len(inventory)) else: print \ """%d items found: => entry. deutsch restricted = list => entry. deutsch restricted = send => entry. deutsch restricted = areas => entry. deutsch restricted = get => entry. deutsch restricted = goto => entry. deutsch restricted = echo => entry. deutsch restricted = exit""" % (7 + len(inventory)) for i in inventory: print "=> entry. deutsch restricted = %s" % tk_objects[i][1].lower() def entry_send(args): global inventory, items if args == []: print " *** send: argument required on line" else: ## What?! User can send objects? That is absurd! if not args[0] in obj: print " *** send: unknown argument" else: objnum = obj[args[0]] if not objnum in inventory: print " *** send: unknown argument" #Doesn't matter! else: if not entry: print " *** send: host of entry not responding" else: print "Sending file for %s ..." % tk_objects[objnum][1].lower() print "Transfer complete." inventory.remove(objnum) items[sect["results"]].append(objnum) def entry_areas(args): print "%d areas found:" % len(visited) for i in visited: print "=> entry. areas restricted = %s" % section_desc[i][1].lower() def entry_get(args): global gotten if args == []: print "Get command failed" else: if args[0] in ["slip", "paper"] and not gotten: gotten = True inventory.append(obj["paper"]) else: print "Get command failed" def entry_goto(args): global current_section, items, inventory, finale if args == []: print "Host required on line" else: if not args[0] in ["entry", "finale"]: print "Unknown host" else: if args[0] == "entry": if not entry: print "Host not responding" else: spass = raw_input("password: ") if spass != "snail": print "Password incorrect" else: items[current_section] = items[current_section] + inventory inventory = [] print "You begin to feel strange for a moment, and lose your items." current_section = sect["results"] entry_exit([]) else: score([]) if not sum([obj_pts[x] for x in xrange(22) if x in items[sect["n-finales-room"]]]) == 90: print "You have not achieved enough points to connect to finale." else: print "Welcome to the finale. You are a truly brave adventurer." current_section = sect["n-finales-room"] finale = True entry_exit([]) def entry_echo(args): if args == []: print else: message = "" for i in args: if i[0] != "$": printer = i else: evaller = i[1:len(i)] if list(evaller) == [x for x in evaller if x in [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_", "[", "]", "-", "\""]]: try: printer = str(eval(evaller)) except Exception, error: printer = "" else: printer = "" message = message + printer + " " message = message[0:-1] print message def entry_exit(args): print "\nYou step back from the console." run_prompt() ## Verblist when using the Entry machine. entry_verblist = { "list": entry_list, "send": entry_send, "areas": entry_areas, "get": entry_get, "goto": entry_goto, "echo": entry_echo, "exit": entry_exit } def entry_interface(): global logged if not logged: for x in xrange(3): print "System ENTRY\n" login = raw_input("login: ") password = raw_input("password: ") if login == "deutsch" and password == "daniel": print "\nWelcome to Entry\n" print \ """You have submitted sufficiently. Please clean up your directories. """ logged = True break else: print "Login incorrect\n" if logged: while True: entry_reply = raw_input("$ ").lower().split() if len(entry_reply) > 0: if not entry_reply[0] in entry_verblist: if "=" in entry_reply[0]: entry_doassign(entry_reply) else: if entry_reply[0][0] == "$": try: entry_exec(entry_reply) except Exception, error: pass else: print " *** %s: not found, try list" % entry_reply[0] else: function = entry_verblist[entry_reply[0]] argset = entry_reply[1:len(entry_reply)] function(argset) def entry_exec(reply): ##When wizarded, you can do this. global wizard if not wizard: wpass = raw_input("Enter wizard pass: ") if wpass != "netta": print "Incorrect." else: wizard = True if wizard: com = "" for i in reply: com = com + i + " " com = com[1:-1] exec com def entry_doassign(reply): global wizard if not wizard: wpass = raw_input("Enter wizard pass: ") if wpass != "netta": print "Incorrect." else: wizard = True if wizard: com = "" for i in reply: com = com + i + " " com = com[0:-1] ##Look for the '=' character. eq_spot = None for trial in xrange(len(com)): if com[trial] == "=": eq_spot = trial break # Find the FIRST of these. varname = com[0:eq_spot] #Do everything SKIPPING the eq_spot index. setto = com[eq_spot+1:len(com)] try: exec "global %s\n%s = %s\n" % (varname, varname, setto) except Exception, whoops: print "Invalid syntax." def _type(args): if current_section != sect["computer-room"]: print "There is nothing here on which you could type." else: if not computer: print "You type on the keyboard, but the characters don't even echo." else: entry_interface() ##This verblist contains every command understood by the user and what # function it refers to. For instance, because this verblist contains # "toss": drop, it will understand "toss chip" as the same command # as drop(["chip"]). verblist = { "die": die, "quit": _quit, "win": win, "reward": win, "save": save, "restore": restore, "cut": cut, "slice": cut, "take": take, "get": take, "throw": drop, "drop": drop, "toss": drop, "x": examine, "examine": examine, "l": examine, "look": examine, "describe": examine, "read": examine, "eat": eat, "type": _type, "reset": power, "long": _long, "short": short, "normal": normal, "shake": shake, "wave": shake, "press": press, "switch": press, "push": press, "flick": press, "put": put, "insert": put, "place": put, "sleep": sleep, "lie": sleep, "answer": answer, "climb": climb, "go": move, "east": east, "e": east, "west": west, "w": west, "north": north, "n": north, "south": south, "s": south, "northeast": northeast, "ne": northeast, "northwest": northwest, "nw": northwest, "southeast": southeast, "se": southeast, "southwest": southwest, "sw": southwest, "up": up, "u": up, "down": down, "d": down, "in": _in, "out": out, "on": _in, "off": out, "enter": _in, "exit": out, "board": _in, "leave": out, "help": _help, "drive": drive, "lick": lick, "score": score, "inventory": inven, "i": inven, "exercise": exercise, "strengthen": exercise } ignore = ["the", "to", "at", "this", "that"] ##The run_prompt function apparently resumes the adventure from the # current section. First it tells the current section, and then it # asks for prompts about what the user wants to do. # It turns each prompt into a list of lowercase words. ##Then, it removes all words that are ignored. It then refers the # first word to the verblist and calls the matching function of # the rest of the words. No match makes the prompt misunderstood. def run_prompt(): global numcommands explainIfNew() while True: try: reply = raw_input(">").lower().split() if len(reply) > 0: for ignorer in ignore: while ignorer in reply: reply.remove(ignorer) if reply == []: reply = [""] if not reply[0] in verblist: print "I don't understand that." else: function = verblist[reply[0]] argset = reply[1:len(reply)] function(argset) numcommands += 1 except Exception, wizard_error: print " *** " + str(wizard_error) if __name__ == "__main__": run_prompt()