def launch_request_handler(handler_input): """ Handler for Skill Launch. """ # type: (HandlerInput) -> Response state_variables = handler_input.attributes_manager.persistent_attributes if state_variables is None: state_variables = {} if not state_variables: state_variables[TheWhispererInDarkness.ROOM] = Room.lobby state_variables[TheWhispererInDarkness.HAS_KEY] = False state_variables[TheWhispererInDarkness.CHAINS_INVESTIGATED] = False state_variables[TheWhispererInDarkness.BOOK_UNLOCKED] = False state_variables[TheWhispererInDarkness.HAS_BOOK] = False state_variables[TheWhispererInDarkness.CHEST_OPENED] = False state_variables[TheWhispererInDarkness.MIRROR_BROKEN] = False state_variables[OctopusRoom.IS_AQUARIUM_OPEN] = False state_variables[OctopusRoom.IS_OCTOPUS_RELEASED] = False handler_input.attributes_manager.session_attributes = state_variables response = TheWhispererInDarkness.handle_launch() handler_input = AlexaHelper.process_response(handler_input, response) return handler_input.response_builder.response
def help_intent_handler(handler_input): """ Handler for Help Intent. """ # type: (HandlerInput) -> Response response = TheWhispererInDarkness.help() handler_input.response_builder.speak(response.speech_text).ask( response.reprompt) return handler_input.response_builder.response
def repeat_riddle_handler(handler_input): # reponse captured from game class. Contains speech text and transformed state variables. response = TheWhispererInDarkness.repeat_riddle() # save speech text speech_text = response.speech_text reprompt = "Repeat yourself" handler_input.response_builder.speak(speech_text).ask(reprompt) return handler_input.response_builder.response
def fallback_handler(handler_input): """ AMAZON.FallbackIntent is only available in en-US locale. This handler will not be triggered except in that locale, so it is safe to deploy on any locale. """ # type: (HandlerInput) -> Response response = TheWhispererInDarkness.fallback() handler_input.response_builder.speak(response.speech_text).ask( response.reprompt) return handler_input.response_builder.response
def leave_room_intent(handler_input): state_variables = handler_input.attributes_manager.session_attributes # reponse captured from game class. Contains speech text and transformed state variables. response = TheWhispererInDarkness.leave_room(state_variables) # save state variables handler_input.attributes_manager.session_attributes = response.state_variables # save speech text speech_text = response.speech_text reprompt = "Repeat yourself" handler_input.response_builder.speak(speech_text).ask(reprompt) return handler_input.response_builder.response
def open_box_handler(handler_input): """ Handler for processing OpenBoxIntent """ state_helper = StateHelper( handler_input.attributes_manager.session_attributes) room = state_helper.get_state(TheWhispererInDarkness.ROOM) if (room is not None and Room(room) == Room.octopus): return aquarium_handler(handler_input) elif (room is not None and Room(room) == Room.mirror): return open_chest_intent(handler_input) response = TheWhispererInDarkness.generic_error_response() handler_input = AlexaHelper.process_response(handler_input, response) return handler_input.response_builder.response
def investigate_chains_handler(handler_input): """ Handler for investigating the chains around the book in the door on the right """ # type: (HandlerInput) -> Response state_variables = handler_input.attributes_manager.session_attributes # reponse captured from game class. Contains speech text and transformed state variables. response = TheWhispererInDarkness.investigate_chains(state_variables) # save state variables handler_input.attributes_manager.session_attributes = response.state_variables # save speech text speech_text = response.speech_text reprompt = "Repeat yourself" handler_input.response_builder.speak(speech_text).ask(reprompt) return handler_input.response_builder.response
def use_key_intent(handler_input): """ Handler for using the key to unlock the chains around the screaming book """ # type: (HandlerInput) -> Response state_variables = handler_input.attributes_manager.session_attributes # reponse captured from game class. Contains speech text and transformed state variables. response = TheWhispererInDarkness.use_key(state_variables) # save state variables handler_input.attributes_manager.session_attributes = response.state_variables # save speech text speech_text = response.speech_text reprompt = "Repeat yourself" handler_input.response_builder.speak(speech_text).ask(reprompt) return handler_input.response_builder.response
def enter_door_handler(handler_input): """ Handler for processing the enter door command """ # type: (HandlerInput) -> Response # the value of DoorNumber slot passed alongside the intent try: door = str(handler_input.request_envelope.request.intent. slots["DoorNumber"].value) except: door = None if (door == None): try: door = str(handler_input.request_envelope.request.intent. slots["DoorOrder"].value) except: door = None if (door == None): try: door = str(handler_input.request_envelope.request.intent. slots["LeftRight"].value) except: door = None state_variables = handler_input.attributes_manager.session_attributes # reponse captured from game class. Contains speech text and transformed state variables. response = TheWhispererInDarkness.enter_door(door, state_variables) # call our helper method to update the handler_input handler_input = AlexaHelper.process_response(handler_input, response) return handler_input.response_builder.response