mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2025-02-07 03:08:45 +00:00
Fix: use positive condition for break branch
This commit is contained in:
parent
a950348856
commit
e92ecc9486
Binary file not shown.
Before Width: | Height: | Size: 330 KiB After Width: | Height: | Size: 927 KiB |
BIN
assets/share/freebies/gift_of_odyssey/OCR_CLAIM.png
Normal file
BIN
assets/share/freebies/gift_of_odyssey/OCR_CLAIM.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 927 KiB |
@ -576,8 +576,8 @@ class KeywordExtract:
|
||||
read_file(os.path.join(TextMap.DATA_FOLDER, 'ExcelOutput', 'RogueBonus.json')), 'BonusTitle.Hash')))
|
||||
self.write_keywords(keyword_class='RogueBonus', output_file='./tasks/rogue/keywords/bonus.py')
|
||||
self.generate_rogue_events()
|
||||
self.load_keywords(['巡星之礼'])
|
||||
self.write_keywords(keyword_class='GiftOfOdysseyEvent', output_file='./tasks/freebies/keywords/gift_of_odyssey.py')
|
||||
self.load_keywords(["巡星之礼", "已领取", "领取", "待签到"])
|
||||
self.write_keywords(keyword_class="GiftOfOdysseyEvent", output_file="./tasks/freebies/keywords/gift_of_odyssey.py")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -18,11 +18,21 @@ GET_REWARD_BUTTON = ButtonWrapper(
|
||||
share=Button(
|
||||
file='./assets/share/freebies/gift_of_odyssey/GET_REWARD_BUTTON.png',
|
||||
area=(647, 397, 665, 415),
|
||||
search=(626, 243, 1212, 631),
|
||||
search=(228, 25, 1263, 701),
|
||||
color=(121, 120, 105),
|
||||
button=(647, 397, 665, 415),
|
||||
),
|
||||
)
|
||||
OCR_CLAIM = ButtonWrapper(
|
||||
name='OCR_CLAIM',
|
||||
share=Button(
|
||||
file='./assets/share/freebies/gift_of_odyssey/OCR_CLAIM.png',
|
||||
area=(228, 25, 1263, 701),
|
||||
search=(208, 5, 1280, 720),
|
||||
color=(155, 149, 153),
|
||||
button=(228, 25, 1263, 701),
|
||||
),
|
||||
)
|
||||
OCR_EVENT = ButtonWrapper(
|
||||
name='OCR_EVENT',
|
||||
share=Button(
|
||||
|
@ -3,8 +3,13 @@ from module.logger import logger
|
||||
from module.ocr.ocr import Ocr
|
||||
from tasks.base.page import page_event
|
||||
from tasks.base.ui import UI
|
||||
from tasks.freebies.assets.assets_freebies_gift_of_odyssey import OCR_EVENT, EVENT_SELECTED, GET_REWARD_BUTTON
|
||||
from tasks.freebies.keywords import GiftOfOdysseyEvent
|
||||
from tasks.freebies.assets.assets_freebies_gift_of_odyssey import (
|
||||
OCR_CLAIM,
|
||||
OCR_EVENT,
|
||||
EVENT_SELECTED,
|
||||
GET_REWARD_BUTTON,
|
||||
)
|
||||
from tasks.freebies.keywords import KEYWORDS_FREEBIES_GIFT_OF_ODYSSEY, GiftOfOdysseyEvent
|
||||
|
||||
|
||||
class GiftofOdyssey(UI):
|
||||
@ -41,9 +46,20 @@ class GiftofOdyssey(UI):
|
||||
break
|
||||
if self.device.click(results[0]):
|
||||
continue
|
||||
|
||||
return True
|
||||
|
||||
def _get_claim_status(self, image):
|
||||
ocr = Ocr(OCR_CLAIM)
|
||||
results = ocr.matched_ocr(image, GiftOfOdysseyEvent)
|
||||
claimed = [result for result in results if result == KEYWORDS_FREEBIES_GIFT_OF_ODYSSEY.Claimed]
|
||||
claim = [result for result in results if result == KEYWORDS_FREEBIES_GIFT_OF_ODYSSEY.Claim]
|
||||
awaiting = [result for result in results if result == KEYWORDS_FREEBIES_GIFT_OF_ODYSSEY.Awaiting_check_in]
|
||||
status = len(claimed), len(claim), len(awaiting)
|
||||
logger.info(f"Claim status (Claimed, Claim, Awaiting check in): {status}")
|
||||
if sum(status) != 7:
|
||||
logger.warning("Num of OCR results is not seven")
|
||||
return status
|
||||
|
||||
def _get_reward(self):
|
||||
logger.info("Getting reward")
|
||||
skip_first_screenshot = True
|
||||
@ -54,9 +70,11 @@ class GiftofOdyssey(UI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear(EVENT_SELECTED) and not self.appear(GET_REWARD_BUTTON):
|
||||
logger.info("No more reward to get")
|
||||
break
|
||||
if self.appear(EVENT_SELECTED):
|
||||
_, claim, _ = self._get_claim_status(self.device.image)
|
||||
if claim == 0:
|
||||
logger.info("No more reward to get")
|
||||
break
|
||||
if self.handle_reward():
|
||||
continue
|
||||
if interval.reached():
|
||||
|
@ -12,3 +12,30 @@ Gift_of_Odyssey = GiftOfOdysseyEvent(
|
||||
jp='巡星の礼',
|
||||
es='Presente del cometa',
|
||||
)
|
||||
Claimed = GiftOfOdysseyEvent(
|
||||
id=2,
|
||||
name='Claimed',
|
||||
cn='已领取',
|
||||
cht='已領取',
|
||||
en='Claimed',
|
||||
jp='受取済',
|
||||
es='Recogido',
|
||||
)
|
||||
Claim = GiftOfOdysseyEvent(
|
||||
id=3,
|
||||
name='Claim',
|
||||
cn='领取',
|
||||
cht='領取',
|
||||
en='Claim',
|
||||
jp='受取',
|
||||
es='Recoger',
|
||||
)
|
||||
Awaiting_check_in = GiftOfOdysseyEvent(
|
||||
id=4,
|
||||
name='Awaiting_check_in',
|
||||
cn='待签到',
|
||||
cht='待簽到',
|
||||
en='Awaiting check-in',
|
||||
jp='ログイン待ち',
|
||||
es='Por registrar',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user