Upd: Exercise HP daemon on new battle UI theme

Signed-off-by: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com>
This commit is contained in:
LmeSzinc 2024-09-25 13:08:10 +08:00
parent cf7b208a4f
commit 32f118f653
11 changed files with 23 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -5,8 +5,10 @@ from module.base.template import Template
# Don't modify it manually.
ATTACKER_HP_AREA = Button(area={'cn': (271, 43, 586, 58), 'en': (271, 43, 586, 58), 'jp': (271, 44, 586, 56), 'tw': (271, 43, 586, 58)}, color={'cn': (239, 51, 15), 'en': (239, 51, 15), 'jp': (244, 123, 106), 'tw': (239, 51, 15)}, button={'cn': (271, 43, 586, 58), 'en': (271, 43, 586, 58), 'jp': (271, 44, 586, 56), 'tw': (271, 43, 586, 58)}, file={'cn': './assets/cn/exercise/ATTACKER_HP_AREA.png', 'en': './assets/en/exercise/ATTACKER_HP_AREA.png', 'jp': './assets/jp/exercise/ATTACKER_HP_AREA.png', 'tw': './assets/tw/exercise/ATTACKER_HP_AREA.png'})
ATTACKER_HP_AREA_New = Button(area={'cn': (266, 40, 592, 49), 'en': (266, 40, 592, 49), 'jp': (266, 40, 592, 49), 'tw': (266, 40, 592, 49)}, color={'cn': (232, 82, 45), 'en': (232, 82, 45), 'jp': (232, 82, 45), 'tw': (232, 82, 45)}, button={'cn': (266, 40, 592, 49), 'en': (266, 40, 592, 49), 'jp': (266, 40, 592, 49), 'tw': (266, 40, 592, 49)}, file={'cn': './assets/cn/exercise/ATTACKER_HP_AREA_New.png', 'en': './assets/en/exercise/ATTACKER_HP_AREA_New.png', 'jp': './assets/jp/exercise/ATTACKER_HP_AREA_New.png', 'tw': './assets/tw/exercise/ATTACKER_HP_AREA_New.png'})
CLICK_SAFE_AREA = Button(area={'cn': (1215, 637, 1260, 686), 'en': (1215, 637, 1260, 686), 'jp': (1215, 637, 1260, 686), 'tw': (1215, 637, 1260, 686)}, color={'cn': (253, 180, 75), 'en': (253, 180, 75), 'jp': (253, 180, 75), 'tw': (253, 180, 75)}, button={'cn': (1215, 637, 1260, 686), 'en': (1215, 637, 1260, 686), 'jp': (1215, 637, 1260, 686), 'tw': (1215, 637, 1260, 686)}, file={'cn': './assets/cn/exercise/CLICK_SAFE_AREA.png', 'en': './assets/en/exercise/CLICK_SAFE_AREA.png', 'jp': './assets/jp/exercise/CLICK_SAFE_AREA.png', 'tw': './assets/tw/exercise/CLICK_SAFE_AREA.png'})
DEFENDER_HP_AREA = Button(area={'cn': (691, 43, 1004, 58), 'en': (691, 43, 1004, 58), 'jp': (691, 44, 1005, 56), 'tw': (691, 43, 1004, 58)}, color={'cn': (239, 51, 15), 'en': (239, 51, 15), 'jp': (244, 115, 98), 'tw': (239, 51, 15)}, button={'cn': (691, 43, 1004, 58), 'en': (691, 43, 1004, 58), 'jp': (691, 44, 1005, 56), 'tw': (691, 43, 1004, 58)}, file={'cn': './assets/cn/exercise/DEFENDER_HP_AREA.png', 'en': './assets/en/exercise/DEFENDER_HP_AREA.png', 'jp': './assets/jp/exercise/DEFENDER_HP_AREA.png', 'tw': './assets/tw/exercise/DEFENDER_HP_AREA.png'})
DEFENDER_HP_AREA_New = Button(area={'cn': (692, 40, 1019, 49), 'en': (692, 40, 1019, 49), 'jp': (692, 40, 1019, 49), 'tw': (692, 40, 1019, 49)}, color={'cn': (231, 80, 45), 'en': (231, 80, 45), 'jp': (231, 80, 45), 'tw': (231, 80, 45)}, button={'cn': (692, 40, 1019, 49), 'en': (692, 40, 1019, 49), 'jp': (692, 40, 1019, 49), 'tw': (692, 40, 1019, 49)}, file={'cn': './assets/cn/exercise/DEFENDER_HP_AREA_New.png', 'en': './assets/en/exercise/DEFENDER_HP_AREA_New.png', 'jp': './assets/jp/exercise/DEFENDER_HP_AREA_New.png', 'tw': './assets/tw/exercise/DEFENDER_HP_AREA_New.png'})
EQUIP_EDIT_ACTIVE = Button(area={'cn': (51, 608, 245, 668), 'en': (50, 607, 247, 670), 'jp': (53, 610, 245, 667), 'tw': (51, 607, 247, 668)}, color={'cn': (191, 159, 109), 'en': (186, 157, 105), 'jp': (192, 159, 109), 'tw': (191, 159, 109)}, button={'cn': (51, 608, 245, 668), 'en': (50, 607, 247, 670), 'jp': (53, 610, 245, 667), 'tw': (51, 607, 247, 668)}, file={'cn': './assets/cn/exercise/EQUIP_EDIT_ACTIVE.png', 'en': './assets/en/exercise/EQUIP_EDIT_ACTIVE.png', 'jp': './assets/jp/exercise/EQUIP_EDIT_ACTIVE.png', 'tw': './assets/tw/exercise/EQUIP_EDIT_ACTIVE.png'})
EQUIP_EDIT_INACTIVE = Button(area={'cn': (51, 608, 246, 667), 'en': (50, 607, 247, 670), 'jp': (50, 610, 244, 668), 'tw': (50, 608, 246, 669)}, color={'cn': (89, 112, 158), 'en': (88, 111, 156), 'jp': (90, 113, 160), 'tw': (92, 115, 160)}, button={'cn': (51, 608, 246, 667), 'en': (50, 607, 247, 670), 'jp': (50, 610, 244, 668), 'tw': (50, 608, 246, 669)}, file={'cn': './assets/cn/exercise/EQUIP_EDIT_INACTIVE.png', 'en': './assets/en/exercise/EQUIP_EDIT_INACTIVE.png', 'jp': './assets/jp/exercise/EQUIP_EDIT_INACTIVE.png', 'tw': './assets/tw/exercise/EQUIP_EDIT_INACTIVE.png'})
EQUIP_ENTER = Button(area={'cn': (432, 283, 442, 293), 'en': (432, 283, 442, 293), 'jp': (432, 283, 442, 293), 'tw': (432, 283, 442, 293)}, color={'cn': (207, 206, 206), 'en': (207, 206, 206), 'jp': (207, 206, 206), 'tw': (207, 206, 206)}, button={'cn': (432, 283, 442, 293), 'en': (432, 283, 442, 293), 'jp': (432, 283, 442, 293), 'tw': (432, 283, 442, 293)}, file={'cn': './assets/cn/exercise/EQUIP_ENTER.png', 'en': './assets/en/exercise/EQUIP_ENTER.png', 'jp': './assets/jp/exercise/EQUIP_ENTER.png', 'tw': './assets/tw/exercise/EQUIP_ENTER.png'})

View File

@ -43,13 +43,18 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment, Combat):
self.low_hp_confirm_timer = Timer(self.config.Exercise_LowHpConfirmWait, count=2).start()
show_hp_timer = Timer(5)
pause_interval = Timer(0.5, count=1)
# Pause button to identify battle UI theme
pause = None
success = True
end = False
while 1:
self.device.screenshot()
if not self.is_combat_executing():
p = self.is_combat_executing()
if p:
pause = p
else:
# Finish - S or D rank
if self.appear_then_click(BATTLE_STATUS_S, interval=1):
success = True
@ -86,7 +91,7 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment, Combat):
pause_interval.reset()
continue
if not end:
if self._at_low_hp(image=self.device.image):
if self._at_low_hp(image=self.device.image, pause=pause):
logger.info('Exercise quit')
if pause_interval.reached():
pause = self.is_combat_executing()

View File

@ -1,7 +1,8 @@
from module.base.base import ModuleBase
from module.base.timer import Timer
from module.base.utils import color_bar_percentage
from module.exercise.assets import ATTACKER_HP_AREA, DEFENDER_HP_AREA
from module.combat_ui.assets import PAUSE, PAUSE_Iridescent_Fantasy, PAUSE_New
from module.exercise.assets import *
from module.logger import logger
@ -54,9 +55,18 @@ class HpDaemon(ModuleBase):
text += ' - Low HP: %ss' % str(round(low_hp_time, 3)).ljust(5, '0')
logger.info(text)
def _at_low_hp(self, image):
self.attacker_hp = self._calculate_hp(image, area=ATTACKER_HP_AREA.area, reverse=True)
self.defender_hp = self._calculate_hp(image, area=DEFENDER_HP_AREA.area, reverse=False)
def _at_low_hp(self, image, pause=None):
if pause is None or pause == PAUSE:
self.attacker_hp = self._calculate_hp(image, area=ATTACKER_HP_AREA.area, reverse=True)
self.defender_hp = self._calculate_hp(image, area=DEFENDER_HP_AREA.area, reverse=False)
elif pause in [PAUSE_New, PAUSE_Iridescent_Fantasy]:
self.attacker_hp = self._calculate_hp(image, area=ATTACKER_HP_AREA_New.area, reverse=True)
self.defender_hp = self._calculate_hp(image, area=DEFENDER_HP_AREA_New.area, reverse=True)
else:
logger.warning(f'_at_low_hp received unknown pause: {pause}')
self.attacker_hp = self._calculate_hp(image, area=ATTACKER_HP_AREA.area, reverse=True)
self.defender_hp = self._calculate_hp(image, area=DEFENDER_HP_AREA.area, reverse=False)
if 0.01 < self.attacker_hp <= self.config.Exercise_LowHpThreshold:
if self.low_hp_confirm_timer.reached() and self.low_hp_confirm_timer.current() < 300:
self._show_hp(self.low_hp_confirm_timer.current())