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 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)
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 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 handleBlueCorridor3(userInput, state): if userInput == 'GO SOUTH': if 'torch' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_2', userInput) and handleFalseTorchLevel( state, userInput) elif 'rustyKey' in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_2', userInput) and handleRustyKeyPickupCorridor2( 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_4', userInput) and handleFalseTorchLevel( state, userInput) elif 'rustyKey' not in state['inventory']: return goToLevel(state, 'BLUE_CORRIDOR_4', userInput) else: return goToLevel(state, 'BLUE_CORRIDOR_4', userInput) and handleRustyKeyPickupCorridor4( state, userInput) elif userInput == "TAKE RUSTY KEY" or userInput == "TAKE KEY": return takeItem(state, 'rustyKey') and handleRustyKeyPickup( state, userInput) elif userInput == 'GO WEST' or userInput == 'GO NORTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleUpperFloor(userInput, state): if userInput == 'TAKE STAIRS' or userInput == 'USE STAIRS': if 'carKeys' in state['inventory']: return goToLevel(state, 'HALL', userInput) and handleNewHallDesc( state, userInput) else: return goToLevel(state, 'HALL', userInput) elif userInput == 'USE GREY KEY' or userInput == 'USE KEY' and "greyKey" in state[ "inventory"]: return handlePersistantItems(state, "GREY KEY", 'BEDROOM') elif userInput == 'GO WEST': if 'GREY KEY' in state['usedItems']: if 'canvas' in state['inventory']: return goToLevel(state, 'BEDROOM', userInput) and handleNewBedroomDesc( state, userInput) else: return goToLevel(state, 'BEDROOM', userInput) else: return handleDoorLock(state, 'UPPER_FLOOR_W', userInput) elif userInput == 'USE LADDER' and "ladder" in state["inventory"]: if 'greyKey' in state['inventory']: return goToLevel(state, 'ATTIC', userInput) and handleNewAtticDesc( state, userInput) else: return goToLevel(state, 'ATTIC', userInput) elif userInput == 'GO NORTH': return handleDoorLock(state, 'UPPER_FLOOR_N', userInput) elif userInput == 'GO EAST' or userInput == 'GO SOUTH': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleMirrorRoom1(userInput, state): if userInput == "GO EAST": return goToLevel(state, 'MIRROR_ROOM_2', userInput) elif userInput == "GO SOUTH" or userInput == "GO WEST" or userInput == "GO NORTH": return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleOutside(userInput, state): if userInput == 'GO WEST': if "lightswitch" in state['usedItems'] and "brassKey" in state['inventory']: return goToLevel(state, 'GREENHOUSE', userInput) and handleKeyTakeGreenhouse(state) elif "lightswitch" in state['usedItems']: return goToLevel(state, 'GREENHOUSE', userInput) and handleLightGreenhouse(state) else: return goToLevel(state, 'GREENHOUSE', userInput) elif userInput == 'LICK DOOR': return goToLevel(state, 'MAIN_HALL', userInput) elif userInput == 'LOOK NICE': return goToLevel(state, 'MIRROR_ROOM_1', userInput) elif userInput == 'MR JALS': return goToLevel(state, 'SADNESS_1', userInput) elif userInput == 'PET THE BABY': return goToLevel(state, 'CRIB_ROOM', userInput) elif userInput == 'GO NOWHERE': return goToLevel(state, 'NOWHERE', userInput) elif userInput == 'SMASH': return goToLevel(state, 'LIVING_ROOM', userInput) elif userInput == 'HAVE A NICE DAY': return goToLevel(state, 'BEACH', userInput) elif userInput == 'ABSOLUTE LEGEND': return goToLevel(state, 'MAIN_HALL_ALL_KEYS', userInput) elif userInput == 'TAKE A SAD SHOWER': return goToLevel(state, 'BLUE_START', userInput) elif userInput == 'GO NORTH': return goToLevel(state, 'PORCH', 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 handleBlueFinish(userInput, state): if userInput == 'TAKE BLUE KEY' or userInput == 'TAKE KEY': return state['inventory'].pop('torch') and state['inventory'].pop( 'rustyKey') and returnToMainHall(state, 'blueKey', 'MAIN_HALL_ALL_KEYS') elif userInput == 'GO WEST' or userInput == 'GO NORTH' or userInput == 'GO EAST' or userInput == 'GO SOUTH': 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 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 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 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 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 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 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 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 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 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 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 handleAttic(userInput, state): if userInput == 'GO SOUTH': return handleDoorLock(state, 'ATTIC', userInput) elif userInput == 'USE LADDER' and "ladder" in state["inventory"]: return goToLevel(state, 'UPPER_FLOOR', userInput) elif userInput == 'TAKE GREY KEY' or userInput == 'TAKE KEY': return takeItem(state, 'greyKey') elif userInput == 'TAKE BOX' or userInput == 'TAKE BOXES': return handleInvalidBox(state) elif userInput == 'GO NORTH' or userInput == 'GO WEST' or userInput == 'GO EAST': return handleInvalidDirection(state) else: return handleInvalidInput(userInput, state)
def handleLighthouseTopFloor(userInput, state): global gateCalled global shedCalled if userInput == 'GO NORTH' or userInput == 'GO WEST' or userInput == 'GO EAST': return handleInvalidDirection(state) elif userInput == "TAKE STAIRS" or userInput == 'USE STAIRS': return goToLevel(state, "LIGHTHOUSE", userInput) elif userInput == 'TAKE GREEN KEY' or userInput == 'TAKE KEY': gateCalled = gateCalled - 1 shedCalled = shedCalled - 1 return state['inventory'].pop('oilLamp') and state['inventory'].pop('bronzeKey') and state['inventory'].pop('tornPages') and returnToMainHall(state, 'greenKey', 'MAIN_HALL_RETURN_FROM_GREEN') 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 handleBabyRoom(userInput, state): if userInput == 'GO EAST': if len(state['pinkPuzzleItems']) != 0: return handleInvalidDirection(state) elif 'pinkKey' in state['inventory']: return goToLevel(state, "STUDY_ROOM", userInput) and studyRoomWithPinkKeyPickedUp(state) elif '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 len(state['pinkPuzzleItems']) != 0: return handleInvalidDirection(state) else: return goToLevel(state, 'TOY_CAR_ROOM', userInput) elif userInput == "TAKE WORN DOLL" or userInput == "TAKE DOLL": return takeItem(state, 'wornDoll') elif 'USE' in userInput: puzzleList = state['pinkPuzzleItems'] if len(puzzleList) == 0: items=[ 'crib', 'moldyPacifier', 'wornDoll', 'dirtyBlanket', 'nurseryRhyme' ] currentItems=state['inventory'] for item in items: if item not in currentItems: return handleDoorLock(state, 'BABY_ROOM', userInput) return pinkRoomPuzzle(state, userInput) else: return pinkRoomPuzzle(state, userInput) elif userInput == "TAKE PINK KEY" or userInput == "TAKE KEY": return takeItem(state, 'pinkKey') elif userInput == 'GO NORTH' or userInput == 'GO WEST': return handleInvalidDirection(state) 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 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)