Opt: Re-arrange interval for faster combat support switch

This commit is contained in:
LmeSzinc 2024-05-13 16:33:56 +08:00
parent f45c8a4dd6
commit ccf357703e
2 changed files with 42 additions and 39 deletions

View File

@ -82,14 +82,11 @@ class Combat(CombatInteract, CombatPrepare, CombatState, CombatTeam, CombatSuppo
logger.hr('Combat prepare')
skip_first_screenshot = True
if support_character:
# To set team before support set
pre_set_team = True
# Block COMBAT_TEAM_PREPARE before support set
support_set = False
else:
pre_set_team = False
support_set = True
logger.info([support_character, pre_set_team, support_set])
logger.info([support_character, support_set])
trial = 0
while 1:
if skip_first_screenshot:
@ -108,10 +105,7 @@ class Combat(CombatInteract, CombatPrepare, CombatState, CombatTeam, CombatSuppo
# Click
if support_character and self.appear(COMBAT_TEAM_SUPPORT, interval=2):
if pre_set_team:
self.team_set(team)
pre_set_team = False
continue
self.support_set(support_character)
self.interval_reset(COMBAT_TEAM_SUPPORT)
support_set = True

View File

@ -130,6 +130,7 @@ class CombatSupport(UI):
out: COMBAT_PREPARE
"""
logger.hr("Combat support")
self.interval_clear(COMBAT_TEAM_SUPPORT)
skip_first_screenshot = True
selected_support = False
while 1:
@ -143,7 +144,7 @@ class CombatSupport(UI):
return True
# Click
if self.appear(COMBAT_TEAM_SUPPORT, interval=1):
if self.appear(COMBAT_TEAM_SUPPORT, interval=2):
self.device.click(COMBAT_TEAM_SUPPORT)
self.interval_reset(COMBAT_TEAM_SUPPORT)
continue
@ -154,15 +155,30 @@ class CombatSupport(UI):
self._select_next_support()
self.interval_reset(POPUP_CANCEL)
continue
if self.appear(COMBAT_SUPPORT_LIST, interval=1):
if self.appear(COMBAT_SUPPORT_LIST, interval=2):
scroll = AdaptiveScroll(area=COMBAT_SUPPORT_LIST_SCROLL.area,
name=COMBAT_SUPPORT_LIST_SCROLL.name)
if not scroll.appear(main=self):
self.interval_clear(COMBAT_SUPPORT_LIST)
continue
if not selected_support and support_character_name != "FirstCharacter":
self._search_support(
support_character_name) # Search support
self._search_support(support_character_name) # Search support
selected_support = True
self.device.click(COMBAT_SUPPORT_ADD)
self.interval_reset(COMBAT_SUPPORT_LIST)
continue
def _get_character(self, support_character_name: str) -> SupportCharacter:
if support_character_name.startswith("Trailblazer"):
character = SupportCharacter(f"Stelle{support_character_name[11:]}", self.device.image)
if character:
return character
character = SupportCharacter(f"Caelum{support_character_name[11:]}", self.device.image)
# Should return something
return character
else:
return SupportCharacter(support_character_name, self.device.image)
def _search_support(self, support_character_name: str = "JingYuan"):
"""
Args:
@ -187,21 +203,14 @@ class CombatSupport(UI):
scroll.set_top(main=self)
logger.info("Searching support")
skip_first_screenshot = False
skip_first_screenshot = True
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if not support_character_name.startswith("Trailblazer"):
character = SupportCharacter(
support_character_name, self.device.image)
else:
character = SupportCharacter(f"Stelle{support_character_name[11:]}",
self.device.image) or SupportCharacter(
f"Caelum{support_character_name[11:]}", self.device.image)
character = self._get_character(support_character_name)
if character:
logger.info("Support found")
if self._select_support(character):