Skip to content

Commit 184b6ac

Browse files
committed
fix enums
1 parent 9f36168 commit 184b6ac

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Model.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __str__(self):
9797
class HeroConstants:
9898
def __init__(self, hero_name, ability_names, max_hp, move_ap_cost, respawn_time):
9999
self.hero_name = hero_name
100-
self.ability_names = self._get_ability_name_enum(ability_names)
100+
self.ability_names = ability_names
101101
self.max_hp = max_hp
102102
self.move_ap_cost = move_ap_cost
103103
self.respawn_time = respawn_time
@@ -302,7 +302,7 @@ def _handle_pick_message(self, msg):
302302
self.current_turn = msg["currentTurn"]
303303
for hero in my_heroes:
304304
for first_hero in self.heroes:
305-
if hero["type"] == first_hero.name:
305+
if HeroName[hero["type"]] == first_hero.name:
306306
my_hero = copy.copy(first_hero)
307307
my_hero.id = hero["id"]
308308
my_hero.update_abilities([Ability(self._get_ability_constants(ability_name), 0)
@@ -321,7 +321,7 @@ def _handle_turn_message(self, msg):
321321
msg = msg['args'][0]
322322
self.my_score = msg["myScore"]
323323
self.opp_score = msg["oppScore"]
324-
self.current_phase = self._get_phase(msg["currentPhase"])
324+
self.current_phase = Phase[msg["currentPhase"]]
325325
self.ap = msg["AP"]
326326
self.current_turn = msg["currentTurn"]
327327
self._update_map(msg["map"])
@@ -347,21 +347,21 @@ def _handle_cast_ability(self, cast_abilities, my_or_opp):
347347
self.map.get_cell(
348348
cast_ability["endCell"]["row"] if "endCell" in cast_ability else -1,
349349
cast_ability["endCell"]["column"] if "endCell" in cast_ability else -1),
350-
cast_ability["abilityName"]))
350+
AbilityName[cast_ability["abilityName"]]))
351351
if my_or_opp == "my":
352352
self.my_cast_abilities = cast_list
353353
elif my_or_opp == "opp":
354354
self.opp_cast_abilities = cast_list
355355

356356
def _get_ability_constants(self, name):
357357
for constant in self.ability_constants:
358-
if name is AbilityName and name.value == constant.name or constant.name == name:
358+
if name == constant.name:
359359
return constant
360360

361361
def _update_heroes(self, heroes_list, main_hero_list):
362362
import copy
363363
for new_hero in heroes_list:
364-
hero_name = new_hero["type"]
364+
hero_name = HeroName[new_hero["type"]]
365365
hero = copy.copy(self._get_hero(hero_name))
366366
hero.id = new_hero["id"]
367367
hero.current_hp = new_hero["currentHP"]
@@ -371,8 +371,8 @@ def _update_heroes(self, heroes_list, main_hero_list):
371371
hero.offensive_abilities = []
372372
hero.defensive_abilities = []
373373
if cooldowns is not None:
374-
hero.abilities += [Ability(self._get_ability_constants(cooldown["name"]), cooldown["remCooldown"])
375-
for cooldown in cooldowns]
374+
hero.abilities += [Ability(self._get_ability_constants(AbilityName[cooldown["name"]]),
375+
cooldown["remCooldown"]) for cooldown in cooldowns]
376376
else:
377377
hero.abilities += [Ability(self._get_ability_constants(ability_name), -1)
378378
for ability_name in hero.ability_names]
@@ -406,7 +406,7 @@ def _ability_constants_init(self, ability_list):
406406

407407
abilities = []
408408
for dic in ability_list:
409-
ability_constant = AbilityConstants(dic["name"], self._get_ability_type(dic["type"]), dic["range"],
409+
ability_constant = AbilityConstants(AbilityName[dic["name"]], AbilityType[dic["type"]], dic["range"],
410410
dic["APCost"], dic["cooldown"], dic["areaOfEffect"], dic["power"],
411411
dic["isLobbing"])
412412
abilities.append(ability_constant)
@@ -427,8 +427,8 @@ def _hero_init(self, heroes_list):
427427
for step, h in enumerate(heroes_list):
428428
names = []
429429
for name in h["abilityNames"]:
430-
names.append(name)
431-
constant = HeroConstants(h["name"], names, h["maxHP"], h["moveAPCost"], h["respawnTime"])
430+
names.append(AbilityName[name])
431+
constant = HeroConstants(HeroName[h["name"]], names, h["maxHP"], h["moveAPCost"], h["respawnTime"])
432432
heroes.append(Hero(0, constant, []))
433433
constants.append(constant)
434434
self.heroes = heroes
@@ -794,7 +794,7 @@ def cast_ability(self, hero_id=None, hero=None, ability_name=None, ability=None,
794794
if ability_name is not None:
795795
args += [ability_name.value]
796796
elif ability is not None:
797-
args += [ability.name]
797+
args += [ability.name.value]
798798

799799
if cell is not None:
800800
args += [cell.row, cell.column]

0 commit comments

Comments
 (0)