mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Add: Claim weekly rogue rewards (#147)
This commit is contained in:
parent
7f6bc78ccc
commit
16b8dc4a1d
BIN
assets/share/rogue/reward/CLAIM_ALL.png
Normal file
BIN
assets/share/rogue/reward/CLAIM_ALL.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
BIN
assets/share/rogue/reward/REWARD_CHECK.png
Normal file
BIN
assets/share/rogue/reward/REWARD_CHECK.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
BIN
assets/share/rogue/reward/REWARD_CLOSE.png
Normal file
BIN
assets/share/rogue/reward/REWARD_CLOSE.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
BIN
assets/share/rogue/reward/REWARD_ENTER.BUTTON.png
Normal file
BIN
assets/share/rogue/reward/REWARD_ENTER.BUTTON.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
assets/share/rogue/reward/REWARD_ENTER.png
Normal file
BIN
assets/share/rogue/reward/REWARD_ENTER.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
BIN
assets/share/rogue/reward/REWARD_RED_DOT.png
Normal file
BIN
assets/share/rogue/reward/REWARD_RED_DOT.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
@ -3,6 +3,56 @@ from module.base.button import Button, ButtonWrapper
|
|||||||
# This file was auto-generated, do not modify it manually. To generate:
|
# This file was auto-generated, do not modify it manually. To generate:
|
||||||
# ``` python -m dev_tools.button_extract ```
|
# ``` python -m dev_tools.button_extract ```
|
||||||
|
|
||||||
|
CLAIM_ALL = ButtonWrapper(
|
||||||
|
name='CLAIM_ALL',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/rogue/reward/CLAIM_ALL.png',
|
||||||
|
area=(871, 524, 1146, 560),
|
||||||
|
search=(851, 504, 1166, 580),
|
||||||
|
color=(238, 186, 85),
|
||||||
|
button=(871, 524, 1146, 560),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
REWARD_CHECK = ButtonWrapper(
|
||||||
|
name='REWARD_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/rogue/reward/REWARD_CHECK.png',
|
||||||
|
area=(152, 504, 187, 532),
|
||||||
|
search=(132, 484, 207, 552),
|
||||||
|
color=(131, 130, 126),
|
||||||
|
button=(152, 504, 187, 532),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
REWARD_CLOSE = ButtonWrapper(
|
||||||
|
name='REWARD_CLOSE',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/rogue/reward/REWARD_CLOSE.png',
|
||||||
|
area=(1139, 137, 1169, 167),
|
||||||
|
search=(1119, 117, 1189, 187),
|
||||||
|
color=(64, 64, 64),
|
||||||
|
button=(1139, 137, 1169, 167),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
REWARD_ENTER = ButtonWrapper(
|
||||||
|
name='REWARD_ENTER',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/rogue/reward/REWARD_ENTER.png',
|
||||||
|
area=(59, 601, 92, 629),
|
||||||
|
search=(39, 581, 112, 649),
|
||||||
|
color=(128, 128, 129),
|
||||||
|
button=(43, 583, 117, 657),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
REWARD_RED_DOT = ButtonWrapper(
|
||||||
|
name='REWARD_RED_DOT',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/rogue/reward/REWARD_RED_DOT.png',
|
||||||
|
area=(94, 582, 122, 610),
|
||||||
|
search=(74, 562, 142, 630),
|
||||||
|
color=(130, 67, 71),
|
||||||
|
button=(94, 582, 122, 610),
|
||||||
|
),
|
||||||
|
)
|
||||||
ROGUE_REPORT = ButtonWrapper(
|
ROGUE_REPORT = ButtonWrapper(
|
||||||
name='ROGUE_REPORT',
|
name='ROGUE_REPORT',
|
||||||
share=Button(
|
share=Button(
|
||||||
|
@ -4,6 +4,7 @@ from module.base.utils import area_offset
|
|||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Digit, Ocr, OcrResultButton
|
from module.ocr.ocr import Digit, Ocr, OcrResultButton
|
||||||
from tasks.base.ui import UI
|
from tasks.base.ui import UI
|
||||||
|
from tasks.rogue.assets.assets_rogue_reward import REWARD_ENTER
|
||||||
from tasks.rogue.assets.assets_rogue_ui import *
|
from tasks.rogue.assets.assets_rogue_ui import *
|
||||||
from tasks.rogue.keywords import RoguePath
|
from tasks.rogue.keywords import RoguePath
|
||||||
|
|
||||||
@ -45,6 +46,9 @@ class RogueUI(UI):
|
|||||||
def is_page_event(self):
|
def is_page_event(self):
|
||||||
return self.appear(PAGE_EVENT)
|
return self.appear(PAGE_EVENT)
|
||||||
|
|
||||||
|
def is_page_rogue_main(self):
|
||||||
|
return self.appear(REWARD_ENTER)
|
||||||
|
|
||||||
def handle_obtain_item_popup(self, interval=5) -> bool:
|
def handle_obtain_item_popup(self, interval=5) -> bool:
|
||||||
"""After selecting some curio (e.g. Sealing_Wax_of_*), there will be a popup after back to main page"""
|
"""After selecting some curio (e.g. Sealing_Wax_of_*), there will be a popup after back to main page"""
|
||||||
if self.appear_then_click(OBTAIN_ITEM_POPUP, interval=interval):
|
if self.appear_then_click(OBTAIN_ITEM_POPUP, interval=interval):
|
||||||
|
115
tasks/rogue/reward.py
Normal file
115
tasks/rogue/reward.py
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
from module.base.timer import Timer
|
||||||
|
from module.logger import logger
|
||||||
|
from tasks.rogue.assets.assets_rogue_reward import CLAIM_ALL, REWARD_CHECK, REWARD_CLOSE, REWARD_ENTER, REWARD_RED_DOT
|
||||||
|
from tasks.rogue.bleesing.ui import RogueUI
|
||||||
|
|
||||||
|
|
||||||
|
class RogueRewardHandler(RogueUI):
|
||||||
|
def _rogue_reward_appear(self) -> bool:
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: is_page_rogue_main()
|
||||||
|
"""
|
||||||
|
if self.image_color_count(REWARD_RED_DOT, color=(214, 45, 47), threshold=221, count=50):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _rogue_reward_enter(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: is_page_rogue_main()
|
||||||
|
out: REWARD_CHECK
|
||||||
|
"""
|
||||||
|
logger.info('Rogue reward enter')
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if self.appear(REWARD_CHECK):
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.appear_then_click(REWARD_ENTER, interval=2):
|
||||||
|
continue
|
||||||
|
|
||||||
|
def _rogue_reward_exit(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: REWARD_CHECK
|
||||||
|
out: is_page_rogue_main()
|
||||||
|
"""
|
||||||
|
logger.info('Rogue reward exit')
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if self.is_page_rogue_main():
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.appear_then_click(REWARD_CLOSE, interval=2):
|
||||||
|
continue
|
||||||
|
if self.handle_reward():
|
||||||
|
continue
|
||||||
|
|
||||||
|
def _rogue_reward_claim(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: REWARD_CHECK, CLAIM_ALL
|
||||||
|
out: REWARD_CHECK
|
||||||
|
"""
|
||||||
|
logger.info('Rogue reward claim')
|
||||||
|
claimed = False
|
||||||
|
appear = False
|
||||||
|
timeout = Timer(2, count=10).start()
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if claimed:
|
||||||
|
if self.appear(REWARD_CHECK):
|
||||||
|
break
|
||||||
|
if self.is_page_rogue_main():
|
||||||
|
break
|
||||||
|
if not appear and timeout.reached():
|
||||||
|
logger.warning('Rogue reward claim timeout, CLAIM_ALL not found')
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.handle_reward():
|
||||||
|
claimed = True
|
||||||
|
continue
|
||||||
|
if self.interval_is_reached(CLAIM_ALL, interval=1):
|
||||||
|
if self.image_color_count(CLAIM_ALL, color=(255, 199, 89), threshold=221, count=500):
|
||||||
|
self.device.click(CLAIM_ALL)
|
||||||
|
self.interval_reset(CLAIM_ALL)
|
||||||
|
appear = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
def rogue_reward_claim(self):
|
||||||
|
"""
|
||||||
|
Claim possible rogue rewards.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: If claimed.
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: is_page_rogue_main()
|
||||||
|
out: is_page_rogue_main()
|
||||||
|
"""
|
||||||
|
if self._rogue_reward_appear():
|
||||||
|
logger.hr('Rogue reward claim', level=2)
|
||||||
|
self._rogue_reward_enter()
|
||||||
|
self._rogue_reward_claim()
|
||||||
|
self._rogue_reward_exit()
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
logger.info('No rogue reward')
|
||||||
|
return False
|
21
tasks/rogue/rogue.py
Normal file
21
tasks/rogue/rogue.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from tasks.rogue.reward import RogueRewardHandler
|
||||||
|
from tasks.rogue.route.loader import RouteLoader
|
||||||
|
|
||||||
|
|
||||||
|
class RogueHandler(RouteLoader, RogueRewardHandler):
|
||||||
|
def rogue_once(self):
|
||||||
|
"""
|
||||||
|
Do a complete rogue run.
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: page_rogue, is_page_rogue_main()
|
||||||
|
out: page_rogue, is_page_rogue_main()
|
||||||
|
"""
|
||||||
|
self.rogue_run()
|
||||||
|
self.rogue_reward_claim()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
self = RogueHandler('src', task='Rogue')
|
||||||
|
self.device.screenshot()
|
||||||
|
self.rogue_once()
|
Loading…
Reference in New Issue
Block a user