Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
epic quests: continue battles even when cannot restart game
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarenko committed Oct 15, 2020
1 parent 2642ad3 commit fa5364e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions lib/game/battle_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class AutoBattleBot(BattleBot):

def fight(self):
"""Start battle and wait until the end."""
if self.is_battle_over():
logger.info("Battle is already over")
return

def wait_battle():
self.skip_cutscene()
return self.is_battle()
Expand Down
29 changes: 14 additions & 15 deletions lib/game/missions/epic_quests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,24 @@ def start_stage(self, stage_button, stage_num, farm_shifter_bios=False):
self.player.click_button(stage_button)
wait_until(self.player.is_ui_element_on_screen, timeout=3, ui_element=self.ui['START_BUTTON'])
if not self.press_start_button():
logger.error(f"Cannot start Epic Quest stage {stage_button}, exiting.")
logger.error(f"Cannot start Epic Quest stage {self.mode_name}, exiting.")
return 0
auto_battle_bot = AutoBattleBot(self.game, self.battle_over_conditions)
ally_appeared = auto_battle_bot.wait_until_shifter_appeared() if farm_shifter_bios else True
if ally_appeared:
auto_battle_bot.fight()
stage_num -= 1
logger.debug(f"{stage_num} stages left to complete")
self.close_mission_notifications()
if stage_num > 0:
self.press_repeat_button()
else:
self.press_home_button()
return stage_num
elif farm_shifter_bios and not ally_appeared:
if farm_shifter_bios and not ally_appeared:
logger.info("No ally, restarting")
if not self.game.restart_game(repeat_while=auto_battle_bot.is_battle):
return 0
self.game.select_mode(self.mode_name)
if self.game.restart_game(repeat_while=auto_battle_bot.is_battle):
self.game.select_mode(self.mode_name)
return stage_num

auto_battle_bot.fight()
stage_num -= 1
logger.debug(f"{stage_num} stages left to complete")
self.close_mission_notifications()
if stage_num > 0:
self.press_repeat_button()
else:
self.press_home_button()
return stage_num

def do_missions(self, times=None, farm_shifter_bios=False):
Expand Down

0 comments on commit fa5364e

Please sign in to comment.