Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
HamidrezaKmK committed Mar 7, 2020
2 parents 2bf8185 + fa842e5 commit 8bb1d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 0 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import copy
from enum import Enum

from typing import *


Expand Down
25 changes: 14 additions & 11 deletions world.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 []
Expand All @@ -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 []
Expand All @@ -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
Expand Down

0 comments on commit 8bb1d60

Please sign in to comment.