Esempio n. 1
0
    def test_lack_of_location(self):
        state = GameState()
        state.add_robot((9, 9), 0)
        robot = state.robots[(9, 9)]

        with self.assertRaises(Exception):
            Player._validate_action(robot, ['move'])
Esempio n. 2
0
 def test_attack_obstacle(self):
     state = GameState()
     state.add_robot((2, 5), 0)
     robot = state.robots[(2, 5)]
     with self.assertRaises(Exception):
         Player._validate_action(robot, ['attack', (2, 4)])
Esempio n. 3
0
 def test_attack_too_far(self):
     state = GameState()
     state.add_robot((9, 9), 0)
     robot = state.robots[(9, 9)]
     with self.assertRaises(Exception):
         Player._validate_action(robot, ['attack', (9, 11)])
Esempio n. 4
0
 def test_move_to_self(self):
     state = GameState()
     state.add_robot((9, 9), 0)
     robot = state.robots[(9, 9)]
     with self.assertRaises(Exception):
         Player._validate_action(robot, ['move', (9, 9)])
Esempio n. 5
0
 def test_wrong_command(self):
     state = GameState()
     state.add_robot((9, 9), 0)
     robot = state.robots[(9, 9)]
     with self.assertRaises(Exception):
         Player._validate_action(robot, ['exterminate'])
Esempio n. 6
0
 def test_strange(self):
     state = GameState()
     state.add_robot((9, 9), 0)
     robot = state.robots[(9, 9)]
     with self.assertRaises(Exception):
         Player._validate_action(robot, "ALL YOUR BASE ARE BELONG TO US")
Esempio n. 7
0
 def test_none(self):
     state = GameState()
     state.add_robot((9, 9), 0)
     robot = state.robots[(9, 9)]
     with self.assertRaises(Exception):
         Player._validate_action(robot, None)
Esempio n. 8
0
 def test_ok(self):
     state = GameState()
     state.add_robot((9, 9), 0)
     robot = state.robots[(9, 9)]
     Player._validate_action(robot, ['guard'])
     Player._validate_action(robot, ['suicide'])
     Player._validate_action(robot, ['guard', None])
     Player._validate_action(robot, ['suicide', (1, 1)])
     Player._validate_action(robot, ['attack', (9, 10)])
     Player._validate_action(robot, ['move', (9, 10)])
     Player._validate_action(robot, ('guard', (2, 3)))
     Player._validate_action(robot, ('suicide', None))
     Player._validate_action(robot, ('attack', (9, 10)))
     Player._validate_action(robot, ('move', (9, 10)))