mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 10:37:36 +08:00
Fix: get research duration remain from page_reward
This commit is contained in:
parent
dd4d818baf
commit
06d33d2a34
BIN
assets/cn/research/RESEARCH_LAB.png
Normal file
BIN
assets/cn/research/RESEARCH_LAB.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
assets/cn/research/RESEARCH_LAB_DURATION_REMAIN.png
Normal file
BIN
assets/cn/research/RESEARCH_LAB_DURATION_REMAIN.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
assets/cn/research/RESEARCH_RUNNING.png
Normal file
BIN
assets/cn/research/RESEARCH_RUNNING.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
assets/jp/research/RESEARCH_LAB.png
Normal file
BIN
assets/jp/research/RESEARCH_LAB.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
assets/jp/research/RESEARCH_LAB_DURATION_REMAIN.png
Normal file
BIN
assets/jp/research/RESEARCH_LAB_DURATION_REMAIN.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
assets/jp/research/RESEARCH_RUNNING.png
Normal file
BIN
assets/jp/research/RESEARCH_RUNNING.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -34,7 +34,10 @@ OCR_RESEARCH_5 = Button(area={'cn': (1042, 277, 1222, 329), 'en': (1042, 277, 12
|
||||
RESEARCH_COST_CHECKER = Button(area={'cn': (809, 365, 972, 386), 'en': (809, 365, 972, 386), 'jp': (809, 365, 972, 386), 'tw': (809, 365, 972, 386)}, color={'cn': (105, 114, 128), 'en': (105, 114, 128), 'jp': (105, 114, 128), 'tw': (105, 114, 128)}, button={'cn': (809, 365, 972, 386), 'en': (809, 365, 972, 386), 'jp': (809, 365, 972, 386), 'tw': (809, 365, 972, 386)}, file={'cn': './assets/cn/research/RESEARCH_COST_CHECKER.png', 'en': './assets/en/research/RESEARCH_COST_CHECKER.png', 'jp': './assets/jp/research/RESEARCH_COST_CHECKER.png', 'tw': './assets/tw/research/RESEARCH_COST_CHECKER.png'})
|
||||
RESEARCH_DETAIL_QUIT = Button(area={'cn': (695, 656, 784, 707), 'en': (695, 656, 784, 707), 'jp': (695, 656, 784, 707), 'tw': (695, 656, 784, 707)}, color={'cn': (50, 57, 74), 'en': (50, 57, 74), 'jp': (50, 57, 74), 'tw': (50, 57, 74)}, button={'cn': (695, 656, 784, 707), 'en': (695, 656, 784, 707), 'jp': (695, 656, 784, 707), 'tw': (695, 656, 784, 707)}, file={'cn': './assets/cn/research/RESEARCH_DETAIL_QUIT.png', 'en': './assets/en/research/RESEARCH_DETAIL_QUIT.png', 'jp': './assets/jp/research/RESEARCH_DETAIL_QUIT.png', 'tw': './assets/tw/research/RESEARCH_DETAIL_QUIT.png'})
|
||||
RESEARCH_FINISHED = Button(area={'cn': (384, 547, 502, 585), 'en': (382, 545, 504, 587), 'jp': (383, 546, 503, 586), 'tw': (384, 547, 502, 585)}, color={'cn': (233, 163, 69), 'en': (235, 174, 92), 'jp': (229, 159, 63), 'tw': (233, 163, 69)}, button={'cn': (384, 547, 502, 585), 'en': (382, 545, 504, 587), 'jp': (383, 546, 503, 586), 'tw': (384, 547, 502, 585)}, file={'cn': './assets/cn/research/RESEARCH_FINISHED.png', 'en': './assets/en/research/RESEARCH_FINISHED.png', 'jp': './assets/jp/research/RESEARCH_FINISHED.png', 'tw': './assets/tw/research/RESEARCH_FINISHED.png'})
|
||||
RESEARCH_LAB = Button(area={'cn': (56, 512, 189, 554), 'en': (56, 512, 189, 554), 'jp': (56, 512, 189, 554), 'tw': (56, 512, 189, 554)}, color={'cn': (106, 136, 168), 'en': (106, 136, 168), 'jp': (106, 136, 168), 'tw': (106, 136, 168)}, button={'cn': (56, 512, 189, 554), 'en': (56, 512, 189, 554), 'jp': (56, 512, 189, 554), 'tw': (56, 512, 189, 554)}, file={'cn': './assets/cn/research/RESEARCH_LAB.png', 'en': './assets/cn/research/RESEARCH_LAB.png', 'jp': './assets/jp/research/RESEARCH_LAB.png', 'tw': './assets/cn/research/RESEARCH_LAB.png'})
|
||||
RESEARCH_LAB_DURATION_REMAIN = Button(area={'cn': (379, 583, 504, 614), 'en': (379, 583, 504, 614), 'jp': (379, 583, 504, 614), 'tw': (379, 583, 504, 614)}, color={'cn': (158, 157, 158), 'en': (158, 157, 158), 'jp': (158, 157, 158), 'tw': (158, 157, 158)}, button={'cn': (379, 583, 504, 614), 'en': (379, 583, 504, 614), 'jp': (379, 583, 504, 614), 'tw': (379, 583, 504, 614)}, file={'cn': './assets/cn/research/RESEARCH_LAB_DURATION_REMAIN.png', 'en': './assets/cn/research/RESEARCH_LAB_DURATION_REMAIN.png', 'jp': './assets/jp/research/RESEARCH_LAB_DURATION_REMAIN.png', 'tw': './assets/cn/research/RESEARCH_LAB_DURATION_REMAIN.png'})
|
||||
RESEARCH_PENDING = Button(area={'cn': (227, 589, 269, 607), 'en': (227, 589, 269, 607), 'jp': (221, 588, 282, 612), 'tw': (225, 586, 272, 612)}, color={'cn': (108, 163, 168), 'en': (98, 152, 158), 'jp': (101, 148, 156), 'tw': (93, 144, 151)}, button={'cn': (227, 589, 269, 607), 'en': (227, 589, 269, 607), 'jp': (221, 588, 282, 612), 'tw': (225, 586, 272, 612)}, file={'cn': './assets/cn/research/RESEARCH_PENDING.png', 'en': './assets/en/research/RESEARCH_PENDING.png', 'jp': './assets/jp/research/RESEARCH_PENDING.png', 'tw': './assets/tw/research/RESEARCH_PENDING.png'})
|
||||
RESEARCH_RUNNING = Button(area={'cn': (313, 556, 362, 619), 'en': (313, 556, 362, 619), 'jp': (313, 556, 362, 619), 'tw': (313, 556, 362, 619)}, color={'cn': (124, 126, 131), 'en': (124, 126, 131), 'jp': (124, 126, 131), 'tw': (124, 126, 131)}, button={'cn': (313, 556, 362, 619), 'en': (313, 556, 362, 619), 'jp': (313, 556, 362, 619), 'tw': (313, 556, 362, 619)}, file={'cn': './assets/cn/research/RESEARCH_RUNNING.png', 'en': './assets/cn/research/RESEARCH_RUNNING.png', 'jp': './assets/jp/research/RESEARCH_RUNNING.png', 'tw': './assets/cn/research/RESEARCH_RUNNING.png'})
|
||||
RESEARCH_START = Button(area={'cn': (446, 570, 568, 596), 'en': (434, 573, 577, 593), 'jp': (421, 562, 594, 605), 'tw': (434, 566, 579, 602)}, color={'cn': (170, 209, 241), 'en': (136, 182, 225), 'jp': (123, 173, 222), 'tw': (148, 194, 237)}, button={'cn': (446, 570, 568, 596), 'en': (434, 573, 577, 593), 'jp': (421, 562, 594, 605), 'tw': (434, 566, 579, 602)}, file={'cn': './assets/cn/research/RESEARCH_START.png', 'en': './assets/en/research/RESEARCH_START.png', 'jp': './assets/jp/research/RESEARCH_START.png', 'tw': './assets/tw/research/RESEARCH_START.png'})
|
||||
RESEARCH_STOP = Button(area={'cn': (419, 559, 594, 604), 'en': (417, 557, 596, 606), 'jp': (421, 562, 593, 605), 'tw': (440, 565, 577, 604)}, color={'cn': (225, 137, 118), 'en': (217, 122, 99), 'jp': (225, 137, 117), 'tw': (237, 155, 137)}, button={'cn': (419, 559, 594, 604), 'en': (417, 557, 596, 606), 'jp': (421, 562, 593, 605), 'tw': (440, 565, 577, 604)}, file={'cn': './assets/cn/research/RESEARCH_STOP.png', 'en': './assets/en/research/RESEARCH_STOP.png', 'jp': './assets/jp/research/RESEARCH_STOP.png', 'tw': './assets/tw/research/RESEARCH_STOP.png'})
|
||||
RESEARCH_UNAVAILABLE = Button(area={'cn': (445, 569, 568, 596), 'en': (434, 573, 577, 593), 'jp': (421, 562, 595, 605), 'tw': (440, 565, 576, 601)}, color={'cn': (176, 188, 209), 'en': (150, 176, 199), 'jp': (159, 174, 202), 'tw': (156, 181, 203)}, button={'cn': (445, 569, 568, 596), 'en': (434, 573, 577, 593), 'jp': (421, 562, 595, 605), 'tw': (440, 565, 576, 601)}, file={'cn': './assets/cn/research/RESEARCH_UNAVAILABLE.png', 'en': './assets/en/research/RESEARCH_UNAVAILABLE.png', 'jp': './assets/jp/research/RESEARCH_UNAVAILABLE.png', 'tw': './assets/tw/research/RESEARCH_UNAVAILABLE.png'})
|
||||
|
@ -9,7 +9,7 @@ from module.research.project import ResearchSelector, RESEARCH_ENTRANCE, get_res
|
||||
from module.ui.page import *
|
||||
from module.ocr.ocr import Duration
|
||||
|
||||
OCR_DURATION = Duration(DURATION_REMAIN, letter=(255, 255, 255), threshold=64, name='DURATION_REMAIN')
|
||||
OCR_DURATION = Duration(RESEARCH_LAB_DURATION_REMAIN, letter=(255, 255, 255), threshold=64, name='RESEARCH_LAB_DURATION_REMAIN')
|
||||
|
||||
|
||||
class RewardResearch(ResearchSelector):
|
||||
@ -300,29 +300,34 @@ class RewardResearch(ResearchSelector):
|
||||
|
||||
def research_get_remain(self):
|
||||
"""
|
||||
Get remain duration of current project (the one in the middle).
|
||||
Get remain duration of current project from page_reward.
|
||||
|
||||
Returns:
|
||||
bool: True if success
|
||||
False if project requirements are not satisfied.
|
||||
float: research project remain time if success
|
||||
None: if failed
|
||||
|
||||
Pages:
|
||||
in: page_research, stable.
|
||||
out: page_research, stable.
|
||||
in: page_reward
|
||||
out: page_reward
|
||||
"""
|
||||
logger.hr('Research get remain')
|
||||
self.research_detect(self.device.image)
|
||||
|
||||
self.ui_click(click_button=RESEARCH_LAB, check_button=RESEARCH_RUNNING)
|
||||
# Check if button is still moving
|
||||
while 1:
|
||||
self.appear(RESEARCH_RUNNING)
|
||||
self.device.screenshot()
|
||||
if RESEARCH_RUNNING.match_appear_on(self.device.image):
|
||||
break
|
||||
|
||||
remain = OCR_DURATION.ocr(self.device.image)
|
||||
logger.info(f'Research project remain: {remain}')
|
||||
|
||||
if remain.total_seconds() > 0:
|
||||
project = self.projects[2]
|
||||
project.duration = remain.total_seconds() / 3600
|
||||
self.research_project_started = project
|
||||
return True
|
||||
if remain.total_seconds() >= 0:
|
||||
research_duration_remain = remain.total_seconds() / 3600
|
||||
return research_duration_remain
|
||||
else:
|
||||
self.research_project_started = None
|
||||
return False
|
||||
return None
|
||||
|
||||
def ui_ensure_research(self):
|
||||
"""
|
||||
@ -338,23 +343,28 @@ class RewardResearch(ResearchSelector):
|
||||
Pages:
|
||||
in: Any page
|
||||
out: page_research, with research project information, but it's still page_research.
|
||||
or page_main
|
||||
"""
|
||||
self.ui_ensure(page_reward)
|
||||
if self.appear(RESEARCH_FINISHED, offset=(50, 20)) or self.appear(RESEARCH_PENDING, offset=(50, 20)):
|
||||
self.ui_ensure_research()
|
||||
success = self.research_reward()
|
||||
else:
|
||||
self.ui_ensure_research()
|
||||
success = self.research_get_remain()
|
||||
|
||||
project = self.research_project_started
|
||||
if success:
|
||||
if project is not None:
|
||||
# Success to start a project
|
||||
self.config.task_delay(minute=float(project.duration) * 60)
|
||||
project = self.research_project_started
|
||||
if success:
|
||||
if project is not None:
|
||||
# Success to start a project
|
||||
self.config.task_delay(minute=float(project.duration) * 60)
|
||||
else:
|
||||
# No project satisfies current filter
|
||||
self.config.task_delay(server_update=True)
|
||||
else:
|
||||
# No project satisfies current filter
|
||||
self.config.task_delay(server_update=True)
|
||||
# Project requirements are not satisfied
|
||||
self.config.task_delay(success=False)
|
||||
else:
|
||||
# Project requirements are not satisfied
|
||||
self.config.task_delay(success=False)
|
||||
research_duration_remain = self.research_get_remain()
|
||||
if research_duration_remain is not None:
|
||||
self.config.task_delay(minute=float(research_duration_remain) * 60)
|
||||
else:
|
||||
self.config.task_delay(success=False)
|
||||
# Close page_reward to avoid bug
|
||||
self.ui_goto_main()
|
Loading…
Reference in New Issue
Block a user