示例#1
0
def send_next():
    if not actionsArray:
        return
    if env.nice_demand:
        tts = ALProxy("ALTextToSpeech", env.nao_ip, env.nao_port)
        tts.say(random.choice(pleasedAnswers))
    while actionsArray:
        action = actionsArray.pop(0)
        print action
        actions.do_action(action)
    env.nice_demand = False
示例#2
0
def main():
    cur_state = State()
    if not cur_state.game_state:
        cur_state.main_menu()

    player = cur_state.game_state['player']
    player_location = player.location

    party = cur_state.game_state['party']
    party_status = False
    for character in party:
        if character.cur_stats['health'] > 0:
            party_status = True

    while party_status:
        current_location = getattr(navigation, player_location.replace(" ", ""))()

        action_input = input('Choose an action: ')
        available_actions = current_location.available_actions()
        found_action = False
        for action in available_actions:
            if action_input.lower() == 'exit':
                sys.exit()

            if (action_input.lower() == action.hotkey.lower()) or \
                    (action_input.lower() in [a.lower() for a in action.alt]):
                os.system('clear')  # For OSX / Linux
                os.system('cls')  # For Windows
                found_action = True
                actions.do_action(action, action.action_class, **action.kwargs)
                break
        if not found_action:
            os.system('clear')  # For OSX / Linux
            os.system('cls')  # For Windows

        cur_state = State()
        cur_state.load_quicksave()
        player = cur_state.game_state['player']
        player_location = player.location
        cur_state.save_game()
示例#3
0
def waitForCommands():
    recognizer = sr.Recognizer()
    microphone = sr.Microphone()

    while True:
        playText("Say something!")
        guess = recognize_speech_from_mic(recognizer, microphone)
        if guess["transcription"]:
            break
        if not guess["success"]:
            break
        playText("I didn't catch that. What did you say?")

    if guess["error"]:
        print("ERROR: {}".format(guess["error"]))

    playText("You said: {}".format(guess["transcription"]))

    action = do_action(guess["transcription"].lower())

    return action
示例#4
0
#!/usr/bin/env python

"""
main() for project_utils. parses command line options and routes to correct
handler
"""

import argparse

from os import path

import config
import actions

# construct argparser and setup main app options
parser = argparse.ArgumentParser(prog="putils",
    description="a set of cli commands to help during development")
parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("--version", action="version", version="%(prog)s 0.1")

# add subparsers for each of the individual functions
subparsers = parser.add_subparsers(dest="action")
actions.setup_actions(subparsers)

actions.do_action(parser.parse_args())
示例#5
0
 def __init__(self):
     actions.do_action(actions.FightMonsters(combat.Combat()), combat.Combat())
     super().__init__()