Ejemplo n.º 1
0
    def _change_tactic(self, cmd: STAChangeCommand):

        try:
            this_player = GameState().our_team.available_players[cmd.data['id']]
        except KeyError:
            self.logger.info('A tactic was assign to a player which is not on the field (id={}).'.format(cmd.data['id']))
            this_player = GameState().our_team.players[cmd.data['id']]

        player_id = this_player.id
        tactic_name = cmd.data['tactic']
        target = Position.from_list(cmd.data['target'])
        if config['GAME']['on_negative_side']:
            target = target.flip_x()
        target = Pose(target, this_player.orientation)
        args = cmd.data.get('args', '')
        try:
            tactic = self.play_state.get_new_tactic(tactic_name)(self.game_state, this_player, target, args)
        except:
            self.logger.exception('An error occurred.')
            self.logger.debug('The tactic was call with wrong arguments')
            raise

        if not isinstance(self.play_state.current_strategy, HumanControl):
            self.play_state.current_strategy = 'HumanControl'
        self.play_state.current_strategy.assign_tactic(tactic, player_id)
Ejemplo n.º 2
0
 def test_givenList_whenFromList_thenPositionIsInstantiated(self):
     pos = Position.from_list(A_LIST)
     self.assertEqual(pos.x, A_LIST[0])
     self.assertEqual(pos.y, A_LIST[1])
Ejemplo n.º 3
0
 def test_givenList_whenFromList_thenPositionIsInstantiated(self):
     pos = Position.from_list(A_LIST)
     self.assertEqual(pos.x, A_LIST[0])
     self.assertEqual(pos.y, A_LIST[1])