diff options
Diffstat (limited to 'battle/summons.py')
-rw-r--r-- | battle/summons.py | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/battle/summons.py b/battle/summons.py index f3f4fd1..ef1b107 100644 --- a/battle/summons.py +++ b/battle/summons.py @@ -19,10 +19,10 @@ import json from utils import (compress, allsummons, stdout, dl_search, Player, Battle) -from consts import (ERR_ERR, ERR_BAD, ST_TOWN) +from consts import (ERR_ERR, ERR_BAD) from battle.skills import skill_core -from battle.common import check_enemy_alive, check_player_alive -from battle.main import advance_wave, battle_endturn, get_result +from battle.common import conditions +#from battle.main import advance_wave, battle_endturn, get_result def handle_summon(token, summon): global Battle, Player @@ -36,35 +36,12 @@ def handle_summon(token, summon): except: return ERR_ERR - # Check for victory/defeat conditions - # Huge code duplication - stdout("Summon: Victory/Defeat Check") - # HOLD THAT! Handle event - if (not check_enemy_alive(token)): - # You won! Do we have a next wave? - stdout("You won!") - if (Battle[token]["wave"] < Battle[token]["max_wave"]): - stdout("Next wave detected: %s, Quest ID: %s\nWave: %s" % (token, Battle[token]["quest_id"], Battle[token]["wave"])) - advance_wave(token, Battle[token]["world"], Battle[token]["quest_id"], Battle[token]["wave"]) - # Do not continue this loop: End the turn now - return battle_endturn(token, Battle[token]["spheres"]) - else: - # You won! - stdout("Total Victory") - Player[token]["status"]=ST_TOWN - # TODO: enemy die = add reward - result=get_result(token, True, Battle[token]["world"], Battle[token]["quest_id"]) - del Battle[token] - return compress(result) - - # It never harms checking for suicide... - if (not check_player_alive(token)): - # You lost! - Player[token]["status"]=ST_TOWN - result=get_result(token, False, Battle[token]["quest_id"]) - del Battle[token] - return compress(result) + + # HOLD THAT! Handle victory/defeat conditions + check = conditions(token, Battle[token]["spheres"]) + if check is not None: + return check # The check is: if not ERR_ERR or ERR_BAD, then reload battle/result sjson=compress(Battle[token]) |