Skip to content

Commit

Permalink
Fix get_spell_by_id name
Browse files Browse the repository at this point in the history
  • Loading branch information
taslimisina committed Feb 14, 2020
1 parent 8d8dc8a commit 11d2b9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions world.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 11d2b9b

Please sign in to comment.