Add: Empyreal Tragicomedy A1 AS1

- Dev: Fix dock extraction. Treat dock as land, because is not accessible
- Dev: Add auto use modified campaign_base
This commit is contained in:
LmeSzinc 2021-01-21 15:33:44 +08:00
parent 75aac75009
commit 4855cab4a2
4 changed files with 209 additions and 4 deletions

View File

@ -0,0 +1,68 @@
from .campaign_base import CampaignBase
from module.map.map_base import CampaignMap
from module.map.map_grids import SelectedGrids, RoadGrids
from module.logger import logger
MAP = CampaignMap('A1')
MAP.shape = 'H6'
MAP.camera_data = ['D2', 'D4', 'E2', 'E4']
MAP.camera_data_spawn_point = ['D4']
MAP.map_data = """
-- ++ -- ME -- ++ ME --
Me ++ -- MB -- Me -- --
-- -- __ ++ ++ -- -- ME
-- Me -- ME ++ -- MS ME
SP -- ME -- ME -- ++ --
SP SP -- -- -- -- MB --
"""
MAP.weight_data = """
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
"""
MAP.spawn_data = [
{'battle': 0, 'enemy': 2, 'siren': 1},
{'battle': 1, 'enemy': 1},
{'battle': 2, 'enemy': 2},
{'battle': 3, 'enemy': 1, 'boss': 1},
{'battle': 4, 'enemy': 2},
{'battle': 5, 'enemy': 1},
]
A1, B1, C1, D1, E1, F1, G1, H1, \
A2, B2, C2, D2, E2, F2, G2, H2, \
A3, B3, C3, D3, E3, F3, G3, H3, \
A4, B4, C4, D4, E4, F4, G4, H4, \
A5, B5, C5, D5, E5, F5, G5, H5, \
A6, B6, C6, D6, E6, F6, G6, H6, \
= MAP.flatten()
class Config:
# ===== Start of generated config =====
MAP_SIREN_TEMPLATE = ['CL']
MOVABLE_ENEMY_TURN = (2,)
MAP_HAS_SIREN = True
MAP_HAS_MOVABLE_ENEMY = True
MAP_HAS_MAP_STORY = False
MAP_HAS_FLEET_STEP = True
MAP_HAS_AMBUSH = False
# ===== End of generated config =====
MAP_SWIPE_MULTIPLY = 1.519
MAP_SWIPE_MULTIPLY_MINITOUCH = 1.469
class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_siren():
return True
return self.battle_default()
def battle_3(self):
return self.clear_boss()

View File

@ -0,0 +1,70 @@
from .campaign_base import CampaignBase
from module.map.map_base import CampaignMap
from module.map.map_grids import SelectedGrids, RoadGrids
from module.logger import logger
MAP = CampaignMap('AS1')
MAP.shape = 'H6'
MAP.camera_data = ['D2', 'D4', 'E2', 'E4']
MAP.camera_data_spawn_point = ['D2', 'E2']
MAP.map_data = """
-- ++ -- ME MS -- -- ME
-- ++ -- -- -- ++ ++ --
ME -- SP -- SP -- ++ Me
-- -- -- ME -- __ -- --
ME -- -- -- -- -- ME --
ME ++ MS -- MB -- MB --
"""
MAP.weight_data = """
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50
"""
MAP.spawn_data = [
{'battle': 0, 'enemy': 2, 'siren': 1},
{'battle': 1, 'enemy': 1},
{'battle': 2, 'enemy': 2},
{'battle': 3, 'enemy': 1, 'boss': 1},
{'battle': 4, 'enemy': 2},
{'battle': 5, 'enemy': 1},
]
A1, B1, C1, D1, E1, F1, G1, H1, \
A2, B2, C2, D2, E2, F2, G2, H2, \
A3, B3, C3, D3, E3, F3, G3, H3, \
A4, B4, C4, D4, E4, F4, G4, H4, \
A5, B5, C5, D5, E5, F5, G5, H5, \
A6, B6, C6, D6, E6, F6, G6, H6, \
= MAP.flatten()
class Config:
# ===== Start of generated config =====
MAP_SIREN_TEMPLATE = ['CL']
MOVABLE_ENEMY_TURN = (2,)
MAP_HAS_SIREN = True
MAP_HAS_MOVABLE_ENEMY = True
MAP_HAS_MAP_STORY = False
MAP_HAS_FLEET_STEP = True
MAP_HAS_AMBUSH = False
STAR_REQUIRE_1 = 0
STAR_REQUIRE_2 = 0
STAR_REQUIRE_3 = 0
# ===== End of generated config =====
MAP_IS_ONE_TIME_STAGE = True
class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_siren():
return True
return self.battle_default()
def battle_3(self):
return self.clear_boss()

View File

@ -0,0 +1,58 @@
from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.logger import logger
from module.exception import CampaignNameError
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, _ = self._campaign_separate_name(name)
if chapter.isdigit():
self.ui_weigh_anchor()
self.campaign_ensure_mode('normal')
self.campaign_ensure_chapter(index=chapter)
if mode == 'hard':
self.campaign_ensure_mode('hard')
self.campaign_ensure_chapter(index=chapter)
elif chapter in 'abcd' or chapter == 'ex_sp' or chapter in ['as', 'cs']:
self.ui_goto_event()
if chapter in 'ab' or chapter == 'as':
self.campaign_ensure_mode('normal')
elif chapter in 'cd' or chapter == 'cs':
self.campaign_ensure_mode('hard')
elif chapter == 'ex_sp':
self.campaign_ensure_mode('ex')
self.campaign_ensure_chapter(index=chapter)
elif chapter == 'sp':
self.ui_goto_sp()
self.campaign_ensure_chapter(index=chapter)
else:
logger.warning(f'Unknown campaign chapter: {name}')
@staticmethod
def _campaign_get_chapter_index(name):
"""
Args:
name (str, int):
Returns:
int
"""
if isinstance(name, int):
return name
else:
if name.isdigit():
return int(name)
elif name in ['a', 'c', 'sp', 'ex_sp', 'as', 'cs']:
return 1
elif name in ['b', 'd', 'ex_ex']:
return 2
else:
raise CampaignNameError

View File

@ -83,7 +83,7 @@ DIC_SIREN_NAME_CHI_TO_ENG = {
# Empyreal Tragicomedy
'teluntuo': 'Trento',
'lituoliao': 'Littorio',
'jianyu': 'swordfish', # Not siren but movable enemy
'jianyu': 'Swordfish', # Not siren but movable enemy
}
@ -120,7 +120,8 @@ class MapData:
6: 'ME',
8: 'MB',
12: 'MS',
16: '__'
16: '__',
100: '++', # Dock in Empyreal Tragicomedy
}
def __init__(self, data, data_loop):
@ -260,13 +261,18 @@ class MapData:
name = f'campaign_{name}'
return name + '.py'
def get_file_lines(self):
def get_file_lines(self, has_modified_campaign_base):
"""
Args:
has_modified_campaign_base (bool): If target folder has modified campaign_base.py
Returns:
list(str): Python code in map file.
"""
if IS_WAR_ARCHIVES:
base_import = 'from ..campaign_war_archives.campaign_base import CampaignBase'
elif has_modified_campaign_base:
base_import = 'from .campaign_base import CampaignBase'
else:
base_import = 'from module.campaign.campaign_base import CampaignBase'
@ -377,6 +383,9 @@ class MapData:
def write(self, path):
file = os.path.join(path, self.map_file_name())
has_modified_campaign_base = os.path.exists(os.path.join(path, 'campaign_base.py'))
if has_modified_campaign_base:
print('Using existing campaign_base.py')
if os.path.exists(file):
if OVERWRITE:
print(f'Delete file: {file}')
@ -386,7 +395,7 @@ class MapData:
return False
print(f'Extract: {file}')
with open(file, 'w') as f:
for text in self.get_file_lines():
for text in self.get_file_lines(has_modified_campaign_base=has_modified_campaign_base):
f.write(text + '\n')