Skip to content

Commit

Permalink
get king by id added
Browse files Browse the repository at this point in the history
  • Loading branch information
erfanfi79 committed Feb 14, 2020
1 parent ea7d650 commit 8d8dc8a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions world.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, world=None, queue=None):
self.player_friend = None
self.player_first_enemy = None
self.player_second_enemy = None
self.spells = None
self.spells = []
self.cast_spells = []

if world is not None:
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_id(spell_id)
spell = self.get_spell_by_type_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_id(spell_id)
spell = self.get_spell_by_type_id(spell_id)
return spell

def upgrade_unit_range(self, unit=None, unit_id=None):
Expand Down Expand Up @@ -546,10 +546,10 @@ def get_all_base_unit(self):
def get_all_spells(self):
return copy.deepcopy(self.spells)

def get_spell_by_id(self, spell_id):
for i in self.spells:
if spell_id == i.type_id:
return i
def get_king_by_id(self, player_id):
for p in self.players:
if p.player_id == player_id:
return p.king

return None

Expand Down

0 comments on commit 8d8dc8a

Please sign in to comment.