Skip to content

Commit

Permalink
Merge pull request LmeSzinc#4587 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Feb 13, 2025
2 parents 15cfcba + 2e395ac commit 8510912
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 22 deletions.
1 change: 1 addition & 0 deletions campaign/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,4 @@ To add a new event, add a new row in here, and run `python -m module.config.conf
| 20250116 | raid 20250116 | Spring Fashion Festa | 华裳巧展喜事长 | Spring Fashion Festa | 新春華裳協奏曲 | - |
| 20250123 | raid 20250116 | Spring Fashion Festa | - | - | - | 華裳巧展喜事長 |
| 20250206 | event 20220818 cn | Operation Convergence Rerun | 复刻远汇点作战 | Operation Convergence Return | 結像点作戦(復刻) | - |
| 20250213 | event 20240815 cn | Windborne Steel Wings | - | - | - | 鐵翼擎風 |
34 changes: 29 additions & 5 deletions module/campaign/campaign_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ def _disable_tasks(self, tasks):
tasks (list[str]): Task name
"""
with self.config.multi_set():
# Disable normal events
for task in tasks:
if task in ['GemsFarming']:
if task in GEMS_FARMINGS:
continue
keys = f'{task}.Scheduler.Enable'
logger.info(f'Disable task `{task}`')
self.config.cross_set(keys=keys, value=False)

for task in ['GemsFarming']:
# Reset GemsFarming
for task in tasks:
if task not in GEMS_FARMINGS:
continue
name = self.config.cross_get(keys=f'{task}.Campaign.Name', default='2-4')
if not self.stage_is_main(name):
logger.info(f'Reset GemsFarming to 2-4')
Expand All @@ -50,7 +54,7 @@ def event_pt_limit_triggered(self):
command = self.config.Scheduler_Command
if limit <= 0 or command not in tasks:
return False
if command == 'GemsFarming' and self.stage_is_main(self.config.Campaign_Name):
if command in GEMS_FARMINGS and self.stage_is_main(self.config.Campaign_Name):
return False

pt = self.get_event_pt()
Expand All @@ -75,7 +79,7 @@ def event_time_limit_triggered(self):
command = self.config.Scheduler_Command
if command not in tasks or limit == DEFAULT_TIME:
return False
if command == 'GemsFarming' and self.stage_is_main(self.config.Campaign_Name):
if command in GEMS_FARMINGS and self.stage_is_main(self.config.Campaign_Name):
return False

now = datetime.now().replace(microsecond=0)
Expand Down Expand Up @@ -128,7 +132,7 @@ def is_event_entrance_available(self):
"""
if self.appear(CAMPAIGN_MENU_NO_EVENT, offset=(20, 20)):
logger.info('Event unavailable, disable task')
tasks = EVENTS + COALITIONS + GEMS_FARMINGS
tasks = EVENTS + RAIDS + COALITIONS + GEMS_FARMINGS
self._disable_tasks(tasks)
self.config.task_stop()
else:
Expand Down Expand Up @@ -177,6 +181,26 @@ def ui_goto_coalition(self):
self.ui_goto(page_coalition)
return True

def disable_raid_on_event(self):
"""
Disable raid tasks (or coalition) when entered an event,
to be foolproof if user forgot to disable raid tasks when raid is over and another event is ongoing
"""
command = self.config.Scheduler_Command
if command not in EVENTS + GEMS_FARMINGS:
return False
if command in GEMS_FARMINGS and self.stage_is_main(self.config.Campaign_Name):
return False

tasks = RAIDS + COALITIONS + MARITIME_ESCORTS
tasks = [t for t in tasks if self.config.is_task_enabled(t)]
if tasks:
logger.info('New event ongoing, disable old event tasks')
self._disable_tasks(tasks)
return True
else:
return False

@staticmethod
def stage_is_main(name) -> bool:
"""
Expand Down
1 change: 1 addition & 0 deletions module/campaign/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def run(self, name, folder='campaign_main', mode='normal', total=0):
self.campaign.ensure_campaign_ui(name=self.stage, mode=mode)
else:
self.campaign.ensure_campaign_ui(name=self.stage, mode=mode)
self.disable_raid_on_event()
self.handle_commission_notice()

# if in hard mode, check remain times
Expand Down
32 changes: 16 additions & 16 deletions module/config/argument/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -1716,12 +1716,12 @@
"display": "hide",
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -2058,12 +2058,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -2515,12 +2515,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -3936,12 +3936,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -4410,12 +4410,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -4884,12 +4884,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -5358,12 +5358,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down Expand Up @@ -5822,12 +5822,12 @@
],
"option_bold": [
"event_20220818_cn",
"event_20231221_cn"
"event_20240815_cn"
],
"cn": "event_20220818_cn",
"en": "event_20220818_cn",
"jp": "event_20220818_cn",
"tw": "event_20231221_cn"
"tw": "event_20240815_cn"
},
"Mode": {
"type": "select",
Expand Down
2 changes: 1 addition & 1 deletion module/config/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@
"event_20240425_cn": "共鳴的PASSION",
"event_20240521_cn": "Light of the Martyrium",
"event_20240725_cn": "Interlude of Illusions",
"event_20240815_cn": "Windborne Steel Wings",
"event_20240815_cn": "鐵翼擎風",
"event_20240829_cn": "埋葬於彼岸之花",
"event_20240912_cn": "Ode of Everblooming Crimson",
"event_20241024_cn": "Tempesta and the Sleeping Sea",
Expand Down
6 changes: 6 additions & 0 deletions module/handler/info_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ def handle_urgent_commission(self, drop=None):
if not self.device.app_is_running():
logger.error('Detected hot fixes from game server, game died')
raise GameNotRunningError
if self.match_template_color(LOGIN_CHECK, offset=(30, 30)):
logger.error('Account logged out, '
'probably because account kicked by server maintenance or another log in')
# Kill game, because game patches after maintenance can only be downloaded at game startup
self.device.app_stop()
raise GameNotRunningError
self._hot_fix_check_wait.clear()

return appear
Expand Down

0 comments on commit 8510912

Please sign in to comment.