Пример #1
0
 def test_move_command_valid_move(self):
     user_input = "north"
     player = copy.copy(Test_Objects.TEST_PLAYER)
     room = copy.copy(Test_Objects.TEST_ROOM)
     room_two = copy.copy(Test_Objects.TEST_ROOM_2)
     self.assertEqual(player.location.desc, room.desc)
     Commands.parse_move_command(user_input, player)
     self.assertEqual(player.location.desc, room_two.desc)
Пример #2
0
 def test_move_command_invalid_move(self):
     user_input = "west"
     player = copy.copy(Test_Objects.TEST_PLAYER)
     room = copy.copy(Test_Objects.TEST_ROOM)
     self.assertEqual(player.location.desc, room.desc)
     actual = Commands.parse_move_command(user_input, player)
     self.assertEqual(Constants.EXIT_NOT_FOUND_STRING, actual)
Пример #3
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