Skip to content

Commit

Permalink
player.cast spell field fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HamidrezaKmK committed Mar 1, 2020
1 parent 708476c commit 76a007b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions world.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,24 @@ def _handle_turn_cast_spells(self, msg):
affected_unit_id in
cast_spell_msg["affectedUnits"]]
if spell.is_area_spell():
self._cast_spells.append(
CastAreaSpell(spell=spell, id=cast_spell_msg["id"],
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))
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():
self._cast_spells.append(
CastUnitSpell(spell=spell, id=cast_spell_msg["id"],
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))
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

def get_cast_spell_by_id(self, id: int) -> Optional["CastSpell"]:
for cast_spell in self._cast_spells:
Expand Down Expand Up @@ -333,6 +338,7 @@ 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

0 comments on commit 76a007b

Please sign in to comment.