Merge pull request #2096 from bookbug666/event_checker

Add: Auto disable event task when no event (#1396)
This commit is contained in:
LmeSzinc 2023-01-29 14:42:58 +08:00 committed by GitHub
commit 2472ccbdc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -4,6 +4,8 @@ from datetime import datetime
from module.campaign.campaign_status import CampaignStatus
from module.config.utils import DEFAULT_TIME
from module.logger import logger
from module.ui.assets import CAMPAIGN_MENU_NO_EVENT
from module.ui.page import page_event, page_campaign_menu, page_sp
class CampaignEvent(CampaignStatus):
@ -140,6 +142,60 @@ class CampaignEvent(CampaignStatus):
self.config.task_call(next_task)
self.config.task_stop()
def ui_goto_event(self):
# Already in page_event, skip event_check.
if self.ui_get_current_page() == page_event:
logger.info('Already at page_event')
return True
else:
self.ui_goto(page_campaign_menu)
# Check event availability
if self.appear(CAMPAIGN_MENU_NO_EVENT, offset=(20, 20)):
logger.info('Event unavailable, disable task')
tasks = [
'Event',
'Event2',
'EventA',
'EventB',
'EventC',
'EventD',
'EventSp',
'GemsFarming',
]
self._disable_tasks(tasks)
self.config.task_stop()
else:
logger.info('Event available, goto page_event')
self.ui_goto(page_event)
return True
def ui_goto_sp(self):
# Already in page_event, skip event_check.
if self.ui_get_current_page() == page_sp:
logger.info('Already at page_sp')
return True
else:
self.ui_goto(page_campaign_menu)
# Check event availability
if self.appear(CAMPAIGN_MENU_NO_EVENT, offset=(20, 20)):
logger.info('Event unavailable, disable task')
tasks = [
'Event',
'Event2',
'EventA',
'EventB',
'EventC',
'EventD',
'EventSp',
'GemsFarming',
]
self._disable_tasks(tasks)
self.config.task_stop()
else:
logger.info('Event available, goto page_sp')
self.ui_goto(destination=page_sp)
return True
@staticmethod
def stage_is_main(name) -> bool:
"""

View File

@ -21,6 +21,7 @@ CAMPAIGN_MENU_GOTO_EVENT = Button(area={'cn': (355, 439, 501, 506), 'en': (374,
CAMPAIGN_MENU_GOTO_EXERCISE = Button(area={'cn': (1011, 586, 1106, 638), 'en': (1010, 600, 1102, 624), 'jp': (970, 586, 1106, 638), 'tw': (1012, 584, 1107, 637)}, color={'cn': (45, 49, 51), 'en': (81, 83, 85), 'jp': (51, 53, 56), 'tw': (48, 52, 53)}, button={'cn': (1011, 586, 1106, 638), 'en': (1010, 600, 1102, 624), 'jp': (970, 586, 1106, 638), 'tw': (1012, 584, 1107, 637)}, file={'cn': './assets/cn/ui/CAMPAIGN_MENU_GOTO_EXERCISE.png', 'en': './assets/en/ui/CAMPAIGN_MENU_GOTO_EXERCISE.png', 'jp': './assets/jp/ui/CAMPAIGN_MENU_GOTO_EXERCISE.png', 'tw': './assets/tw/ui/CAMPAIGN_MENU_GOTO_EXERCISE.png'})
CAMPAIGN_MENU_GOTO_OS = Button(area={'cn': (355, 439, 501, 506), 'en': (374, 449, 503, 483), 'jp': (383, 442, 508, 507), 'tw': (355, 436, 503, 507)}, color={'cn': (103, 106, 113), 'en': (112, 115, 124), 'jp': (68, 72, 82), 'tw': (101, 104, 112)}, button={'cn': (543, 345, 967, 552), 'en': (543, 345, 967, 552), 'jp': (543, 345, 967, 552), 'tw': (543, 345, 967, 552)}, file={'cn': './assets/cn/ui/CAMPAIGN_MENU_GOTO_OS.png', 'en': './assets/en/ui/CAMPAIGN_MENU_GOTO_OS.png', 'jp': './assets/jp/ui/CAMPAIGN_MENU_GOTO_OS.png', 'tw': './assets/tw/ui/CAMPAIGN_MENU_GOTO_OS.png'})
CAMPAIGN_MENU_GOTO_WAR_ARCHIVES = Button(area={'cn': (210, 586, 310, 638), 'en': (222, 590, 308, 634), 'jp': (196, 591, 307, 632), 'tw': (211, 584, 311, 638)}, color={'cn': (62, 65, 66), 'en': (53, 55, 54), 'jp': (78, 80, 81), 'tw': (64, 67, 69)}, button={'cn': (210, 586, 310, 638), 'en': (222, 590, 308, 634), 'jp': (196, 591, 307, 632), 'tw': (211, 584, 311, 638)}, file={'cn': './assets/cn/ui/CAMPAIGN_MENU_GOTO_WAR_ARCHIVES.png', 'en': './assets/en/ui/CAMPAIGN_MENU_GOTO_WAR_ARCHIVES.png', 'jp': './assets/jp/ui/CAMPAIGN_MENU_GOTO_WAR_ARCHIVES.png', 'tw': './assets/tw/ui/CAMPAIGN_MENU_GOTO_WAR_ARCHIVES.png'})
CAMPAIGN_MENU_NO_EVENT = Button(area={'cn': (616, 206, 897, 233), 'en': (616, 206, 897, 233), 'jp': (575, 209, 940, 235), 'tw': (616, 206, 897, 233)}, color={'cn': (57, 67, 77), 'en': (57, 67, 77), 'jp': (49, 60, 70), 'tw': (57, 67, 77)}, button={'cn': (616, 206, 897, 233), 'en': (616, 206, 897, 233), 'jp': (575, 209, 940, 235), 'tw': (616, 206, 897, 233)}, file={'cn': './assets/cn/ui/CAMPAIGN_MENU_NO_EVENT.png', 'en': './assets/en/ui/CAMPAIGN_MENU_NO_EVENT.png', 'jp': './assets/jp/ui/CAMPAIGN_MENU_NO_EVENT.png', 'tw': './assets/cn/ui/CAMPAIGN_MENU_NO_EVENT.png'})
COMMISSION_CHECK = Button(area={'cn': (122, 16, 175, 39), 'en': (120, 14, 301, 41), 'jp': (121, 14, 176, 39), 'tw': (121, 14, 176, 41)}, color={'cn': (157, 173, 210), 'en': (98, 112, 150), 'jp': (159, 175, 211), 'tw': (141, 155, 193)}, button={'cn': (122, 16, 175, 39), 'en': (120, 14, 301, 41), 'jp': (121, 14, 176, 39), 'tw': (121, 14, 176, 41)}, file={'cn': './assets/cn/ui/COMMISSION_CHECK.png', 'en': './assets/en/ui/COMMISSION_CHECK.png', 'jp': './assets/jp/ui/COMMISSION_CHECK.png', 'tw': './assets/tw/ui/COMMISSION_CHECK.png'})
DAILY_CHECK = Button(area={'cn': (23, 656, 67, 698), 'en': (23, 656, 67, 698), 'jp': (23, 656, 67, 698), 'tw': (23, 656, 67, 698)}, color={'cn': (84, 139, 210), 'en': (84, 139, 210), 'jp': (84, 139, 210), 'tw': (84, 139, 210)}, button={'cn': (23, 656, 67, 698), 'en': (23, 656, 67, 698), 'jp': (23, 656, 67, 698), 'tw': (23, 656, 67, 698)}, file={'cn': './assets/cn/ui/DAILY_CHECK.png', 'en': './assets/en/ui/DAILY_CHECK.png', 'jp': './assets/jp/ui/DAILY_CHECK.png', 'tw': './assets/tw/ui/DAILY_CHECK.png'})
DORMMENU_CHECK = Button(area={'cn': (248, 270, 363, 359), 'en': (225, 265, 401, 350), 'jp': (203, 248, 409, 450), 'tw': (248, 270, 363, 359)}, color={'cn': (194, 187, 184), 'en': (169, 168, 173), 'jp': (144, 155, 168), 'tw': (194, 187, 184)}, button={'cn': (248, 270, 363, 359), 'en': (225, 265, 401, 350), 'jp': (203, 248, 409, 450), 'tw': (248, 270, 363, 359)}, file={'cn': './assets/cn/ui/DORMMENU_CHECK.png', 'en': './assets/en/ui/DORMMENU_CHECK.png', 'jp': './assets/jp/ui/DORMMENU_CHECK.png', 'tw': './assets/tw/ui/DORMMENU_CHECK.png'})