Exemple #1
0
def wardrobe_handler(handler_input):
    """
    Handler for processing Octopus_WardrobeIntent
    """
    state_variables = handler_input.attributes_manager.persistent_attributes

    response = OctopusRoom.wardrobe(state_variables)

    AlexaHelper.process_response(handler_input, response)

    return handler_input.response_builder.response
Exemple #2
0
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
Exemple #3
0
def octopus_handler(handler_input):
    """
    Handler for processing Octopus_OctopusIntent
    """
    state_variables = handler_input.attributes_manager.session_attributes
    response = OctopusRoom.octopus(state_variables)

    handler_input = AlexaHelper.process_response(handler_input, response)

    return handler_input.response_builder.response
Exemple #4
0
def repeat_intent_handler(handler_input):
    """
    Handler for RepeatIntent
    """
    state_helper = AlexaHelper.get_state_helper(
        lambda: handler_input.attributes_manager.persistent_attributes)

    previous_speech_text = state_helper.get_state("PreviousSpeechText")
    previous_reprompt = state_helper.get_state("PreviousReprompt")

    # TODO handle when above are None

    # TODO add audio snippet saying that this is a repeat of the previous speech

    # don't call the helper to build the response since we don't want to override the PreviousSpeechText session attribute
    handler_input.response_builder.speak(previous_speech_text).ask(
        previous_reprompt)

    return handler_input.response_builder.response
Exemple #5
0
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
Exemple #6
0
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