def _handle_turn_message(self, msg): self._start_time = self._get_current_time_millis() self._handle_init_message(self._init_message) self._current_turn = msg['currTurn'] self._player.deck = [ self._get_base_unit_by_id(deck_type_id) for deck_type_id in msg["deck"] ] self._player.hand = [ self._get_base_unit_by_id(hand_type_id) for hand_type_id in msg["hand"] ] self._handle_turn_units(msg=msg["diedUnits"], is_dead_unit=True) self._handle_turn_cast_spells(msg["castSpells"]) self._handle_turn_units(msg["units"]) self._handle_turn_kings(msg["kings"]) self._turn_updates = TurnUpdates( received_spell=msg["receivedSpell"], friend_received_spell=msg["friendReceivedSpell"], got_range_upgrade=msg["gotRangeUpgrade"], got_damage_upgrade=msg["gotDamageUpgrade"], available_range_upgrades=msg["availableRangeUpgrades"], available_damage_upgrades=msg["availableDamageUpgrades"]) self._player.set_spells( [self.get_spell_by_id(spell_id) for spell_id in msg["mySpells"]]) self._player_friend.set_spells([ self.get_spell_by_id(spell_id) for spell_id in msg["friendSpells"] ]) self._player.ap = msg["remainingAP"]
def __init__(self, world=None, queue=None): self._start_time = 0 self._init_message = None self._game_constants = None self._turn_updates = None self._map = None self._base_units = None self._current_turn = 0 self._players = [] self._player = None self._player_friend = None self._player_first_enemy = None self._player_second_enemy = None self._spells = [] self._cast_spells = [] if world is not None: self._init_message = world._init_message self._game_constants = world._game_constants self._turn_updates = TurnUpdates(turn_updates=world._turn_updates) self._map = world._map self._base_units = world._base_units self._spells = world._spells self._current_turn = world._current_turn self._players = world._players self._player = world._player self._player_friend = world._player_friend self._player_first_enemy = world._player_first_enemy self._player_second_enemy = world._player_second_enemy self._cast_spells = world._cast_spells self._queue = world._queue else: self._queue = queue if len(World._shortest_path) == 0: self._pre_process_shortest_path()
def __init__(self, world=None, queue=None): self.game_constants = None self.turn_updates = None self.map = None self.base_units = None self.current_turn = 0 self.players = [] self.player = None self.player_friend = None self.player_first_enemy = None self.player_second_enemy = None self.spells = [] self.cast_spells = [] if world is not None: self.game_constants = world.game_constants self.turn_updates = TurnUpdates(turn_updates=world.turn_updates) self.map = world.map self.base_units = world.base_units self.spells = world.spells self.current_turn = world.current_turn self.players = world.players self.player = world.player self.player_friend = world.player_friend self.player_first_enemy = world.player_first_enemy self.player_second_enemy = world.player_second_enemy self.cast_spells = world.cast_spells self.queue = world.queue else: self.queue = queue