2023-07-10 14:23:11 +00:00
|
|
|
from module.base.decorator import run_once
|
2024-01-17 10:08:17 +00:00
|
|
|
from module.exception import RequestHumanTakeover
|
2023-06-16 19:15:26 +00:00
|
|
|
from module.logger import logger
|
|
|
|
from tasks.combat.assets.assets_combat_finish import COMBAT_AGAIN, COMBAT_EXIT
|
2024-06-10 08:11:19 +00:00
|
|
|
from tasks.combat.assets.assets_combat_interact import DUNGEON_COMBAT_INTERACT
|
2023-06-16 19:15:26 +00:00
|
|
|
from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE
|
2023-08-27 09:13:05 +00:00
|
|
|
from tasks.combat.assets.assets_combat_team import COMBAT_TEAM_PREPARE, COMBAT_TEAM_SUPPORT
|
2024-06-27 22:29:39 +00:00
|
|
|
from tasks.combat.fuel import Fuel
|
2023-06-16 19:15:26 +00:00
|
|
|
from tasks.combat.interact import CombatInteract
|
2024-05-17 18:35:44 +00:00
|
|
|
from tasks.combat.obtain import CombatObtain
|
2023-06-16 19:15:26 +00:00
|
|
|
from tasks.combat.prepare import CombatPrepare
|
2023-09-23 18:08:36 +00:00
|
|
|
from tasks.combat.skill import CombatSkill
|
2023-06-16 19:15:26 +00:00
|
|
|
from tasks.combat.state import CombatState
|
2023-07-24 10:15:22 +00:00
|
|
|
from tasks.combat.support import CombatSupport
|
2023-08-27 09:13:05 +00:00
|
|
|
from tasks.combat.team import CombatTeam
|
2024-05-17 18:35:44 +00:00
|
|
|
from tasks.dungeon.keywords import DungeonList
|
2023-06-27 18:26:32 +00:00
|
|
|
from tasks.map.control.joystick import MapControlJoystick
|
2023-06-16 19:15:26 +00:00
|
|
|
|
|
|
|
|
2024-05-17 18:35:44 +00:00
|
|
|
class Combat(CombatInteract, CombatPrepare, CombatState, CombatTeam, CombatSupport, CombatSkill, CombatObtain,
|
2024-06-27 22:29:39 +00:00
|
|
|
MapControlJoystick, Fuel):
|
2024-05-17 18:35:44 +00:00
|
|
|
dungeon: DungeonList | None = None
|
2024-05-30 13:16:36 +00:00
|
|
|
is_doing_planner: bool = False
|
2024-05-17 18:35:44 +00:00
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
def handle_combat_prepare(self):
|
|
|
|
"""
|
2023-07-10 14:23:11 +00:00
|
|
|
Returns:
|
|
|
|
bool: If able to run a combat
|
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
Pages:
|
|
|
|
in: COMBAT_PREPARE
|
|
|
|
"""
|
2023-07-10 14:23:11 +00:00
|
|
|
self.combat_waves = 1
|
2023-06-27 15:52:41 +00:00
|
|
|
cost = self.combat_get_wave_cost()
|
2024-08-27 03:53:34 +00:00
|
|
|
current = self.combat_get_trailblaze_power()
|
|
|
|
if current < self.combat_wave_cost:
|
2024-08-26 14:33:06 +00:00
|
|
|
if self._try_get_more_trablaize_power(self.combat_wave_cost):
|
|
|
|
current = self.config.stored.TrailblazePower.value
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
2023-06-27 15:52:41 +00:00
|
|
|
if cost == 10:
|
2023-07-10 14:23:11 +00:00
|
|
|
# Calyx
|
|
|
|
self.combat_waves = min(current // self.combat_wave_cost, 6)
|
|
|
|
if self.combat_wave_limit:
|
|
|
|
self.combat_waves = min(self.combat_waves, self.combat_wave_limit - self.combat_wave_done)
|
|
|
|
logger.info(
|
|
|
|
f'Current has {current}, combat costs {self.combat_wave_cost}, '
|
|
|
|
f'wave={self.combat_wave_done}/{self.combat_wave_limit}, '
|
|
|
|
f'able to do {self.combat_waves} waves')
|
|
|
|
else:
|
|
|
|
logger.info(f'Current has {current}, combat costs {self.combat_wave_cost}, '
|
|
|
|
f'able to do {self.combat_waves} waves')
|
|
|
|
if self.combat_waves > 0:
|
|
|
|
self.combat_set_wave(self.combat_waves)
|
2023-06-16 19:15:26 +00:00
|
|
|
else:
|
2023-07-10 14:23:11 +00:00
|
|
|
# Others
|
|
|
|
logger.info(f'Current has {current}, combat costs {self.combat_wave_cost}, '
|
|
|
|
f'do {self.combat_waves} wave')
|
|
|
|
|
|
|
|
# Check limits
|
2023-08-27 16:41:49 +00:00
|
|
|
if self.config.stored.TrailblazePower.value < self.combat_wave_cost:
|
2024-08-27 03:53:34 +00:00
|
|
|
return self._try_get_more_trablaize_power(self.combat_wave_cost)
|
2023-07-10 14:23:11 +00:00
|
|
|
if self.combat_waves <= 0:
|
|
|
|
logger.info('Combat wave limited, cannot continue combat')
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
2023-06-16 19:15:26 +00:00
|
|
|
|
2023-06-27 18:26:32 +00:00
|
|
|
def handle_ascension_dungeon_prepare(self):
|
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
bool: If clicked.
|
|
|
|
"""
|
2023-06-28 14:55:19 +00:00
|
|
|
if self.combat_wave_cost == 30 and self.is_in_main():
|
2023-06-27 18:26:32 +00:00
|
|
|
if self.handle_map_A():
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
2023-07-24 10:15:22 +00:00
|
|
|
def combat_prepare(self, team=1, support_character: str = None):
|
2023-06-16 19:15:26 +00:00
|
|
|
"""
|
2023-06-17 08:20:01 +00:00
|
|
|
Args:
|
|
|
|
team: 1 to 6.
|
2023-07-24 10:15:22 +00:00
|
|
|
support_character: Support character name
|
2023-08-27 09:13:05 +00:00
|
|
|
|
2023-06-17 08:20:01 +00:00
|
|
|
Returns:
|
|
|
|
bool: True if success to enter combat
|
|
|
|
False if trialblaze power is not enough
|
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
Pages:
|
|
|
|
in: COMBAT_PREPARE
|
|
|
|
out: is_combat_executing
|
|
|
|
"""
|
|
|
|
logger.hr('Combat prepare')
|
|
|
|
skip_first_screenshot = True
|
2024-03-27 15:13:14 +00:00
|
|
|
if support_character:
|
|
|
|
# Block COMBAT_TEAM_PREPARE before support set
|
|
|
|
support_set = False
|
|
|
|
else:
|
|
|
|
support_set = True
|
2024-05-13 08:33:56 +00:00
|
|
|
logger.info([support_character, support_set])
|
2024-01-17 10:08:17 +00:00
|
|
|
trial = 0
|
2023-06-16 19:15:26 +00:00
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
|
|
|
if self.is_combat_executing():
|
2023-06-17 08:20:01 +00:00
|
|
|
return True
|
2024-01-17 10:08:17 +00:00
|
|
|
# Relics full
|
|
|
|
# Clicking between COMBAT_PREPARE and COMBAT_TEAM_PREPARE
|
|
|
|
if trial > 3:
|
|
|
|
logger.critical('Failed to enter dungeon after 3 trial, probably because relics are full')
|
|
|
|
raise RequestHumanTakeover
|
2023-06-16 19:15:26 +00:00
|
|
|
|
|
|
|
# Click
|
2024-05-13 04:40:44 +00:00
|
|
|
if support_character and self.appear(COMBAT_TEAM_SUPPORT, interval=2):
|
2024-05-13 08:33:56 +00:00
|
|
|
self.team_set(team)
|
2023-07-24 10:15:22 +00:00
|
|
|
self.support_set(support_character)
|
2024-05-13 04:40:44 +00:00
|
|
|
self.interval_reset(COMBAT_TEAM_SUPPORT)
|
2024-03-27 15:13:14 +00:00
|
|
|
support_set = True
|
2023-07-24 10:15:22 +00:00
|
|
|
continue
|
2024-03-27 15:13:14 +00:00
|
|
|
if support_set and self.appear(COMBAT_TEAM_PREPARE, interval=2):
|
2023-06-20 14:07:08 +00:00
|
|
|
self.team_set(team)
|
|
|
|
self.device.click(COMBAT_TEAM_PREPARE)
|
|
|
|
self.interval_reset(COMBAT_TEAM_PREPARE)
|
2024-05-13 04:40:44 +00:00
|
|
|
self.interval_reset(COMBAT_TEAM_SUPPORT)
|
2023-06-20 14:07:08 +00:00
|
|
|
continue
|
|
|
|
if self.appear(COMBAT_TEAM_PREPARE):
|
|
|
|
self.interval_reset(COMBAT_PREPARE)
|
2023-09-19 17:20:52 +00:00
|
|
|
self.map_A_timer.reset()
|
2023-06-16 19:15:26 +00:00
|
|
|
if self.appear(COMBAT_PREPARE, interval=2):
|
2024-06-10 08:00:09 +00:00
|
|
|
if self.is_doing_planner and self.obtained_is_full(self.dungeon, wave_done=self.combat_wave_done):
|
2024-05-19 09:17:30 +00:00
|
|
|
# Update stamina so task can be delayed if both obtained_is_full and stamina exhausted
|
|
|
|
self.combat_get_trailblaze_power()
|
|
|
|
return False
|
2023-07-10 14:23:11 +00:00
|
|
|
if not self.handle_combat_prepare():
|
2023-06-17 08:20:01 +00:00
|
|
|
return False
|
2024-07-15 13:47:59 +00:00
|
|
|
if self.is_doing_planner and self.combat_wave_cost == 0:
|
|
|
|
logger.info('Free combat gets nothing cannot meet planner needs')
|
|
|
|
return False
|
2023-06-16 19:15:26 +00:00
|
|
|
self.device.click(COMBAT_PREPARE)
|
|
|
|
self.interval_reset(COMBAT_PREPARE)
|
2024-01-17 10:08:17 +00:00
|
|
|
trial += 1
|
2023-06-16 19:15:26 +00:00
|
|
|
continue
|
2024-06-10 08:11:19 +00:00
|
|
|
if self.appear(DUNGEON_COMBAT_INTERACT):
|
|
|
|
if self.handle_combat_interact():
|
|
|
|
self.map_A_timer.reset()
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
if self.handle_ascension_dungeon_prepare():
|
|
|
|
continue
|
2023-09-26 19:14:12 +00:00
|
|
|
if self.handle_popup_confirm():
|
|
|
|
continue
|
2023-06-16 19:15:26 +00:00
|
|
|
|
2023-09-23 11:20:53 +00:00
|
|
|
def combat_execute(self, expected_end=None):
|
2023-06-16 19:15:26 +00:00
|
|
|
"""
|
2023-09-23 11:20:53 +00:00
|
|
|
Args:
|
|
|
|
expected_end: A function returns bool, True represents end.
|
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
Pages:
|
|
|
|
in: is_combat_executing
|
|
|
|
out: COMBAT_AGAIN
|
|
|
|
"""
|
|
|
|
logger.hr('Combat execute')
|
|
|
|
skip_first_screenshot = True
|
|
|
|
is_executing = True
|
|
|
|
self.combat_state_reset()
|
2024-08-10 14:36:33 +00:00
|
|
|
self.device.stuck_record_clear()
|
|
|
|
self.device.click_record_clear()
|
2024-07-01 15:36:36 +00:00
|
|
|
self.device.screenshot_interval_set('combat')
|
2023-06-16 19:15:26 +00:00
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
2023-09-23 11:20:53 +00:00
|
|
|
if callable(expected_end) and expected_end():
|
|
|
|
logger.info(f'Combat execute ended at {expected_end.__name__}')
|
|
|
|
break
|
2024-05-13 06:59:48 +00:00
|
|
|
if (self.appear(COMBAT_AGAIN) and
|
|
|
|
self.image_color_count(COMBAT_AGAIN, color=(227, 227, 228), threshold=221, count=50)):
|
2023-09-21 16:23:00 +00:00
|
|
|
logger.info(f'Combat execute ended at {COMBAT_AGAIN}')
|
|
|
|
break
|
|
|
|
if self.is_in_main():
|
|
|
|
logger.info(f'Combat execute ended at page_main')
|
2023-06-16 19:15:26 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
# Daemon
|
|
|
|
if self.is_combat_executing():
|
|
|
|
if not is_executing:
|
|
|
|
logger.info('Combat continues')
|
|
|
|
self.device.stuck_record_clear()
|
|
|
|
is_executing = True
|
|
|
|
else:
|
|
|
|
is_executing = False
|
|
|
|
if self.handle_combat_state():
|
|
|
|
continue
|
2024-05-13 07:48:25 +00:00
|
|
|
# Battle pass popup appears just after combat finished and before blessings
|
|
|
|
if self.handle_battle_pass_notification():
|
|
|
|
continue
|
2023-06-16 19:15:26 +00:00
|
|
|
|
2024-08-10 14:36:33 +00:00
|
|
|
self.device.stuck_record_clear()
|
|
|
|
self.device.click_record_clear()
|
2024-07-01 15:36:36 +00:00
|
|
|
self.device.screenshot_interval_set()
|
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
def _combat_can_again(self) -> bool:
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: COMBAT_AGAIN
|
|
|
|
"""
|
2023-09-26 19:14:12 +00:00
|
|
|
current = self.combat_get_trailblaze_power(expect_reduce=self.combat_wave_cost > 0)
|
2024-05-19 09:17:30 +00:00
|
|
|
# Planner
|
|
|
|
logger.attr('obtain_frequent_check', self.obtain_frequent_check)
|
|
|
|
if self.obtain_frequent_check:
|
|
|
|
logger.info('Exit combat to check obtained items')
|
|
|
|
return False
|
2023-07-10 14:23:11 +00:00
|
|
|
# Wave limit
|
|
|
|
if self.combat_wave_limit:
|
|
|
|
if self.combat_wave_done + self.combat_waves > self.combat_wave_limit:
|
|
|
|
logger.info(f'Combat wave limit: {self.combat_wave_done}/{self.combat_wave_limit}, '
|
|
|
|
f'can not run again')
|
|
|
|
return False
|
|
|
|
# Cost limit
|
2023-06-27 15:52:41 +00:00
|
|
|
if self.combat_wave_cost == 10:
|
2023-07-10 14:23:11 +00:00
|
|
|
if current >= self.combat_wave_cost * self.combat_waves:
|
2023-06-27 15:52:41 +00:00
|
|
|
logger.info(f'Current has {current}, combat costs {self.combat_wave_cost}, can run again')
|
2023-06-16 19:15:26 +00:00
|
|
|
return True
|
|
|
|
else:
|
2024-08-10 18:27:40 +00:00
|
|
|
return self._try_get_more_trablaize_power(self.combat_wave_cost * self.combat_waves)
|
2023-09-26 19:14:12 +00:00
|
|
|
elif self.combat_wave_cost <= 0:
|
|
|
|
logger.info(f'Free combat, combat costs {self.combat_wave_cost}, can not run again')
|
|
|
|
return False
|
2023-06-16 19:15:26 +00:00
|
|
|
else:
|
2023-06-27 15:52:41 +00:00
|
|
|
if current >= self.combat_wave_cost:
|
|
|
|
logger.info(f'Current has {current}, combat costs {self.combat_wave_cost}, can run again')
|
|
|
|
return True
|
|
|
|
else:
|
2024-08-10 18:27:40 +00:00
|
|
|
return self._try_get_more_trablaize_power(self.combat_wave_cost * self.combat_waves)
|
2024-07-11 09:06:17 +00:00
|
|
|
|
2024-08-10 18:27:40 +00:00
|
|
|
def _try_get_more_trablaize_power(self, cost):
|
|
|
|
self.extract_stamina(
|
|
|
|
update=False,
|
|
|
|
use_reserved=self.config.TrailblazePower_ExtractReservedTrailblazePower,
|
|
|
|
use_fuel=self.config.TrailblazePower_UseFuel
|
|
|
|
)
|
|
|
|
current = self.config.stored.TrailblazePower.value
|
2024-07-11 09:06:17 +00:00
|
|
|
if current >= cost:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
logger.info(f'Current has {current}, combat costs {self.combat_wave_cost}, can not run again')
|
|
|
|
return False
|
2023-06-16 19:15:26 +00:00
|
|
|
|
2023-07-10 14:23:11 +00:00
|
|
|
def _combat_should_reenter(self):
|
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
bool: True to re-enter combat and run with another wave settings
|
|
|
|
"""
|
2024-05-19 09:17:30 +00:00
|
|
|
# Planner
|
|
|
|
logger.attr('obtain_frequent_check', self.obtain_frequent_check)
|
|
|
|
if self.obtain_frequent_check:
|
2024-05-19 20:28:38 +00:00
|
|
|
if self.config.stored.TrailblazePower.value >= self.combat_wave_cost \
|
|
|
|
and (self.combat_wave_limit and self.combat_wave_done < self.combat_wave_limit):
|
|
|
|
logger.info(f'Stall having some trailblaze power '
|
|
|
|
f'but wave limit reached {self.combat_wave_done}/{self.combat_wave_limit}, '
|
|
|
|
f'ignore obtain_frequent_check cause will reenter later')
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
logger.info('Re-enter combat to check obtained items')
|
|
|
|
return True
|
2024-05-19 09:17:30 +00:00
|
|
|
# Stamina
|
2024-05-13 07:02:56 +00:00
|
|
|
if self.config.stored.TrailblazePower.value < self.combat_wave_cost:
|
2024-05-30 13:16:36 +00:00
|
|
|
if self.is_doing_planner:
|
|
|
|
logger.info('Current trailblaze power is not enough for next run, '
|
|
|
|
're-enter combat to check obtained items')
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
logger.info('Current trailblaze power is not enough for next run')
|
|
|
|
return False
|
2023-07-10 14:23:11 +00:00
|
|
|
# Wave limit
|
|
|
|
if self.combat_wave_limit:
|
|
|
|
if self.combat_wave_done < self.combat_wave_limit:
|
|
|
|
logger.info(f'Combat wave limit: {self.combat_wave_done}/{self.combat_wave_limit}, '
|
|
|
|
f'run again with less waves')
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
# Cost limit
|
2023-08-27 16:41:49 +00:00
|
|
|
if self.config.stored.TrailblazePower.value >= self.combat_wave_cost:
|
2023-07-10 14:23:11 +00:00
|
|
|
logger.info('Still having some trailblaze power run with less waves to empty it')
|
|
|
|
return True
|
2024-05-13 07:02:56 +00:00
|
|
|
return False
|
2023-07-10 14:23:11 +00:00
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
def combat_finish(self) -> bool:
|
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
bool: True if exit, False if again
|
|
|
|
|
|
|
|
Pages:
|
|
|
|
in: COMBAT_AGAIN
|
|
|
|
out: page_main if exit
|
|
|
|
is_combat_executing if again
|
|
|
|
"""
|
|
|
|
logger.hr('Combat finish')
|
2023-07-10 14:23:11 +00:00
|
|
|
|
|
|
|
@run_once
|
|
|
|
def add_wave_done():
|
|
|
|
self.combat_wave_done += self.combat_waves
|
|
|
|
logger.info(f'Done {self.combat_waves} waves at total')
|
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
skip_first_screenshot = True
|
2023-12-18 15:57:33 +00:00
|
|
|
combat_can_again = None
|
2023-06-16 19:15:26 +00:00
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
2023-06-27 18:26:32 +00:00
|
|
|
if self.is_in_main():
|
2023-06-16 19:15:26 +00:00
|
|
|
logger.info('Combat finishes at page_main')
|
|
|
|
return True
|
2024-09-10 16:19:11 +00:00
|
|
|
if self.appear(COMBAT_PREPARE):
|
|
|
|
logger.info('Combat finishes at COMBAT_PREPARE')
|
|
|
|
return True
|
2023-06-16 19:15:26 +00:00
|
|
|
if self.is_combat_executing():
|
|
|
|
logger.info('Combat finishes at another combat')
|
|
|
|
return False
|
|
|
|
|
|
|
|
# Click
|
2023-07-05 16:37:21 +00:00
|
|
|
# Game client might slow to response COMBAT_AGAIN clicks
|
|
|
|
if self.appear(COMBAT_AGAIN, interval=5):
|
2023-07-10 14:23:11 +00:00
|
|
|
add_wave_done()
|
2024-05-30 12:26:45 +00:00
|
|
|
# Update obtain_frequent_check
|
2024-06-10 08:00:09 +00:00
|
|
|
if self.is_doing_planner:
|
|
|
|
self.obtained_is_full(dungeon=self.dungeon, wave_done=self.combat_wave_done, obtain_get=False)
|
2023-12-18 15:57:33 +00:00
|
|
|
# Cache the result of _combat_can_again() as no expected stamina reduce during retry
|
|
|
|
if combat_can_again is None:
|
|
|
|
combat_can_again = self._combat_can_again()
|
|
|
|
if combat_can_again:
|
2023-06-16 19:15:26 +00:00
|
|
|
self.device.click(COMBAT_AGAIN)
|
|
|
|
else:
|
|
|
|
self.device.click(COMBAT_EXIT)
|
|
|
|
self.interval_reset(COMBAT_AGAIN)
|
2023-12-25 12:34:44 +00:00
|
|
|
continue
|
2024-02-23 16:44:56 +00:00
|
|
|
# Dropped light cone from weekly
|
2023-12-25 12:34:44 +00:00
|
|
|
if self.handle_get_light_cone():
|
|
|
|
continue
|
2024-02-23 16:44:56 +00:00
|
|
|
# Having any character died
|
|
|
|
if self.handle_popup_confirm():
|
|
|
|
continue
|
2023-06-16 19:15:26 +00:00
|
|
|
|
2023-06-17 08:20:01 +00:00
|
|
|
def combat_exit(self, skip_first_screenshot=True):
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: Any page during combat
|
|
|
|
out: page_main
|
|
|
|
"""
|
|
|
|
logger.info('Combat exit')
|
|
|
|
self.interval_clear([COMBAT_PREPARE, COMBAT_TEAM_PREPARE, COMBAT_AGAIN])
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
2023-06-27 18:26:32 +00:00
|
|
|
if self.is_in_main():
|
2023-06-17 08:20:01 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
# Click
|
2023-10-18 04:00:48 +00:00
|
|
|
if self.handle_ui_close(COMBAT_PREPARE, interval=2):
|
2023-06-17 08:20:01 +00:00
|
|
|
continue
|
2023-10-18 04:00:48 +00:00
|
|
|
if self.handle_ui_close(COMBAT_TEAM_PREPARE, interval=2):
|
2023-06-17 08:20:01 +00:00
|
|
|
continue
|
|
|
|
if self.appear(COMBAT_AGAIN, interval=2):
|
|
|
|
logger.info(f'{COMBAT_AGAIN} -> {COMBAT_EXIT}')
|
|
|
|
self.device.click(COMBAT_EXIT)
|
|
|
|
continue
|
2023-11-02 03:39:15 +00:00
|
|
|
if self.handle_get_light_cone():
|
|
|
|
continue
|
2023-06-17 08:20:01 +00:00
|
|
|
|
2023-08-27 16:41:49 +00:00
|
|
|
def is_trailblaze_power_exhausted(self) -> bool:
|
|
|
|
flag = self.config.stored.TrailblazePower.value < self.combat_wave_cost
|
|
|
|
logger.attr('TrailblazePowerExhausted', flag)
|
2023-08-27 09:13:05 +00:00
|
|
|
return flag
|
|
|
|
|
|
|
|
def combat(self, team: int = 1, wave_limit: int = 0, support_character: str = None, skip_first_screenshot=True):
|
2023-06-16 19:15:26 +00:00
|
|
|
"""
|
|
|
|
Combat until trailblaze power runs out.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
team: 1 to 6.
|
2023-07-10 14:23:11 +00:00
|
|
|
wave_limit: Limit combat runs, 0 means no limit.
|
2023-07-24 10:15:22 +00:00
|
|
|
support_character: Support character name
|
2023-08-27 09:13:05 +00:00
|
|
|
skip_first_screenshot:
|
2023-06-16 19:15:26 +00:00
|
|
|
|
2023-07-10 15:36:35 +00:00
|
|
|
Returns:
|
2023-08-27 09:13:05 +00:00
|
|
|
int: Run count
|
2023-07-10 15:36:35 +00:00
|
|
|
|
2024-01-17 10:08:17 +00:00
|
|
|
Raises:
|
|
|
|
RequestHumanTakeover: If relics are full
|
|
|
|
|
2023-06-16 19:15:26 +00:00
|
|
|
Pages:
|
|
|
|
in: COMBAT_PREPARE
|
|
|
|
or page_main with DUNGEON_COMBAT_INTERACT
|
|
|
|
out: page_main
|
|
|
|
"""
|
|
|
|
if not skip_first_screenshot:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
2023-07-10 14:23:11 +00:00
|
|
|
self.combat_wave_limit = wave_limit
|
|
|
|
self.combat_wave_done = 0
|
2023-06-16 19:15:26 +00:00
|
|
|
while 1:
|
|
|
|
logger.hr('Combat', level=2)
|
2023-07-10 14:23:11 +00:00
|
|
|
logger.info(f'Combat, team={team}, wave={self.combat_wave_done}/{self.combat_wave_limit}')
|
2023-06-17 08:20:01 +00:00
|
|
|
# Prepare
|
2023-07-24 10:15:22 +00:00
|
|
|
prepare = self.combat_prepare(team, support_character)
|
2023-06-17 08:20:01 +00:00
|
|
|
if not prepare:
|
|
|
|
self.combat_exit()
|
|
|
|
break
|
|
|
|
# Execute
|
2023-06-16 19:15:26 +00:00
|
|
|
self.combat_execute()
|
2023-06-17 08:20:01 +00:00
|
|
|
# Finish
|
2023-06-16 19:15:26 +00:00
|
|
|
finish = self.combat_finish()
|
2023-07-10 14:23:11 +00:00
|
|
|
if self._combat_should_reenter():
|
2023-06-16 19:15:26 +00:00
|
|
|
continue
|
|
|
|
if finish:
|
2024-09-10 16:19:11 +00:00
|
|
|
self.combat_exit()
|
2023-06-16 19:15:26 +00:00
|
|
|
break
|
2024-07-01 18:52:09 +00:00
|
|
|
# Reset combat_wave_cost, so handle_combat_interact() won't activate before handle_combat_prepare()
|
|
|
|
self.combat_wave_cost = 10
|
2023-07-10 15:36:35 +00:00
|
|
|
|
2024-01-01 19:54:54 +00:00
|
|
|
logger.attr('combat_wave_done', self.combat_wave_done)
|
|
|
|
return self.combat_wave_done
|