From 11d2b9bab34279c8f7526889a72aa2a10129439c Mon Sep 17 00:00:00 2001 From: taslimisina Date: Sat, 15 Feb 2020 00:02:45 +0330 Subject: [PATCH] Fix get_spell_by_id name --- AI.py | 2 +- world.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AI.py b/AI.py index edc757a..73afb5c 100644 --- a/AI.py +++ b/AI.py @@ -14,7 +14,7 @@ def pick(self, world): print("pick started!") # preprocess - map = world.map + map = world.get_map() self.rows = map.row_num self.cols = map.column_num diff --git a/world.py b/world.py index 0801fcc..c079e15 100644 --- a/world.py +++ b/world.py @@ -60,7 +60,7 @@ def get_player_by_id(self, player_id): return player return None - def get_spell_by_type_id(self, type_id): + def get_spell_by_id(self, type_id): for spell in self.spells: if spell.type_id == type_id: return spell @@ -236,7 +236,7 @@ def _handle_turn_units(self, msg, is_dead_unit=False): def _handle_turn_cast_spells(self, msg): self.cast_spells = [] for cast_spell_msg in msg: - spell = self.get_spell_by_type_id(cast_spell_msg["typeId"]) + spell = self.get_spell_by_id(cast_spell_msg["typeId"]) cell = self.map.get_cell(cast_spell_msg["cell"]["row"], cast_spell_msg["cell"]["col"]) affected_units = [self.get_unit_by_id(affected_unit_id) for affected_unit_id in @@ -278,8 +278,8 @@ def _handle_turn_message(self, msg): available_range_upgrades=msg["availableRangeUpgrades"], available_damage_upgrades=msg["availableDamageUpgrades"]) - self.player.set_spells([self.get_spell_by_id(spell_id=spell_id) for spell_id in msg["mySpells"]]) - self.player_friend.set_spells([self.get_spell_by_id(spell_id=spell_id) for spell_id in msg["friendSpells"]]) + 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"] self.start_time = self.get_current_time_millis() @@ -407,7 +407,7 @@ def cast_unit_spell(self, unit=None, unit_id=None, path=None, path_id=None, cell if spell is None and spell_id is None: return None if spell is None: - spell = self.get_spell_by_type_id(spell_id) + spell = self.get_spell_by_id(spell_id) if row is not None and col is not None: cell = Cell(row, col) if unit is not None: @@ -429,7 +429,7 @@ def cast_unit_spell(self, unit=None, unit_id=None, path=None, path_id=None, cell # cast spell in the cell 'center' def cast_area_spell(self, center=None, row=None, col=None, spell=None, spell_id=None): if spell is None: - spell = self.get_spell_by_type_id(spell_id) + spell = self.get_spell_by_id(spell_id) if row is not None and col is not None: center = self.map.get_cell(row, col) @@ -503,13 +503,13 @@ def get_damage_upgrade_number(self): # returns the spell given in that turn def get_received_spell(self): spell_id = self.turn_updates.received_spell - spell = self.get_spell_by_type_id(spell_id) + spell = self.get_spell_by_id(spell_id) return spell # returns the spell given in that turn to friend def get_friend_received_spell(self): spell_id = self.turn_updates.friend_received_spell - spell = self.get_spell_by_type_id(spell_id) + spell = self.get_spell_by_id(spell_id) return spell def upgrade_unit_range(self, unit=None, unit_id=None):