diff --git a/model.py b/model.py index 743b38a..ab24cbc 100644 --- a/model.py +++ b/model.py @@ -1,6 +1,4 @@ -import copy from enum import Enum - from typing import * diff --git a/world.py b/world.py index aa9b0f6..2d702c5 100644 --- a/world.py +++ b/world.py @@ -201,7 +201,8 @@ def _handle_turn_kings(self, msg): self.get_player_by_id(king_msg["playerId"]).king.hp = king_msg["hp"] if king_msg["target"] != -1: self.get_player_by_id(king_msg["playerId"]).king.target = self.get_unit_by_id(king_msg["target"]) - self.get_player_by_id(king_msg["playerId"]).king.target_cell = self.get_unit_by_id(king_msg["target"]).cell + self.get_player_by_id(king_msg["playerId"]).king.target_cell = self.get_unit_by_id( + king_msg["target"]).cell else: self.get_player_by_id(king_msg["playerId"]).king.target = None self.get_player_by_id(king_msg["playerId"]).king.target_cell = None @@ -293,20 +294,20 @@ def _handle_turn_cast_spells(self, msg): cast_spell_msg["affectedUnits"]] if spell.is_area_spell(): cast_area_spell = CastAreaSpell(spell=spell, id=cast_spell_msg["id"], - caster_id=cast_spell_msg["casterId"], cell=cell, - remaining_turns=cast_spell_msg["remainingTurns"], - affected_units=affected_units) + caster_id=cast_spell_msg["casterId"], cell=cell, + remaining_turns=cast_spell_msg["remainingTurns"], + affected_units=affected_units) self._cast_spells.append(cast_area_spell) if cast_spell_msg["wasCastThisTurn"]: self.get_player_by_id(cast_spell_msg["casterId"]).cast_area_spell = cast_area_spell elif spell.is_unit_spell(): cast_unit_spell = CastUnitSpell(spell=spell, id=cast_spell_msg["id"], - caster_id=cast_spell_msg["casterId"], - cell=cell, - unit=self.get_unit_by_id(cast_spell_msg["unitId"]), - path=self._map.get_path_by_id(cast_spell_msg["pathId"]), - affected_units=affected_units) + caster_id=cast_spell_msg["casterId"], + cell=cell, + unit=self.get_unit_by_id(cast_spell_msg["unitId"]), + path=self._map.get_path_by_id(cast_spell_msg["pathId"]), + affected_units=affected_units) self._cast_spells.append(cast_unit_spell) if cast_spell_msg["wasCastThisTurn"]: self.get_player_by_id(cast_spell_msg["casterId"]).cast_unit_spell = cast_unit_spell @@ -338,7 +339,6 @@ def _handle_turn_message(self, msg): self._player_friend.set_spells([self.get_spell_by_id(spell_id) for spell_id in msg["friendSpells"]]) self._player.ap = msg["remainingAP"] - def choose_hand_by_id(self, type_ids: List[int]) -> None: message = Message(type="pick", turn=self.get_current_turn(), info=None) if type_ids is not None: @@ -400,7 +400,7 @@ def get_paths_crossing_cell(self, cell: Cell = None, row: int = None, col: int = Logs.show_log("get_paths_crossing cell function called with no valid argument") return [] cell = self._map.get_cell(row, col) - + cell = self._map.get_cell(cell.row, cell.col) if not isinstance(cell, Cell): Logs.show_log("Given cell is invalid!") return [] @@ -418,6 +418,7 @@ def get_cell_units(self, cell: Cell = None, row: int = None, col: int = None) -> Logs.show_log("get_paths_crossing cell function called with no valid argument") return [] cell = self._map.get_cell(row, col) + cell = self._map.get_cell(cell.row, cell.col) if not isinstance(cell, Cell): Logs.show_log("Given cell is invalid!") return [] @@ -440,6 +441,8 @@ def get_shortest_path_to_cell(self, from_player_id: int = None, from_player: Pla if row is None or col is None: return None cell = self._map.get_cell(row, col) + else: + cell = self._map.get_cell(cell.row, cell.col) shortest_path_from_player = World._shortest_path.get(from_player_id, None) if shortest_path_from_player is None: return None