2022-11-24 22:24:20 +08:00
|
|
|
from module.campaign.campaign_base import CampaignBase as CampaignBase_
|
2022-11-25 03:44:18 +08:00
|
|
|
from module.combat.assets import GET_ITEMS_1_RYZA
|
2024-12-10 03:28:20 +08:00
|
|
|
from module.handler.fast_forward import AUTO_SEARCH
|
2022-11-25 21:40:19 +08:00
|
|
|
from module.handler.assets import MYSTERY_ITEM
|
2022-11-25 01:51:12 +08:00
|
|
|
from module.logger import logger
|
|
|
|
from module.map.map_grids import SelectedGrids
|
2022-11-24 22:24:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
class CampaignBase(CampaignBase_):
|
|
|
|
STAGE_INCREASE = [
|
|
|
|
'T1 > T2 > T3 > TS1 > T4 > T5',
|
2022-11-25 01:51:12 +08:00
|
|
|
'TH1 > TH2 > TH3 > TH4 > TH5',
|
2022-11-24 22:24:20 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
def campaign_set_chapter_event(self, chapter, mode='normal'):
|
2022-11-25 01:51:12 +08:00
|
|
|
if chapter.startswith('t'):
|
2022-11-24 22:24:20 +08:00
|
|
|
self.ui_goto_event()
|
2025-01-10 02:27:51 +08:00
|
|
|
self.campaign_ensure_chapter(chapter)
|
2022-11-24 22:24:20 +08:00
|
|
|
return True
|
|
|
|
|
|
|
|
return super().campaign_set_chapter_event(chapter, mode=mode)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _campaign_separate_name(name):
|
2022-11-25 01:51:12 +08:00
|
|
|
# T, TH, ASP, EX
|
|
|
|
if name == 'ex':
|
|
|
|
return 't4', '1'
|
2022-11-25 02:10:48 +08:00
|
|
|
if name == 'asp':
|
|
|
|
return 't3', '1'
|
2022-11-25 01:51:12 +08:00
|
|
|
if name == 'sp':
|
|
|
|
return 't3', '1'
|
2022-11-24 22:24:20 +08:00
|
|
|
if name == 'ts1':
|
2022-11-25 01:51:12 +08:00
|
|
|
return 't1', name[-1]
|
|
|
|
if name.startswith('th'):
|
|
|
|
return 't2', name[-1]
|
|
|
|
if name.startswith('t'):
|
|
|
|
return 't1', name[-1]
|
2022-11-24 22:24:20 +08:00
|
|
|
|
|
|
|
return CampaignBase_._campaign_separate_name(name)
|
2022-11-25 01:51:12 +08:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _campaign_get_chapter_index(name):
|
|
|
|
if name == 't4':
|
|
|
|
return 4
|
|
|
|
if name == 't3':
|
|
|
|
return 3
|
|
|
|
if name == 't2':
|
|
|
|
return 2
|
|
|
|
if name == 't1':
|
|
|
|
return 1
|
|
|
|
|
2022-11-25 02:10:48 +08:00
|
|
|
return CampaignBase_._campaign_get_chapter_index(name)
|
|
|
|
|
|
|
|
def campaign_get_entrance(self, name):
|
|
|
|
if name == 'sp':
|
|
|
|
name = 'asp'
|
|
|
|
return super().campaign_get_entrance(name)
|
2022-11-25 01:51:12 +08:00
|
|
|
|
|
|
|
def map_get_info(self):
|
|
|
|
name = str(self.config.Campaign_Name).lower()
|
|
|
|
super().map_get_info()
|
|
|
|
|
|
|
|
# Chapter TH has no map_percentage and no 3_stars
|
2022-11-25 02:53:31 +08:00
|
|
|
if name.startswith('th') or name.startswith('ht'):
|
2024-12-10 03:28:20 +08:00
|
|
|
appear = AUTO_SEARCH.appear(main=self)
|
2022-11-25 02:53:31 +08:00
|
|
|
self.map_is_100_percent_clear = self.map_is_3_stars = self.map_is_threat_safe = appear
|
|
|
|
self.map_has_clear_mode = appear
|
2022-11-25 01:51:12 +08:00
|
|
|
self.map_show_info()
|
|
|
|
|
2022-11-25 03:44:18 +08:00
|
|
|
def handle_mystery_items(self, button=None, drop=None):
|
|
|
|
# Handle a different GET_ITEMS_1
|
|
|
|
if super().handle_mystery_items(button, drop=drop):
|
|
|
|
return True
|
|
|
|
if self.appear(GET_ITEMS_1_RYZA, offset=(20, 20)):
|
|
|
|
logger.attr('Mystery', 'Get item')
|
|
|
|
if drop:
|
|
|
|
drop.add(self.device.image)
|
2022-11-25 21:40:19 +08:00
|
|
|
self.device.click(MYSTERY_ITEM)
|
2022-11-25 03:44:18 +08:00
|
|
|
self.device.sleep(0.5)
|
|
|
|
self.device.screenshot()
|
|
|
|
# self.strategy_close()
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2022-11-25 01:51:12 +08:00
|
|
|
def clear_map_items(self, grids):
|
|
|
|
"""
|
|
|
|
|
|
|
|
Args:
|
|
|
|
grids (GridInfo, list[GridInfo]): Grid object or a list of them
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
"""
|
|
|
|
if not isinstance(grids, list):
|
|
|
|
grids = [grids]
|
|
|
|
grids = SelectedGrids(grids).sort('cost')
|
|
|
|
for grid in grids:
|
|
|
|
logger.hr('Clear map item')
|
|
|
|
logger.info(f'Clear map item on {grid}')
|
|
|
|
self.goto(grid)
|