def handleBlueCorridor6(userInput, state): if userInput == 'GO SOUTH': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_5', userInput) and handleFalseTorchLevel( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_5', userInput) elif userInput == 'GO EAST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_7', userInput) and handleFalseTorchLevel( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_7', userInput) elif userInput == 'GO NORTH': if "rustyKey" in state['inventory']: if state['inventory']['rustyKey']['itemUse'] == True: return goToLevel(state, 'BLUE_CORRIDOR_8', userInput) else: return handleDoorLock(state, 'BLUE_CORRIDOR_6', userInput) else: return handleDoorLock(state, 'BLUE_CORRIDOR_6', userInput) elif userInput == 'GO WEST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleLivingRoom(userInput, state): if 'THROW' in userInput: return redPuzzle(state, userInput) elif userInput == 'TAKE RED KEY' or userInput == 'TAKE KEY' and 'carKeys' in state[ 'isBurned']: return state['inventory'].pop('greyKey') and state['inventory'].pop( 'ladder') and returnToMainHall(state, 'redKey', 'MAIN_HALL_RETURN_FROM_RED') elif userInput == 'GO EAST': if 'photograph' in state['inventory']: return goToLevel(state, 'KITCHEN', userInput) and handleNewKitchenDesc( state, userInput) else: return goToLevel(state, 'KITCHEN', userInput) elif userInput == 'GO WEST': if 'carKeys' in state['inventory']: return goToLevel(state, 'HALL', userInput) and handleNewHallDesc( state, userInput) else: return goToLevel(state, 'HALL', userInput) elif userInput == 'GO NORTH' or userInput == 'GO SOUTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleMirrorRoom2(userInput, state): if userInput == "GO NORTH": return goToLevel(state, 'JOY', userInput) elif userInput == "GO WEST": return goToLevel(state, 'MIRROR_ROOM_1', userInput) elif userInput == "GO SOUTH" or userInput == "GO EAST": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleLighthouseOutside(userInput, state): if userInput == 'GO NORTH': return goToLevel(state, 'LIGHTHOUSE', userInput) elif userInput == "GO SOUTH": return goToLevel(state, "GATE", userInput) elif userInput == 'GO WEST' or userInput == 'GO EAST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleAnger2(userInput, state): if userInput == "GO EAST": return goToLevel(state, 'LOVE', userInput) elif userInput == "GO SOUTH": return goToLevel(state, 'ANGER_1', userInput) elif userInput == "GO WEST" or userInput == "GO NORTH": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleSadness1(userInput, state): if userInput == "GO WEST": return goToLevel(state, 'SADNESS_2', userInput) elif userInput == "GO SOUTH": return goToLevel(state, 'LOVE', userInput) elif userInput == "GO EAST" or userInput == "GO NORTH": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleLighthouse(userInput, state): if userInput == 'GO WEST' or userInput == 'GO EAST' or userInput == 'GO NORTH': return handleInvalidDirection(state) elif userInput == "GO SOUTH": return goToLevel(state, "LIGHTHOUSE_OUTSIDE", userInput) elif userInput == 'TAKE STAIRS' or userInput == 'USE STAIRS': return goToLevel(state, "LIGHTHOUSE_TOP_FLOOR", userInput) else: return handleInvalidInput(userInput, state)
def handleJoy(userInput, state): if userInput == "GO WEST": return goToLevel(state, 'ANGER_1', userInput) elif userInput == "GO SOUTH": return goToLevel(state, 'MIRROR_ROOM_2', userInput) elif userInput == "NORTH" or userInput == "GO EAST": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleSadness2(userInput, state): if userInput == 'TAKE POCKET WATCH' or userInput == 'TAKE WATCH': return goToLevel(state, "END", userInput) elif userInput == "GO EAST": return goToLevel(state, 'SADNESS_1', userInput) elif userInput == "GO WEST" or userInput == "GO NORTH": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleLove(userInput, state): if userInput == "GO NORTH": return goToLevel(state, 'SADNESS_1', userInput) elif userInput == "GO WEST": return goToLevel(state, 'ANGER_2', userInput) elif userInput == "GO SOUTH" or userInput == "GO EAST": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBlueCorridor1(userInput, state): if userInput == 'GO SOUTH': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_START', userInput) else: return goToLevel(state, 'BLUE_START', userInput) and handleTrueTorchLevel( state, userInput) elif userInput == 'GO WEST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_2', userInput) and handleFalseTorchLevel( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_2', userInput) elif userInput == 'GO EAST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_5', userInput) and handleFalseTorchLevel( state, userInput) elif 'rustyKey' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_5', userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_5', userInput) and handleRustyKeyPickupCorridor5( state, userInput) elif userInput == 'GO NORTH': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_4', userInput) and handleFalseTorchLevel( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_4', userInput) else: return handleInvalidInput(userInput, state)
def handlePorch(userInput, state): if userInput == 'GO SOUTH': return goToLevel(state, 'OUTSIDE', userInput) elif userInput == 'USE BRASS KEY' or userInput == 'USE KEY' and "brassKey" in state["inventory"]: return state['inventory'].pop('brassKey') and goToLevel(state, 'MAIN_HALL', userInput) elif userInput == 'GO NORTH': return handleDoorLock(state, 'PORCH', userInput) elif userInput == 'GO EAST' or userInput == 'GO WEST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBeachEastSide(userInput, state): if userInput == 'GO WEST': return goToLevel(state, 'BEACH', userInput) and handleNewBeachDesc(state, userInput) elif userInput == 'GO EAST': if "tornPages" in state["inventory"]: return goToLevel(state, 'SHIPWRECK', userInput) and handleNewShipwreckDesc(state, userInput) else: return goToLevel(state, "SHIPWRECK", userInput) elif userInput == 'GO SOUTH' or userInput == 'GO NORTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleShipwreck(userInput, state): if userInput == 'GO WEST': return goToLevel(state, 'BEACH_EAST_SIDE', userInput) elif userInput == "GO EAST": if "tornPages" in state["inventory"]: return goToLevel(state, 'CAPTAINS_CABIN', userInput) and handleNewCabinDesc(state, userInput) else: return goToLevel(state, "CAPTAINS_CABIN", userInput) elif userInput == 'GO NORTH' or userInput == "GO SOUTH": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleShedFrontDoor(userInput, state): if userInput == 'GO WEST': if "oilLamp" in state["inventory"]: return goToLevel(state, "SHED", userInput) and handleNewShedDesc(state, userInput) else: return goToLevel(state, "SHED", userInput) elif userInput == 'GO NORTH' or userInput == "GO SOUTH": return handleInvalidDirection(state) elif userInput == 'GO EAST': return goToLevel(state, "BEACH", userInput) and handleNewBeachDesc(state, userInput) else: return handleInvalidInput(userInput, state)
def handleTorchRoom(userInput, state): if userInput == "TAKE TORCH": return takeItem(state, 'torch') elif userInput == 'GO EAST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_START', userInput) else: return goToLevel(state, 'BLUE_START', userInput) and handleTrueTorchLevel( state, userInput) elif userInput == 'GO NORTH' or userInput == 'GO SOUTH' or userInput == 'GO WEST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBlueCorridor9(userInput, state): if userInput == 'GO SOUTH' or userInput == 'GO WEST': return handleInvalidDirection(state) elif userInput == 'GO NORTH': return goToLevel(state, 'BLUE_FINISH', userInput) elif userInput == 'GO EAST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_8', userInput) and handleFalseTorchLevel( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_8', userInput) else: return handleInvalidInput(userInput, state)
def handleCellar(userInput, state): if userInput == 'GO WEST' or userInput == "GO NORTH" or userInput == "GO EAST" or userInput == "GO SOUTH": return handleInvalidDirection(state) elif userInput == 'TAKE STAIRS' or userInput == 'USE STAIRS': if "oilLamp" in state["inventory"]: return goToLevel(state, 'SHED', userInput) and handleNewShedDesc(state, userInput) else: return goToLevel(state, "SHED", userInput) elif userInput == "USE OIL LAMP" and "oilLamp" in state["inventory"]: return handleNewCellarDesc(state) elif userInput == "TAKE BRONZE KEY" or userInput == "TAKE KEY": return takeItem(state, 'bronzeKey') else: return handleInvalidInput(userInput, state)
def handleBeach(userInput, state): if userInput == 'GO WEST': if "oilLamp" in state["inventory"]: return goToLevel(state, "SHED_FRONT_DOOR", userInput) and handleNewShedFrontDoorDesc(state, userInput) else: return goToLevel(state, "SHED_FRONT_DOOR", userInput) elif userInput == 'GO NORTH': return goToLevel(state, 'GATE', userInput) elif userInput == 'GO SOUTH': return handleOcean(state) elif userInput == 'GO EAST': return goToLevel(state, "BEACH_EAST_SIDE", userInput) else: return handleInvalidInput(userInput, state)
def handleToyCarRoom(userInput, state): if userInput == 'GO NORTH': if 'wornDoll' in state['inventory']: return goToLevel(state, 'BABY_ROOM', userInput) and babyRoomWithDollPickedUp(state) else: return goToLevel(state, 'BABY_ROOM', userInput) elif userInput == 'GO SOUTH': if 'crib' in state ['inventory']: return goToLevel(state, 'CRIB_ROOM', userInput) and cribRoomWithCribPickedUp(state) else: return goToLevel(state, 'CRIB_ROOM', userInput) elif userInput == 'GO WEST' or userInput == 'GO EAST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleCribRoom(userInput, state): if userInput == 'GO NORTH': return goToLevel(state, 'TOY_CAR_ROOM', userInput) elif userInput == 'GO EAST': if 'nurseryRhyme' in state ['inventory']: return goToLevel(state, 'MESSY_ROOM', userInput) and messyRoomWithRhymePickedUp(state) else: return goToLevel(state, 'MESSY_ROOM', userInput) return handleInvalidDirection(state) elif userInput == "TAKE CRIB": return takeItem(state, 'crib') elif userInput == 'GO SOUTH' or userInput == 'GO WEST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBasement(userInput, state): if userInput == 'TAKE STAIRS' or userInput == 'USE STAIRS': if 'photograph' in state['inventory']: return goToLevel(state, 'KITCHEN', userInput) and handleNewKitchenDesc( state, userInput) else: return goToLevel(state, 'KITCHEN', userInput) elif userInput == 'TAKE LADDER': return takeItem(state, 'ladder') elif userInput == 'TAKE TOYS' or userInput == 'TAKE OLD TOYS': return handleInvalidToy(state) elif userInput == 'GO WEST' or userInput == 'GO SOUTH' or userInput == 'GO EAST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleGate(userInput, state): global gateCalled if userInput == "USE BRONZE KEY" or userInput == 'USE KEY' and "bronzeKey" in state["inventory"]: gateCalled = gateCalled + 1 return goToLevel(state, 'LIGHTHOUSE_OUTSIDE', userInput) elif userInput == "GO NORTH": if "bronzeKey" in state["inventory"] and gateCalled >= 1: return goToLevel(state, "LIGHTHOUSE_OUTSIDE", userInput) and handleNewGateDesc(state) else: return handleDoorLock(state, "GATE", userInput) elif userInput == "GO SOUTH": return goToLevel(state, "BEACH", userInput) and handleNewBeachDesc(state, userInput) elif userInput == 'GO WEST' or userInput == 'GO EAST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBedroom(userInput, state): if userInput == 'GO EAST' and "greyKey" in state['inventory']: if 'photograph' in state['inventory'] and 'carKeys' in state[ 'inventory'] and 'canvas' in state['inventory']: state['inventory']['greyKey']['itemUse'] = True return goToLevel(state, 'UPPER_FLOOR', userInput) and handleFireLoudDesc( state, userInput) else: return goToLevel(state, 'UPPER_FLOOR', userInput) elif userInput == 'TAKE CANVAS': return takeItem(state, 'canvas') elif userInput == 'GO NORTH' or userInput == 'GO SOUTH' or userInput == 'GO WEST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleStudyRoom(userInput, state): if userInput == 'GO NORTH': if 'moldyPacifier' in state ['inventory']: return goToLevel(state, 'NURSING_ROOM', userInput) and nursingRoomWithPacifierPickedUp(state) else: return goToLevel(state, 'NURSING_ROOM', userInput) elif userInput == 'GO SOUTH': if 'nurseryRhyme' in state ['inventory']: return goToLevel(state, 'MESSY_ROOM', userInput) and messyRoomWithRhymePickedUp(state) else: return goToLevel(state, 'MESSY_ROOM', userInput) elif userInput == "TAKE DIRTY BLANKET" or userInput == "TAKE BLANKET": return takeItem(state, 'dirtyBlanket') elif userInput == 'GO WEST' or userInput == 'GO EAST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleMessyRoom(userInput, state): if userInput == 'GO NORTH': if 'dirtyBlanket' in state ['inventory']: return goToLevel(state, 'STUDY_ROOM', userInput) and studyRoomWithBlanketPickedUp(state) else: return goToLevel(state, 'STUDY_ROOM', userInput) elif userInput == 'GO WEST': if 'crib' in state ['inventory']: return goToLevel(state, 'CRIB_ROOM', userInput) and cribRoomWithCribPickedUp(state) else: return goToLevel(state, 'CRIB_ROOM', userInput) elif userInput == "TAKE NURSERY RHYME" or userInput == "TAKE RHYME" or userInput == "TAKE NOTEBOOK": return takeItem(state, 'nurseryRhyme') elif userInput == 'GO EAST' or userInput == 'GO SOUTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBlueStart(userInput, state): if userInput == 'GO WEST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_TORCH_ROOM', userInput) else: return goToLevel(state, 'BLUE_TORCH_ROOM', userInput) and handleTorchInTorchRoom( state, userInput) elif userInput == 'GO SOUTH' or userInput == 'GO EAST': return handleInvalidDirection(state) elif userInput == 'GO NORTH': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_1', userInput) and handleFalseTorchLevel( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_1', userInput) else: return handleInvalidInput(userInput, state)
def handleCaptainsCabin(userInput, state): if userInput == 'GO WEST': return goToLevel(state, 'SHIPWRECK', userInput) and handleNewShipwreckDesc(state, userInput) elif userInput == "GO EAST" or userInput == "GO NORTH" or userInput == "GO SOUTH": return handleInvalidDirection(state) elif userInput == "TAKE TORN PAGES" or userInput == "TAKE PAGES": return takeItem(state, "tornPages") elif userInput == "TAKE FAMILY PHOTOGRAPH" or userInput == "TAKE PHOTOGRAPH" or userInput == "TAKE FAMILY PHOTO" or userInput == "TAKE FRAMED FAMILY PHOTOGRAPH": return handleInvalidPhoto(state) else: return handleInvalidInput(userInput, state)
def handleKitchen(userInput, state): if userInput == 'GO WEST': if 'photograph' and 'carKeys' and 'canvas' in state['inventory']: return goToLevel(state, 'LIVING_ROOM', userInput) and handleNewLivingRoomDesc( state, userInput) else: return goToLevel(state, 'LIVING_ROOM', userInput) elif userInput == 'TAKE PHOTOGRAPH': return takeItem(state, 'photograph') elif userInput == 'TAKE STAIRS' or userInput == 'USE STAIRS': if 'ladder' in state['inventory']: return goToLevel(state, 'BASEMENT', userInput) and handleNewBasementDesc( state, userInput) else: return goToLevel(state, 'BASEMENT', userInput) elif userInput == 'GO NORTH' or userInput == 'GO EAST' or userInput == 'GO SOUTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleBlueCorridor2(userInput, state): if userInput == 'GO NORTH': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_3', userInput) and handleFalseTorchLevel( state, userInput) elif 'rustyKey' in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_3', userInput) and handleRustyKeyPickup( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_3', userInput) elif userInput == 'GO EAST': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_1', userInput) and handleFalseTorchLevel( state, userInput) elif 'rustyKey' in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_1', userInput) and handleRustyKeyPickupCorridor1( state, userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_1', userInput) elif userInput == 'GO WEST' or userInput == 'GO SOUTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)