Skip to content

Commit

Permalink
Add: meta progress reward receive
Browse files Browse the repository at this point in the history
  • Loading branch information
guoh064 committed Dec 12, 2024
1 parent bfdf6e4 commit 8835906
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 0 deletions.
Binary file added assets/cn/meta_reward/META_PROGRESS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cn/meta_reward/META_PROGRESS_CHECK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cn/meta_reward/META_PROGRESS_FINISHED.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cn/meta_reward/META_PROGRESS_NOTICE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cn/meta_reward/META_PROGRESS_RECEIVE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cn/meta_reward/META_SHIP_RECEIVE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions module/meta_reward/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
DOSSIER_REWARD_CHECK = Button(area={'cn': (120, 14, 231, 40), 'en': (120, 14, 316, 39), 'jp': (119, 13, 231, 39), 'tw': (120, 14, 231, 40)}, color={'cn': (176, 159, 160), 'en': (130, 105, 104), 'jp': (183, 169, 170), 'tw': (176, 159, 160)}, button={'cn': (120, 14, 231, 40), 'en': (120, 14, 316, 39), 'jp': (119, 13, 231, 39), 'tw': (120, 14, 231, 40)}, file={'cn': './assets/cn/meta_reward/DOSSIER_REWARD_CHECK.png', 'en': './assets/en/meta_reward/DOSSIER_REWARD_CHECK.png', 'jp': './assets/jp/meta_reward/DOSSIER_REWARD_CHECK.png', 'tw': './assets/cn/meta_reward/DOSSIER_REWARD_CHECK.png'})
DOSSIER_REWARD_ENTER = Button(area={'cn': (244, 645, 404, 709), 'en': (244, 645, 404, 709), 'jp': (244, 645, 404, 709), 'tw': (244, 645, 404, 709)}, color={'cn': (104, 87, 80), 'en': (104, 87, 80), 'jp': (104, 87, 80), 'tw': (104, 87, 80)}, button={'cn': (244, 645, 404, 709), 'en': (244, 645, 404, 709), 'jp': (244, 645, 404, 709), 'tw': (244, 645, 404, 709)}, file={'cn': './assets/cn/meta_reward/DOSSIER_REWARD_ENTER.png', 'en': './assets/en/meta_reward/DOSSIER_REWARD_ENTER.png', 'jp': './assets/jp/meta_reward/DOSSIER_REWARD_ENTER.png', 'tw': './assets/cn/meta_reward/DOSSIER_REWARD_ENTER.png'})
DOSSIER_REWARD_RECEIVE = Button(area={'cn': (426, 617, 432, 628), 'en': (426, 617, 432, 628), 'jp': (426, 617, 432, 628), 'tw': (426, 617, 432, 628)}, color={'cn': (214, 117, 103), 'en': (214, 117, 103), 'jp': (214, 117, 103), 'tw': (214, 117, 103)}, button={'cn': (320, 622, 428, 651), 'en': (320, 622, 428, 651), 'jp': (320, 622, 428, 651), 'tw': (320, 622, 428, 651)}, file={'cn': './assets/cn/meta_reward/DOSSIER_REWARD_RECEIVE.png', 'en': './assets/en/meta_reward/DOSSIER_REWARD_RECEIVE.png', 'jp': './assets/jp/meta_reward/DOSSIER_REWARD_RECEIVE.png', 'tw': './assets/cn/meta_reward/DOSSIER_REWARD_RECEIVE.png'})
META_PROGRESS = Button(area={'cn': (594, 404, 605, 415), 'en': (594, 404, 605, 415), 'jp': (594, 404, 605, 415), 'tw': (594, 404, 605, 415)}, color={'cn': (32, 118, 205), 'en': (32, 118, 205), 'jp': (32, 118, 205), 'tw': (32, 118, 205)}, button={'cn': (594, 404, 605, 415), 'en': (594, 404, 605, 415), 'jp': (594, 404, 605, 415), 'tw': (594, 404, 605, 415)}, file={'cn': './assets/cn/meta_reward/META_PROGRESS.png', 'en': './assets/cn/meta_reward/META_PROGRESS.png', 'jp': './assets/cn/meta_reward/META_PROGRESS.png', 'tw': './assets/cn/meta_reward/META_PROGRESS.png'})
META_PROGRESS_CHECK = Button(area={'cn': (809, 351, 824, 370), 'en': (809, 351, 824, 370), 'jp': (809, 351, 824, 370), 'tw': (809, 351, 824, 370)}, color={'cn': (143, 41, 42), 'en': (143, 41, 42), 'jp': (143, 41, 42), 'tw': (143, 41, 42)}, button={'cn': (809, 351, 824, 370), 'en': (809, 351, 824, 370), 'jp': (809, 351, 824, 370), 'tw': (809, 351, 824, 370)}, file={'cn': './assets/cn/meta_reward/META_PROGRESS_CHECK.png', 'en': './assets/cn/meta_reward/META_PROGRESS_CHECK.png', 'jp': './assets/cn/meta_reward/META_PROGRESS_CHECK.png', 'tw': './assets/cn/meta_reward/META_PROGRESS_CHECK.png'})
META_PROGRESS_FINISHED = Button(area={'cn': (503, 378, 516, 385), 'en': (503, 378, 516, 385), 'jp': (503, 378, 516, 385), 'tw': (503, 378, 516, 385)}, color={'cn': (254, 253, 253), 'en': (254, 253, 253), 'jp': (254, 253, 253), 'tw': (254, 253, 253)}, button={'cn': (503, 378, 516, 385), 'en': (503, 378, 516, 385), 'jp': (503, 378, 516, 385), 'tw': (503, 378, 516, 385)}, file={'cn': './assets/cn/meta_reward/META_PROGRESS_FINISHED.png', 'en': './assets/cn/meta_reward/META_PROGRESS_FINISHED.png', 'jp': './assets/cn/meta_reward/META_PROGRESS_FINISHED.png', 'tw': './assets/cn/meta_reward/META_PROGRESS_FINISHED.png'})
META_PROGRESS_NOTICE = Button(area={'cn': (967, 340, 971, 345), 'en': (967, 340, 971, 345), 'jp': (967, 340, 971, 345), 'tw': (967, 340, 971, 345)}, color={'cn': (247, 182, 58), 'en': (247, 182, 58), 'jp': (247, 182, 58), 'tw': (247, 182, 58)}, button={'cn': (967, 340, 971, 345), 'en': (967, 340, 971, 345), 'jp': (967, 340, 971, 345), 'tw': (967, 340, 971, 345)}, file={'cn': './assets/cn/meta_reward/META_PROGRESS_NOTICE.png', 'en': './assets/cn/meta_reward/META_PROGRESS_NOTICE.png', 'jp': './assets/cn/meta_reward/META_PROGRESS_NOTICE.png', 'tw': './assets/cn/meta_reward/META_PROGRESS_NOTICE.png'})
META_PROGRESS_RECEIVE = Button(area={'cn': (837, 342, 968, 380), 'en': (837, 342, 968, 380), 'jp': (837, 342, 968, 380), 'tw': (837, 342, 968, 380)}, color={'cn': (111, 83, 84), 'en': (111, 83, 84), 'jp': (111, 83, 84), 'tw': (111, 83, 84)}, button={'cn': (837, 342, 968, 380), 'en': (837, 342, 968, 380), 'jp': (837, 342, 968, 380), 'tw': (837, 342, 968, 380)}, file={'cn': './assets/cn/meta_reward/META_PROGRESS_RECEIVE.png', 'en': './assets/cn/meta_reward/META_PROGRESS_RECEIVE.png', 'jp': './assets/cn/meta_reward/META_PROGRESS_RECEIVE.png', 'tw': './assets/cn/meta_reward/META_PROGRESS_RECEIVE.png'})
META_REWARD_NOTICE = Button(area={'cn': (1070, 508, 1075, 523), 'en': (1070, 508, 1075, 523), 'jp': (1070, 508, 1075, 523), 'tw': (1070, 508, 1075, 523)}, color={'cn': (249, 182, 57), 'en': (249, 182, 57), 'jp': (249, 182, 57), 'tw': (249, 182, 57)}, button={'cn': (1070, 508, 1075, 523), 'en': (1070, 508, 1075, 523), 'jp': (1070, 508, 1075, 523), 'tw': (1070, 508, 1075, 523)}, file={'cn': './assets/cn/meta_reward/META_REWARD_NOTICE.png', 'en': './assets/en/meta_reward/META_REWARD_NOTICE.png', 'jp': './assets/jp/meta_reward/META_REWARD_NOTICE.png', 'tw': './assets/cn/meta_reward/META_REWARD_NOTICE.png'})
META_SHIP_RECEIVE = Button(area={'cn': (557, 337, 723, 379), 'en': (557, 337, 723, 379), 'jp': (557, 337, 723, 379), 'tw': (557, 337, 723, 379)}, color={'cn': (157, 103, 103), 'en': (157, 103, 103), 'jp': (157, 103, 103), 'tw': (157, 103, 103)}, button={'cn': (557, 337, 723, 379), 'en': (557, 337, 723, 379), 'jp': (557, 337, 723, 379), 'tw': (557, 337, 723, 379)}, file={'cn': './assets/cn/meta_reward/META_SHIP_RECEIVE.png', 'en': './assets/cn/meta_reward/META_SHIP_RECEIVE.png', 'jp': './assets/cn/meta_reward/META_SHIP_RECEIVE.png', 'tw': './assets/cn/meta_reward/META_SHIP_RECEIVE.png'})
REWARD_CHECK = Button(area={'cn': (31, 486, 64, 543), 'en': (35, 487, 62, 541), 'jp': (31, 486, 64, 543), 'tw': (31, 486, 64, 543)}, color={'cn': (199, 164, 165), 'en': (203, 169, 170), 'jp': (206, 172, 174), 'tw': (199, 164, 165)}, button={'cn': (31, 486, 64, 543), 'en': (35, 487, 62, 541), 'jp': (31, 486, 64, 543), 'tw': (31, 486, 64, 543)}, file={'cn': './assets/cn/meta_reward/REWARD_CHECK.png', 'en': './assets/en/meta_reward/REWARD_CHECK.png', 'jp': './assets/jp/meta_reward/REWARD_CHECK.png', 'tw': './assets/cn/meta_reward/REWARD_CHECK.png'})
REWARD_ENTER = Button(area={'cn': (1109, 535, 1187, 554), 'en': (1106, 532, 1199, 544), 'jp': (1108, 535, 1188, 554), 'tw': (1109, 535, 1187, 554)}, color={'cn': (199, 195, 201), 'en': (213, 212, 217), 'jp': (215, 207, 214), 'tw': (199, 195, 201)}, button={'cn': (1109, 535, 1187, 554), 'en': (1106, 532, 1199, 544), 'jp': (1108, 535, 1188, 554), 'tw': (1109, 535, 1187, 554)}, file={'cn': './assets/cn/meta_reward/REWARD_ENTER.png', 'en': './assets/en/meta_reward/REWARD_ENTER.png', 'jp': './assets/jp/meta_reward/REWARD_ENTER.png', 'tw': './assets/cn/meta_reward/REWARD_ENTER.png'})
REWARD_RECEIVE = Button(area={'cn': (1031, 601, 1215, 638), 'en': (1067, 608, 1182, 633), 'jp': (1043, 604, 1203, 635), 'tw': (1031, 601, 1215, 638)}, color={'cn': (149, 62, 62), 'en': (164, 92, 93), 'jp': (150, 64, 64), 'tw': (149, 62, 62)}, button={'cn': (1031, 601, 1215, 638), 'en': (1067, 608, 1182, 633), 'jp': (1043, 604, 1203, 635), 'tw': (1031, 601, 1215, 638)}, file={'cn': './assets/cn/meta_reward/REWARD_RECEIVE.png', 'en': './assets/en/meta_reward/REWARD_RECEIVE.png', 'jp': './assets/jp/meta_reward/REWARD_RECEIVE.png', 'tw': './assets/cn/meta_reward/REWARD_RECEIVE.png'})
104 changes: 104 additions & 0 deletions module/meta_reward/meta_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,104 @@ def meta_reward_receive(self, skip_first_screenshot=True):
logger.info(f'Meta reward receive finished, received={received}')
return received

def meta_progress_appear(self):
return self.appear(META_PROGRESS, offset=(30, 30))

def meta_progress_receive(self, skip_first_screenshot=True):
"""
Args:
skip_first_screenshot:
Returns:
bool: If received.
Pages:
in: page_meta
out: page_meta
"""
logger.hr('Meta reward receive', level=1)
confirm_timer = Timer(1, count=3).start()
received = False
progress_loaded = False
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()

if not progress_loaded:
if not self.appear(META_PROGRESS_CHECK):
confirm_timer.reset()
continue
else:
progress_loaded = True
if self.appear(META_PROGRESS_NOTICE, offset=(20, 20), interval=3):
self.device.click(META_PROGRESS_RECEIVE)
confirm_timer.reset()
continue
if self.handle_get_items():
received = True
confirm_timer.reset()
continue

# End
if not self.image_color_count(META_PROGRESS_NOTICE, color=(247, 182, 58), threshold=221, count=6):
if confirm_timer.reached():
break
else:
confirm_timer.reset()

logger.info(f'Meta reward receive finished, received={received}')
return received

def meta_progress_finished(self):
return self.appear(META_PROGRESS_FINISHED, offset=(30, 0))

def meta_ship_receive(self, skip_first_screenshot=True):
"""
Args:
skip_first_screenshot:
Returns:
bool: If received.
Pages:
in: page_meta
out: page_meta
"""
logger.hr('Meta reward receive', level=1)
confirm_timer = Timer(1, count=3).start()
received = False
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()

if self.meta_progress_finished():
self.device.click(META_SHIP_RECEIVE)
confirm_timer.reset()
continue
if self.handle_popup_confirm('META_REWARD'):
# Lock new META ships
confirm_timer.reset()
continue
if self.handle_get_items():
received = True
confirm_timer.reset()
continue
if self.handle_get_ship():
received = True
confirm_timer.reset()
continue

# End
if self.appear(REWARD_ENTER):
break

logger.info(f'Meta reward receive finished, received={received}')
return received

def run(self):
if self.config.SERVER in ['cn', 'en', 'jp']:
pass
Expand All @@ -101,6 +199,12 @@ def run(self):

self.ui_ensure(page_meta)

if self.meta_progress_appear():
self.meta_progress_receive()

if self.meta_progress_finished():
self.meta_ship_receive()

if self.meta_reward_notice_appear():
self.meta_reward_enter()
self.meta_reward_receive()
Expand Down

0 comments on commit 8835906

Please sign in to comment.