Exemplo n.º 1
0
def parse_untargetable_command(user_input, player):
    command = user_input[0]
    if command in Constants.DIRECTIONS[0]:
        return Commands.parse_move_command(user_input, player)
    if command in Constants.HELP:
        return Commands.parse_help_command()
    if command in Constants.LOOK:
        return Commands.parse_look_command(player)
    if command in Constants.QUIT:
        return Commands.parse_quit_command()
    if command in Constants.INVENTORY:
        return Commands.parse_inventory_command(player)

    # If the command is in the targeted commands like 'examine' or 'give', tell the player this.
    if is_command_valid(
            user_input, Constants.SINGLE_TARGET_COMMANDS +
            Constants.DOUBLE_TARGET_COMMANDS):
        return Constants.IMPROPERLY_TARGETED_COMMAND

    return Constants.INVALID_COMMAND_GIVEN_STRING
Exemplo n.º 2
0
 def test_help_command(self):
     actual = Commands.parse_help_command()
     self.assertEqual(Constants.PLAYER_HELP, actual)