Пример #1
0
def check_for_navigation(pipeline):
    if pipeline.output == iotypes.File and len(pipeline.commands) == 1\
            and command_refers_to_dir(pipeline.commands[0]):
        go_command = parser.get_command('go', [])
        pipeline.add(go_command) 
        file_command = parser.get_command('file', ['.'])
        pipeline.add(file_command) 
        ls_command = parser.get_command('ls', [])
        pipeline.add(ls_command) 
Пример #2
0
def play():
    clear_screen()
    print_wrap("Welcome to %s." % game_name)
    player = Player()
    world = World()
    print_wrap(world.tile_at(player.x, player.y).intro_text())
    while True:
        print("")  # Print a blank line for spacing purposes.
        [raw_input, parsed_input] = parser.get_command()
        print("")  # Print a blank line for spacing purposes.

        if (parsed_input):
            if (len(parsed_input) == 1):
                if (parsed_input[0] == "help"):
                    print_wrap(help_text)
                elif (parsed_input[0] == "check"):
                    print_wrap(world.tile_at(player.x, player.y).intro_text())
                elif (parsed_input[0] == "exit" or parsed_input[0] == quit):
                    exit()
                else:
                    print(
                        "I don't understand what you are trying to do. Please try again."
                    )
            elif (len(parsed_input) == 2):
                if (parsed_input[0] == "go"):  ### Command "go"
                    move_status = False
                    if (parsed_input[1] == "north"):
                        [move_status, move_description
                         ] = world.check_north(player.x, player.y)
                        print_wrap(move_description)
                        if (move_status):
                            player.move_north()
                    elif (parsed_input[1] == "south"):
                        [move_status, move_description
                         ] = world.check_south(player.x, player.y)
                        print_wrap(move_description)
                        if (move_status):
                            player.move_south()
                    elif (parsed_input[1] == "east"):
                        [move_status, move_description
                         ] = world.check_east(player.x, player.y)
                        print_wrap(move_description)
                        if (move_status):
                            player.move_east()
                    elif (parsed_input[1] == "west"):
                        [move_status, move_description
                         ] = world.check_west(player.x, player.y)
                        print_wrap(move_description)
                        if (move_status):
                            player.move_west()
                    else:
                        print("I don't understand where you're trying to go.")

                    if (
                            move_status
                    ):  # If we have successfully moved, give the player the new location's description.
                        print_wrap(
                            world.tile_at(player.x, player.y).intro_text())

                elif (parsed_input[0] == "check"):  ### Command "check"
                    if (parsed_input[1] == "inventory"):
                        player.print_inventory()
                    elif (parsed_input[1] == "around"):
                        print_wrap(
                            world.tile_at(player.x, player.y).intro_text())
                    else:
                        print("I don't know what you're trying to look at.")

                else:
                    print(
                        "I don't understand what you are trying to do. Please try again."
                    )
            else:
                print(
                    "I don't understand what you are trying to do. Please try again."
                )

            if (debug_mode):
                print()
                print("RAW USER COMMANDS: " + raw_input)
                print("PARSED USER COMMANDS: " + str(parsed_input))


#for word in parsed_input:
#	if(word):
#		print(word + " ")
#	else:
#		print("None")
        else:
            print("Something seems to have gone wrong. Please try again.")
Пример #3
0
 def testSwitchOff(self):
     command = parser.get_command("switch xyz off")
     self.assertEqual("--off xyz", command.tdtool())
Пример #4
0
 def testShowStatus(self):
     command = parser.get_command("show status")
     self.assertEqual("--list", command.tdtool())
Пример #5
0
 def testSwitchOn(self):
     command = parser.get_command("switch xyz on")
     self.assertEqual("--on xyz", command.tdtool())