Refactor: Abstract chapter switches from 20240725 to 20241219

This commit is contained in:
LmeSzinc 2024-12-20 21:07:58 +08:00
parent a3bb25a95d
commit cc2cf0d046
27 changed files with 151 additions and 119 deletions

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -1,11 +1,4 @@
from module.campaign.assets import SWITCH_20240725_COMBAT, SWITCH_20240725_STORY
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.campaign.campaign_ui import ModeSwitch
from module.logger import logger
MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', offset=(30, 30))
MODE_SWITCH_20240725.add_state('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_state('story', SWITCH_20240725_STORY)
class CampaignBase(CampaignBase_):
@ -20,9 +13,4 @@ class CampaignBase(CampaignBase_):
if mode == 'hard':
self.config.override(Campaign_Mode='hard')
if mode in ['normal', 'hard', 'ex']:
MODE_SWITCH_20240725.set('combat', main=self)
elif mode in ['story']:
MODE_SWITCH_20240725.set('story', main=self)
else:
logger.warning(f'Unknown campaign mode: {mode}')
self.campaign_ensure_mode_20241219(mode)

View File

@ -1,11 +1,5 @@
from module.campaign.assets import SWITCH_20240725_COMBAT, SWITCH_20240725_STORY
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.campaign.campaign_ui import ModeSwitch
from module.logger import logger
MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', offset=(30, 30))
MODE_SWITCH_20240725.add_state('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_state('story', SWITCH_20240725_STORY)
from module.campaign.campaign_base import CampaignBase as CampaignBase_
class CampaignBase(CampaignBase_):
@ -20,12 +14,7 @@ class CampaignBase(CampaignBase_):
if mode == 'hard':
self.config.override(Campaign_Mode='hard')
if mode in ['normal', 'hard', 'ex']:
MODE_SWITCH_20240725.set('combat', main=self)
elif mode in ['story']:
MODE_SWITCH_20240725.set('story', main=self)
else:
logger.warning(f'Unknown campaign mode: {mode}')
self.campaign_ensure_mode_20241219(mode)
@staticmethod
def _campaign_separate_name(name):

View File

@ -1,12 +1,11 @@
from module.campaign.assets import SWITCH_20240725_COMBAT, SWITCH_20240725_STORY
from module.campaign.assets import SWITCH_20241219_COMBAT, SWITCH_20241219_STORY
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.campaign.campaign_ui import ModeSwitch
from module.ui.ui import page_event
MODE_SWITCH_20240912 = ModeSwitch('Mode_switch_20240912', is_selector=True, offset=(30, 30))
MODE_SWITCH_20240912.add_state('combat', SWITCH_20240725_COMBAT, offset=(444, 4))
MODE_SWITCH_20240912.add_state('story', SWITCH_20240725_STORY, offset=(444, 4))
MODE_SWITCH_20240912 = ModeSwitch('Mode_switch_20240912', is_selector=True)
MODE_SWITCH_20240912.add_state('combat', SWITCH_20241219_COMBAT, offset=(444, 4))
MODE_SWITCH_20240912.add_state('story', SWITCH_20241219_STORY, offset=(444, 4))
class CampaignBase(CampaignBase_):
@ -18,6 +17,9 @@ class CampaignBase(CampaignBase_):
Returns:
bool: If mode changed.
"""
# event_20240912_cn has two mode switches at bottom
# The classic one, MODE_SWITCH_* is at bottom-left,
# and MODE_SWITCH_20240912 is at bottom-middle
if mode == "story":
MODE_SWITCH_20240912.set('story', main=self)
elif mode in ['normal', 'hard', 'ex']:

View File

@ -1,21 +1,10 @@
from module.base.utils import color_similarity_2d
from module.campaign.assets import *
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.campaign.campaign_ui import ModeSwitch
from module.campaign.campaign_ui import ASIDE_SWITCH_20241219, MODE_SWITCH_20241219
from module.logger import logger
from module.map_detection.grid import Grid
from module.template.assets import TEMPLATE_ENEMY_BOSS
MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', is_selector=True, offset=(30, 30))
MODE_SWITCH_20240725.add_state('combat', SWITCH_20240725_COMBAT, offset=(444, 4))
MODE_SWITCH_20240725.add_state('story', SWITCH_20240725_STORY, offset=(444, 4))
CHAPTER_SWITCH_20241024 = ModeSwitch('Chapter_switch_20241024', is_selector=True, offset=(30, 30))
CHAPTER_SWITCH_20241024.add_state('ab', CHAPTER_20241024_AB)
CHAPTER_SWITCH_20241024.add_state('cd', CHAPTER_20241024_CD)
CHAPTER_SWITCH_20241024.add_state('sp', CHAPTER_20241024_SP)
CHAPTER_SWITCH_20241024.add_state('ex', CHAPTER_20241024_EX)
class EventGrid(Grid):
def predict_enemy_genre(self):
@ -43,33 +32,16 @@ class CampaignBase(CampaignBase_):
"""
]
def campaign_set_chapter(self, name, mode='normal'):
"""
Args:
name (str): Campaign name, such as '7-2', 'd3', 'sp3'.
mode (str): 'normal' or 'hard'.
"""
chapter, stage = self._campaign_separate_name(name)
if chapter in ['t']:
def campaign_set_chapter_20241219(self, chapter, stage, mode='combat'):
if chapter == 't':
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
MODE_SWITCH_20241219.set('combat', main=self)
if stage in ['1', '2', '3']:
CHAPTER_SWITCH_20241024.set('ab', main=self)
ASIDE_SWITCH_20241219.set('part1', main=self)
elif stage in ['4', '5', '6']:
CHAPTER_SWITCH_20241024.set('cd', main=self)
ASIDE_SWITCH_20241219.set('part2', main=self)
else:
logger.warning(f'Stage {name} is not in CHAPTER_SWITCH_20241024')
logger.warning(f'Stage {chapter}{stage} is not in event_20241024')
self.campaign_ensure_chapter(index=chapter)
elif chapter in ['ex_sp']:
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
CHAPTER_SWITCH_20241024.set('sp', main=self)
self.campaign_ensure_chapter(index=chapter)
elif chapter in ['ex_ex']:
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
CHAPTER_SWITCH_20241024.set('ex', main=self)
self.campaign_ensure_chapter(index=chapter)
else:
logger.warning(f'Unknown campaign chapter: {name}')
return super().campaign_set_chapter_20241219(chapter, stage, mode)

View File

@ -49,6 +49,7 @@ class Config:
# ===== End of generated config =====
STAGE_ENTRANCE = ['half', '20240725']
MAP_CHAPTER_SWITCH_20241219 = True
HOMO_STORAGE = ((10, 5), [(152.845, 95.044), (1264.11, 95.044), (28.172, 525.208), (1419.191, 525.208)])
HOMO_EDGE_COLOR_RANGE = (0, 33)
HOMO_EDGE_HOUGHLINES_THRESHOLD = 120

View File

@ -58,6 +58,7 @@ class Config:
# ===== End of generated config =====
STAGE_ENTRANCE = ['half', '20240725']
MAP_CHAPTER_SWITCH_20241219 = True
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
'height': (80, 255 - 33),
'width': (0.9, 10),

View File

@ -1,6 +1,5 @@
from campaign.event_20241024_cn.campaign_base import CHAPTER_SWITCH_20241024, MODE_SWITCH_20240725
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.logger import logger
from module.campaign.campaign_ui import MODE_SWITCH_20241219, ASIDE_SWITCH_20241219
class CampaignBase(CampaignBase_):
@ -22,41 +21,16 @@ class CampaignBase(CampaignBase_):
return 1
return CampaignBase_._campaign_get_chapter_index(name)
def campaign_set_chapter(self, name, mode='normal'):
"""
Args:
name (str): Campaign name, such as '7-2', 'd3', 'sp3'.
mode (str): 'normal' or 'hard'.
"""
chapter, stage = self._campaign_separate_name(name)
logger.info([chapter, stage])
def campaign_set_chapter_20241219(self, chapter, stage, mode='combat'):
if chapter == 't':
self.ui_goto_event()
MODE_SWITCH_20241219.set('combat', main=self)
ASIDE_SWITCH_20241219.set('part1', main=self)
self.campaign_ensure_chapter(index=chapter)
if chapter == 'ttl':
self.ui_goto_event()
MODE_SWITCH_20241219.set('combat', main=self)
ASIDE_SWITCH_20241219.set('part2', main=self)
self.campaign_ensure_chapter(index=chapter)
if chapter in ['t']:
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
if stage in ['1', '2', '3', '4', '5']:
CHAPTER_SWITCH_20241024.set('ab', main=self)
else:
logger.warning(f'Stage {name} is not in CHAPTER_SWITCH_20241024')
self.campaign_ensure_chapter(index=chapter)
elif chapter in ['ttl']:
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
if stage in ['1', '2', '3', '4', '5']:
CHAPTER_SWITCH_20241024.set('cd', main=self)
else:
logger.warning(f'Stage {name} is not in CHAPTER_SWITCH_20241024')
logger.info('campaign_ensure_chapter')
self.campaign_ensure_chapter(index=chapter)
elif chapter in ['ex_sp']:
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
CHAPTER_SWITCH_20241024.set('sp', main=self)
self.campaign_ensure_chapter(index=chapter)
elif chapter in ['ex_ex']:
self.ui_goto_event()
MODE_SWITCH_20240725.set('combat', main=self)
CHAPTER_SWITCH_20241024.set('ex', main=self)
self.campaign_ensure_chapter(index=chapter)
else:
logger.warning(f'Unknown campaign chapter: {name}')
return super().campaign_set_chapter_20241219(chapter, stage, mode)

View File

@ -58,6 +58,7 @@ class Config:
# ===== End of generated config =====
STAGE_ENTRANCE = ['half', '20240725']
MAP_CHAPTER_SWITCH_20241219 = True
MAP_IS_ONE_TIME_STAGE = True
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
'height': (80, 255 - 33),

View File

@ -58,6 +58,7 @@ class Config:
# ===== End of generated config =====
STAGE_ENTRANCE = ['half', '20240725']
MAP_CHAPTER_SWITCH_20241219 = True
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
'height': (80, 255 - 33),
'width': (0.9, 10),

View File

@ -45,6 +45,7 @@ class Config:
# ===== End of generated config =====
STAGE_ENTRANCE = ['half', '20240725']
MAP_CHAPTER_SWITCH_20241219 = True
MAP_IS_ONE_TIME_STAGE = True
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
'height': (80, 255 - 33),

View File

@ -0,0 +1,9 @@
from module.campaign.campaign_base import CampaignBase as CampaignBase_
class CampaignBase(CampaignBase_):
STAGE_INCREASE = [
'A1 > A2 > A3 > B1 > B2 > B3',
'C1 > C2 > C3',
'D1 > D2 > D3',
]

View File

@ -4,10 +4,10 @@ from module.base.template import Template
# This file was automatically generated by dev_tools/button_extract.py.
# Don't modify it manually.
CHAPTER_20241024_AB = Button(area={'cn': (17, 226, 34, 241), 'en': (17, 226, 34, 241), 'jp': (17, 226, 34, 241), 'tw': (17, 226, 34, 241)}, color={'cn': (162, 169, 196), 'en': (162, 169, 196), 'jp': (162, 169, 196), 'tw': (162, 169, 196)}, button={'cn': (17, 226, 34, 241), 'en': (17, 226, 34, 241), 'jp': (17, 226, 34, 241), 'tw': (17, 226, 34, 241)}, file={'cn': './assets/cn/campaign/CHAPTER_20241024_AB.png', 'en': './assets/cn/campaign/CHAPTER_20241024_AB.png', 'jp': './assets/cn/campaign/CHAPTER_20241024_AB.png', 'tw': './assets/cn/campaign/CHAPTER_20241024_AB.png'})
CHAPTER_20241024_CD = Button(area={'cn': (17, 299, 34, 314), 'en': (17, 299, 34, 314), 'jp': (17, 299, 34, 314), 'tw': (17, 299, 34, 314)}, color={'cn': (168, 176, 204), 'en': (168, 176, 204), 'jp': (168, 176, 204), 'tw': (168, 176, 204)}, button={'cn': (17, 299, 34, 314), 'en': (17, 299, 34, 314), 'jp': (17, 299, 34, 314), 'tw': (17, 299, 34, 314)}, file={'cn': './assets/cn/campaign/CHAPTER_20241024_CD.png', 'en': './assets/cn/campaign/CHAPTER_20241024_CD.png', 'jp': './assets/cn/campaign/CHAPTER_20241024_CD.png', 'tw': './assets/cn/campaign/CHAPTER_20241024_CD.png'})
CHAPTER_20241024_EX = Button(area={'cn': (17, 446, 34, 461), 'en': (17, 446, 34, 461), 'jp': (17, 446, 34, 461), 'tw': (17, 446, 34, 461)}, color={'cn': (169, 178, 207), 'en': (169, 178, 207), 'jp': (169, 178, 207), 'tw': (169, 178, 207)}, button={'cn': (17, 446, 34, 461), 'en': (17, 446, 34, 461), 'jp': (17, 446, 34, 461), 'tw': (17, 446, 34, 461)}, file={'cn': './assets/cn/campaign/CHAPTER_20241024_EX.png', 'en': './assets/cn/campaign/CHAPTER_20241024_EX.png', 'jp': './assets/cn/campaign/CHAPTER_20241024_EX.png', 'tw': './assets/cn/campaign/CHAPTER_20241024_EX.png'})
CHAPTER_20241024_SP = Button(area={'cn': (17, 372, 34, 388), 'en': (17, 372, 34, 388), 'jp': (17, 372, 34, 388), 'tw': (17, 372, 34, 388)}, color={'cn': (163, 172, 201), 'en': (163, 172, 201), 'jp': (163, 172, 201), 'tw': (163, 172, 201)}, button={'cn': (17, 372, 34, 388), 'en': (17, 372, 34, 388), 'jp': (17, 372, 34, 388), 'tw': (17, 372, 34, 388)}, file={'cn': './assets/cn/campaign/CHAPTER_20241024_SP.png', 'en': './assets/cn/campaign/CHAPTER_20241024_SP.png', 'jp': './assets/cn/campaign/CHAPTER_20241024_SP.png', 'tw': './assets/cn/campaign/CHAPTER_20241024_SP.png'})
CHAPTER_20241219_EX = Button(area={'cn': (17, 446, 34, 461), 'en': (17, 446, 34, 461), 'jp': (17, 446, 34, 461), 'tw': (17, 446, 34, 461)}, color={'cn': (169, 178, 207), 'en': (169, 178, 207), 'jp': (169, 178, 207), 'tw': (169, 178, 207)}, button={'cn': (17, 446, 34, 461), 'en': (17, 446, 34, 461), 'jp': (17, 446, 34, 461), 'tw': (17, 446, 34, 461)}, file={'cn': './assets/cn/campaign/CHAPTER_20241219_EX.png', 'en': './assets/cn/campaign/CHAPTER_20241219_EX.png', 'jp': './assets/cn/campaign/CHAPTER_20241219_EX.png', 'tw': './assets/cn/campaign/CHAPTER_20241219_EX.png'})
CHAPTER_20241219_PART1 = Button(area={'cn': (17, 226, 34, 241), 'en': (17, 226, 34, 241), 'jp': (17, 226, 34, 241), 'tw': (17, 226, 34, 241)}, color={'cn': (162, 169, 196), 'en': (162, 169, 196), 'jp': (162, 169, 196), 'tw': (162, 169, 196)}, button={'cn': (17, 226, 34, 241), 'en': (17, 226, 34, 241), 'jp': (17, 226, 34, 241), 'tw': (17, 226, 34, 241)}, file={'cn': './assets/cn/campaign/CHAPTER_20241219_PART1.png', 'en': './assets/cn/campaign/CHAPTER_20241219_PART1.png', 'jp': './assets/cn/campaign/CHAPTER_20241219_PART1.png', 'tw': './assets/cn/campaign/CHAPTER_20241219_PART1.png'})
CHAPTER_20241219_PART2 = Button(area={'cn': (17, 299, 34, 314), 'en': (17, 299, 34, 314), 'jp': (17, 299, 34, 314), 'tw': (17, 299, 34, 314)}, color={'cn': (168, 176, 204), 'en': (168, 176, 204), 'jp': (168, 176, 204), 'tw': (168, 176, 204)}, button={'cn': (17, 299, 34, 314), 'en': (17, 299, 34, 314), 'jp': (17, 299, 34, 314), 'tw': (17, 299, 34, 314)}, file={'cn': './assets/cn/campaign/CHAPTER_20241219_PART2.png', 'en': './assets/cn/campaign/CHAPTER_20241219_PART2.png', 'jp': './assets/cn/campaign/CHAPTER_20241219_PART2.png', 'tw': './assets/cn/campaign/CHAPTER_20241219_PART2.png'})
CHAPTER_20241219_SP = Button(area={'cn': (17, 372, 34, 388), 'en': (17, 372, 34, 388), 'jp': (17, 372, 34, 388), 'tw': (17, 372, 34, 388)}, color={'cn': (163, 172, 201), 'en': (163, 172, 201), 'jp': (163, 172, 201), 'tw': (163, 172, 201)}, button={'cn': (17, 372, 34, 388), 'en': (17, 372, 34, 388), 'jp': (17, 372, 34, 388), 'tw': (17, 372, 34, 388)}, file={'cn': './assets/cn/campaign/CHAPTER_20241219_SP.png', 'en': './assets/cn/campaign/CHAPTER_20241219_SP.png', 'jp': './assets/cn/campaign/CHAPTER_20241219_SP.png', 'tw': './assets/cn/campaign/CHAPTER_20241219_SP.png'})
CHAPTER_NEXT = Button(area={'cn': (1216, 362, 1232, 388), 'en': (1216, 362, 1232, 388), 'jp': (1216, 362, 1232, 388), 'tw': (1216, 362, 1232, 388)}, color={'cn': (121, 150, 198), 'en': (121, 150, 198), 'jp': (121, 150, 198), 'tw': (121, 150, 198)}, button={'cn': (1216, 362, 1232, 388), 'en': (1216, 362, 1232, 388), 'jp': (1216, 362, 1232, 388), 'tw': (1216, 362, 1232, 388)}, file={'cn': './assets/cn/campaign/CHAPTER_NEXT.png', 'en': './assets/en/campaign/CHAPTER_NEXT.png', 'jp': './assets/jp/campaign/CHAPTER_NEXT.png', 'tw': './assets/tw/campaign/CHAPTER_NEXT.png'})
CHAPTER_PREV = Button(area={'cn': (42, 360, 58, 387), 'en': (42, 360, 58, 387), 'jp': (42, 360, 58, 387), 'tw': (42, 360, 58, 387)}, color={'cn': (105, 133, 169), 'en': (105, 133, 169), 'jp': (105, 133, 169), 'tw': (105, 133, 169)}, button={'cn': (42, 360, 58, 387), 'en': (42, 360, 58, 387), 'jp': (42, 360, 58, 387), 'tw': (42, 360, 58, 387)}, file={'cn': './assets/cn/campaign/CHAPTER_PREV.png', 'en': './assets/en/campaign/CHAPTER_PREV.png', 'jp': './assets/jp/campaign/CHAPTER_PREV.png', 'tw': './assets/tw/campaign/CHAPTER_PREV.png'})
COMMISSION_NOTICE_AT_CAMPAIGN = Button(area={'cn': (1077, 637, 1083, 643), 'en': (1077, 637, 1083, 643), 'jp': (1077, 637, 1083, 643), 'tw': (1077, 637, 1083, 643)}, color={'cn': (172, 72, 49), 'en': (172, 72, 49), 'jp': (172, 72, 49), 'tw': (172, 72, 49)}, button={'cn': (1077, 637, 1083, 643), 'en': (1077, 637, 1083, 643), 'jp': (1077, 637, 1083, 643), 'tw': (1077, 637, 1083, 643)}, file={'cn': './assets/cn/campaign/COMMISSION_NOTICE_AT_CAMPAIGN.png', 'en': './assets/en/campaign/COMMISSION_NOTICE_AT_CAMPAIGN.png', 'jp': './assets/jp/campaign/COMMISSION_NOTICE_AT_CAMPAIGN.png', 'tw': './assets/tw/campaign/COMMISSION_NOTICE_AT_CAMPAIGN.png'})
@ -18,8 +18,8 @@ OCR_OIL = Button(area={'cn': (614, 23, 714, 51), 'en': (614, 23, 714, 51), 'jp':
OCR_OIL_CHECK = Button(area={'cn': (573, 30, 592, 49), 'en': (573, 30, 592, 49), 'jp': (573, 30, 592, 49), 'tw': (573, 30, 592, 49)}, color={'cn': (82, 82, 82), 'en': (82, 82, 82), 'jp': (82, 82, 82), 'tw': (82, 82, 82)}, button={'cn': (573, 30, 592, 49), 'en': (573, 30, 592, 49), 'jp': (573, 30, 592, 49), 'tw': (573, 30, 592, 49)}, file={'cn': './assets/cn/campaign/OCR_OIL_CHECK.png', 'en': './assets/en/campaign/OCR_OIL_CHECK.png', 'jp': './assets/jp/campaign/OCR_OIL_CHECK.png', 'tw': './assets/tw/campaign/OCR_OIL_CHECK.png'})
SWITCH_1_HARD = Button(area={'cn': (82, 641, 148, 675), 'en': (87, 642, 148, 676), 'jp': (24, 645, 150, 697), 'tw': (82, 641, 148, 675)}, color={'cn': (233, 141, 128), 'en': (234, 139, 124), 'jp': (219, 116, 106), 'tw': (236, 159, 148)}, button={'cn': (82, 641, 148, 675), 'en': (87, 642, 148, 676), 'jp': (24, 645, 150, 697), 'tw': (82, 641, 148, 675)}, file={'cn': './assets/cn/campaign/SWITCH_1_HARD.png', 'en': './assets/en/campaign/SWITCH_1_HARD.png', 'jp': './assets/jp/campaign/SWITCH_1_HARD.png', 'tw': './assets/tw/campaign/SWITCH_1_HARD.png'})
SWITCH_1_NORMAL = Button(area={'cn': (80, 641, 148, 675), 'en': (79, 638, 147, 675), 'jp': (24, 644, 150, 697), 'tw': (79, 641, 148, 675)}, color={'cn': (157, 180, 227), 'en': (157, 180, 227), 'jp': (143, 169, 222), 'tw': (156, 179, 227)}, button={'cn': (80, 641, 148, 675), 'en': (79, 638, 147, 675), 'jp': (24, 644, 150, 697), 'tw': (79, 641, 148, 675)}, file={'cn': './assets/cn/campaign/SWITCH_1_NORMAL.png', 'en': './assets/en/campaign/SWITCH_1_NORMAL.png', 'jp': './assets/jp/campaign/SWITCH_1_NORMAL.png', 'tw': './assets/tw/campaign/SWITCH_1_NORMAL.png'})
SWITCH_20240725_COMBAT = Button(area={'cn': (39, 659, 71, 691), 'en': (39, 659, 71, 691), 'jp': (39, 659, 71, 691), 'tw': (39, 659, 71, 691)}, color={'cn': (133, 96, 49), 'en': (133, 96, 49), 'jp': (133, 96, 49), 'tw': (133, 96, 49)}, button={'cn': (39, 659, 71, 691), 'en': (39, 659, 71, 691), 'jp': (39, 659, 71, 691), 'tw': (39, 659, 71, 691)}, file={'cn': './assets/cn/campaign/SWITCH_20240725_COMBAT.png', 'en': './assets/en/campaign/SWITCH_20240725_COMBAT.png', 'jp': './assets/jp/campaign/SWITCH_20240725_COMBAT.png', 'tw': './assets/tw/campaign/SWITCH_20240725_COMBAT.png'})
SWITCH_20240725_STORY = Button(area={'cn': (327, 657, 352, 688), 'en': (327, 657, 352, 688), 'jp': (327, 657, 352, 688), 'tw': (327, 657, 352, 688)}, color={'cn': (105, 77, 31), 'en': (105, 77, 31), 'jp': (105, 77, 31), 'tw': (105, 77, 31)}, button={'cn': (327, 657, 352, 688), 'en': (327, 657, 352, 688), 'jp': (327, 657, 352, 688), 'tw': (327, 657, 352, 688)}, file={'cn': './assets/cn/campaign/SWITCH_20240725_STORY.png', 'en': './assets/en/campaign/SWITCH_20240725_STORY.png', 'jp': './assets/jp/campaign/SWITCH_20240725_STORY.png', 'tw': './assets/tw/campaign/SWITCH_20240725_STORY.png'})
SWITCH_20241219_COMBAT = Button(area={'cn': (39, 659, 71, 691), 'en': (39, 659, 71, 691), 'jp': (39, 659, 71, 691), 'tw': (39, 659, 71, 691)}, color={'cn': (133, 96, 49), 'en': (133, 96, 49), 'jp': (133, 96, 49), 'tw': (133, 96, 49)}, button={'cn': (39, 659, 71, 691), 'en': (39, 659, 71, 691), 'jp': (39, 659, 71, 691), 'tw': (39, 659, 71, 691)}, file={'cn': './assets/cn/campaign/SWITCH_20241219_COMBAT.png', 'en': './assets/cn/campaign/SWITCH_20241219_COMBAT.png', 'jp': './assets/cn/campaign/SWITCH_20241219_COMBAT.png', 'tw': './assets/cn/campaign/SWITCH_20241219_COMBAT.png'})
SWITCH_20241219_STORY = Button(area={'cn': (327, 657, 352, 688), 'en': (327, 657, 352, 688), 'jp': (327, 657, 352, 688), 'tw': (327, 657, 352, 688)}, color={'cn': (105, 77, 31), 'en': (105, 77, 31), 'jp': (105, 77, 31), 'tw': (105, 77, 31)}, button={'cn': (327, 657, 352, 688), 'en': (327, 657, 352, 688), 'jp': (327, 657, 352, 688), 'tw': (327, 657, 352, 688)}, file={'cn': './assets/cn/campaign/SWITCH_20241219_STORY.png', 'en': './assets/cn/campaign/SWITCH_20241219_STORY.png', 'jp': './assets/cn/campaign/SWITCH_20241219_STORY.png', 'tw': './assets/cn/campaign/SWITCH_20241219_STORY.png'})
SWITCH_2_EX = Button(area={'cn': (272, 658, 310, 676), 'en': (251, 644, 313, 697), 'jp': (186, 638, 314, 692), 'tw': (241, 640, 312, 692)}, color={'cn': (253, 168, 98), 'en': (254, 163, 80), 'jp': (205, 136, 64), 'tw': (254, 161, 72)}, button={'cn': (272, 658, 310, 676), 'en': (251, 644, 313, 697), 'jp': (186, 638, 314, 692), 'tw': (241, 640, 312, 692)}, file={'cn': './assets/cn/campaign/SWITCH_2_EX.png', 'en': './assets/en/campaign/SWITCH_2_EX.png', 'jp': './assets/jp/campaign/SWITCH_2_EX.png', 'tw': './assets/tw/campaign/SWITCH_2_EX.png'})
SWITCH_2_HARD = Button(area={'cn': (246, 641, 311, 675), 'en': (244, 640, 312, 684), 'jp': (233, 655, 310, 681), 'tw': (245, 641, 311, 674)}, color={'cn': (233, 140, 127), 'en': (228, 121, 106), 'jp': (223, 110, 96), 'tw': (237, 161, 150)}, button={'cn': (246, 641, 311, 675), 'en': (244, 640, 312, 684), 'jp': (233, 655, 310, 681), 'tw': (245, 641, 311, 674)}, file={'cn': './assets/cn/campaign/SWITCH_2_HARD.png', 'en': './assets/en/campaign/SWITCH_2_HARD.png', 'jp': './assets/jp/campaign/SWITCH_2_HARD.png', 'tw': './assets/tw/campaign/SWITCH_2_HARD.png'})
TEMPLATE_EVENT_20230817_STORY_E1 = Template(file={'cn': './assets/cn/campaign/TEMPLATE_EVENT_20230817_STORY_E1.png', 'en': './assets/en/campaign/TEMPLATE_EVENT_20230817_STORY_E1.png', 'jp': './assets/jp/campaign/TEMPLATE_EVENT_20230817_STORY_E1.png', 'tw': './assets/tw/campaign/TEMPLATE_EVENT_20230817_STORY_E1.png'})

View File

@ -24,6 +24,17 @@ MODE_SWITCH_2 = ModeSwitch('Mode_switch_2', offset=(30, 10))
MODE_SWITCH_2.add_state('hard', SWITCH_2_HARD)
MODE_SWITCH_2.add_state('ex', SWITCH_2_EX)
# Event mode switches changing from 20240725 to 20241219
# I think it stable at 20241219, so give them names with date 20241219
MODE_SWITCH_20241219 = ModeSwitch('Mode_switch_20241219', is_selector=True, offset=(30, 30))
MODE_SWITCH_20241219.add_state('combat', SWITCH_20241219_COMBAT)
MODE_SWITCH_20241219.add_state('story', SWITCH_20241219_STORY)
ASIDE_SWITCH_20241219 = ModeSwitch('Aside_switch_20241219', is_selector=True, offset=(30, 30))
ASIDE_SWITCH_20241219.add_state('part1', CHAPTER_20241219_PART1)
ASIDE_SWITCH_20241219.add_state('part2', CHAPTER_20241219_PART2)
ASIDE_SWITCH_20241219.add_state('sp', CHAPTER_20241219_SP)
ASIDE_SWITCH_20241219.add_state('ex', CHAPTER_20241219_EX)
class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
ENTRANCE = Button(area=(), color=(), button=(), name='default_button')
@ -83,9 +94,6 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
"""
Args:
mode (str): 'normal', 'hard', 'ex'
Returns:
bool: If mode changed.
"""
if mode == 'hard':
self.config.override(Campaign_Mode='hard')
@ -113,6 +121,34 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
else:
logger.warning(f'Unknown campaign mode: {mode}')
def campaign_ensure_mode_20241219(self, mode='combat'):
"""
Args:
mode (str): 'combat' or 'story'
"""
if mode in ['normal', 'hard', 'ex', 'combat']:
MODE_SWITCH_20241219.set('combat', main=self)
elif mode in ['story']:
MODE_SWITCH_20241219.set('story', main=self)
else:
logger.warning(f'Unknown campaign mode: {mode}')
def campaign_ensure_aside_20241219(self, chapter):
"""
Args:
chapter: 'part1', 'part2', 'sp', 'ex'
"""
if chapter in ['part1', 'a', 'c', 't']:
MODE_SWITCH_20241219.set('part1', main=self)
elif chapter in ['part2', 'b', 'd']:
MODE_SWITCH_20241219.set('part2', main=self)
elif chapter in ['sp', 'ex_sp']:
MODE_SWITCH_20241219.set('sp', main=self)
elif chapter in ['ex', 'ex_ex']:
MODE_SWITCH_20241219.set('sp', main=self)
else:
logger.warning(f'Unknown campaign aside: {chapter}')
def campaign_get_mode_names(self, name):
"""
Get stage names in both 'normal' and 'hard'
@ -136,6 +172,22 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
return [f'b{name[1:]}', f'd{name[1:]}']
return [name]
def _campaign_name_is_hard(self, name):
"""
Reuse manual defination in campaign_get_mode_names()
Args:
name: 'a1', 'ht1', 'sp1'
Returns:
bool: If stage is hard mode
"""
mode_names = self.campaign_get_mode_names(name)
if len(mode_names) == 2 and mode_names[1] == name:
return True
else:
return False
def campaign_get_entrance(self, name):
"""
Args:
@ -145,7 +197,7 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
Button:
"""
entrance_name = name
if self.config.MAP_HAS_MODE_SWITCH:
if self.config.MAP_HAS_MODE_SWITCH or self.config.MAP_CHAPTER_SWITCH_20241219:
for mode_name in self.campaign_get_mode_names(name):
if mode_name in self.stage_entrance:
name = mode_name
@ -195,16 +247,55 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
else:
return False
def campaign_set_chapter_20241219(self, chapter, stage, mode='combat'):
if not self.config.MAP_CHAPTER_SWITCH_20241219:
return False
if self._campaign_name_is_hard(f'{chapter}{stage}'):
self.config.override(Campaign_Mode='hard')
if mode == 'story':
MODE_SWITCH_20241219.set('story', main=self)
return True
if chapter in ['a', 'c', 't']:
self.ui_goto_event()
MODE_SWITCH_20241219.set('combat', main=self)
ASIDE_SWITCH_20241219.set('part1', main=self)
self.campaign_ensure_chapter(index=chapter)
return True
if chapter in ['b', 'd', 'ttl']:
self.ui_goto_event()
MODE_SWITCH_20241219.set('combat', main=self)
ASIDE_SWITCH_20241219.set('part2', main=self)
self.campaign_ensure_chapter(index=chapter)
return True
if chapter in ['ex_sp']:
self.ui_goto_event()
MODE_SWITCH_20241219.set('combat', main=self)
ASIDE_SWITCH_20241219.set('sp', main=self)
self.campaign_ensure_chapter(index=chapter)
return True
if chapter in ['ex_ex']:
self.ui_goto_event()
MODE_SWITCH_20241219.set('combat', main=self)
ASIDE_SWITCH_20241219.set('ex', main=self)
self.campaign_ensure_chapter(index=chapter)
return True
else:
return False
def campaign_set_chapter(self, name, mode='normal'):
"""
Args:
name (str): Campaign name, such as '7-2', 'd3', 'sp3'.
mode (str): 'normal' or 'hard'.
"""
chapter, _ = self._campaign_separate_name(name)
chapter, stage = self._campaign_separate_name(name)
if self.campaign_set_chapter_main(chapter, mode):
pass
elif self.campaign_set_chapter_20241219(chapter, stage, mode):
pass
elif self.campaign_set_chapter_event(chapter, mode):
pass
elif self.campaign_set_chapter_sp(chapter, mode):

View File

@ -112,6 +112,8 @@ class ManualConfig:
module.map.fleet
"""
MAP_HAS_MODE_SWITCH = False # event_20240725_cn has mode switch in map preparation
# Events from 20240725 to 20241219 introduced new chapter switches
MAP_CHAPTER_SWITCH_20241219 = False
MAP_HAS_CLEAR_PERCENTAGE = True
MAP_HAS_WALK_SPEEDUP = False
MAP_HAS_AMBUSH = True

View File

@ -265,7 +265,7 @@ class MapOperation(MysteryHandler, FleetPreparation, Retirement, FastForwardHand
bool: If map mode satisfied
Always True if map doesn't have mode switch in map preparation
"""
if not self.config.MAP_HAS_MODE_SWITCH:
if not self.config.MAP_HAS_MODE_SWITCH and not self.config.MAP_CHAPTER_SWITCH_20241219:
return True
if mode == 'normal':