Skip to content

Commit 7ab1865

Browse files
authored
Merge pull request LmeSzinc#5378 from LmeSzinc/dev
Bug fix
2 parents b9ed5b1 + 32d36cd commit 7ab1865

21 files changed

Lines changed: 76 additions & 157 deletions

File tree

6.14 KB
Loading
8.07 KB
Loading

config/template.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@
309309
"ServerUpdate": "00:00"
310310
},
311311
"GemsFarming": {
312-
"ChangeFlagship": "ship",
313312
"CommonCV": "any",
314313
"ChangeVanguard": "ship",
315314
"CommonDD": "any",

dev_tools/utils.py

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_alias(self, server):
4545
def filepath(self, path):
4646
return os.path.join(self.folder, self.server, path)
4747

48-
def _load_file(self, file):
48+
def _load_file(self, file, keyword=None):
4949
"""
5050
Args:
5151
file (str):
@@ -57,56 +57,21 @@ def _load_file(self, file):
5757
text = f.read()
5858

5959
result = {}
60-
matched = re.findall('function \(\)(.*?)end[()]', text, re.S)
61-
if matched:
62-
# Most files are in this format
63-
"""
64-
pg = pg or {}
65-
slot0 = pg
66-
slot0.chapter_template = {}
67-
68-
(function ()
69-
...
70-
end)()
71-
"""
72-
for func in matched:
73-
add = slpp.decode('{' + func + '}')
74-
result.update(add)
75-
elif text.startswith('pg'):
76-
# Old format
77-
"""
78-
pg = pg or {}
79-
pg.item_data_statistics = {
80-
...
81-
}
82-
"""
83-
# or
84-
"""
85-
pg = pg or {}
86-
87-
rawset(pg, "item_data_statistics", rawget(pg, "item_data_statistics") or {
88-
...
89-
}
90-
"""
91-
text = '{' + text.split('{', 2)[2]
92-
result = slpp.decode(text)
93-
else:
94-
# Another format, just bare data
95-
"""
96-
_G.pg.expedition_data_template[...] = {
97-
...
98-
}
99-
_G.pg.expedition_data_template[...] = {
100-
...
101-
}
102-
...
103-
"""
60+
if text.startswith('_G'):
10461
text = '{' + text + '}'
10562
result = slpp.decode(text)
106-
63+
else:
64+
if keyword:
65+
print(f'Finding keyword: {keyword}')
66+
pattern = rf"^{re.escape(keyword)}.*?\{{\s*\n(.*?)^\}}"
67+
else:
68+
pattern = r"\{\s*\n(.*?)^\}"
69+
m = re.search(pattern, text, re.S | re.M)
70+
if m:
71+
result = slpp.decode('{' + m.group(1) + '}')
10772
return result
10873

109-
def load(self, path):
74+
def load(self, path, keyword=None):
11075
"""
11176
Load a lua file to python dictionary, handling the differences
11277
@@ -123,7 +88,7 @@ def load(self, path):
12388
for file in tqdm(os.listdir(self.filepath(path))):
12489
result.update(self._load_file(f'./{path}/{file}'))
12590
else:
126-
result = self._load_file(path)
91+
result = self._load_file(path, keyword=keyword)
12792

12893
print(f'{len(result.keys())} items loaded')
12994
return result

module/campaign/gems_farming.py

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,10 @@ class GemsCampaign(GemsCampaignOverride, self.module.Campaign):
7979
self.campaign.config.override(Emotion_Mode='ignore')
8080
self.campaign.config.override(EnemyPriority_EnemyScaleBalanceWeight='S1_enemy_first')
8181

82-
@property
83-
def change_flagship(self):
84-
return 'ship' in self.config.GemsFarming_ChangeFlagship
85-
86-
@property
87-
def change_flagship_equip(self):
88-
return 'equip' in self.config.GemsFarming_ChangeFlagship
89-
9082
@property
9183
def change_vanguard(self):
9284
return 'ship' in self.config.GemsFarming_ChangeVanguard
9385

94-
@property
95-
def change_vanguard_equip(self):
96-
return 'equip' in self.config.GemsFarming_ChangeVanguard
97-
9886
@property
9987
def fleet_to_attack(self):
10088
if self.config.Fleet_FleetOrder == 'fleet1_standby_fleet2_all':
@@ -110,31 +98,12 @@ def flagship_change(self):
11098
Returns:
11199
bool: True if flagship changed.
112100
"""
113-
114-
if self.config.GemsFarming_CommonCV == 'any':
115-
index_list = range(3, 5)
116-
else:
117-
index_list = range(0, 5)
118101
logger.hr('Change flagship', level=1)
119-
logger.attr('ChangeFlagship', self.config.GemsFarming_ChangeFlagship)
120102
self.fleet_enter(self.fleet_to_attack)
121-
if self.change_flagship_equip:
122-
logger.hr('Record flagship equipment', level=2)
123-
self.fleet_enter_ship(FLEET_DETAIL_ENTER_FLAGSHIP)
124-
self.ship_equipment_record_image(index_list=index_list)
125-
self.ship_equipment_take_off()
126-
self.fleet_back()
127103

128104
logger.hr('Change flagship', level=2)
129105
success = self.flagship_change_execute()
130106

131-
if self.change_flagship_equip:
132-
logger.hr('Equip flagship equipment', level=2)
133-
self.fleet_enter_ship(FLEET_DETAIL_ENTER_FLAGSHIP)
134-
self.ship_equipment_take_off()
135-
self.ship_equipment_take_on_image(index_list=index_list)
136-
self.fleet_back()
137-
138107
return success
139108

140109
def vanguard_change(self):
@@ -148,23 +117,10 @@ def vanguard_change(self):
148117
logger.hr('Change vanguard', level=1)
149118
logger.attr('ChangeVanguard', self.config.GemsFarming_ChangeVanguard)
150119
self.fleet_enter(self.fleet_to_attack)
151-
if self.change_vanguard_equip:
152-
logger.hr('Record vanguard equipment', level=2)
153-
self.fleet_enter_ship(FLEET_DETAIL_ENTER)
154-
self.ship_equipment_record_image()
155-
self.ship_equipment_take_off()
156-
self.fleet_back()
157120

158121
logger.hr('Change vanguard', level=2)
159122
success = self.vanguard_change_execute()
160123

161-
if self.change_vanguard_equip:
162-
logger.hr('Equip vanguard equipment', level=2)
163-
self.fleet_enter_ship(FLEET_DETAIL_ENTER)
164-
self.ship_equipment_take_off()
165-
self.ship_equipment_take_on_image()
166-
self.fleet_back()
167-
168124
return success
169125

170126
def _dock_reset(self):
@@ -391,7 +347,7 @@ def vanguard_change_execute(self):
391347

392348
def triggered_stop_condition(self, oil_check=True):
393349
# Lv32 limit
394-
if self.change_flagship and self.campaign.config.LV32_TRIGGERED:
350+
if self.campaign.config.LV32_TRIGGERED:
395351
self._trigger_lv32 = True
396352
logger.hr('TRIGGERED LV32 LIMIT')
397353
return True
@@ -411,7 +367,7 @@ def run(self, name, folder='campaign_main', mode='normal', total=0):
411367
mode (str): `normal` or `hard`
412368
total (int):
413369
"""
414-
self.config.STOP_IF_REACH_LV32 = self.change_flagship
370+
self.config.override(STOP_IF_REACH_LV32=True)
415371

416372
while 1:
417373
self._trigger_lv32 = False
@@ -427,9 +383,7 @@ def run(self, name, folder='campaign_main', mode='normal', total=0):
427383

428384
# End
429385
if self._trigger_lv32 or self._trigger_emotion:
430-
success = True
431-
if self.change_flagship:
432-
success = self.flagship_change()
386+
success = self.flagship_change()
433387
if self.change_vanguard:
434388
success = success and self.vanguard_change()
435389

module/combat/combat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def is_combat_executing(self):
119119
return PAUSE_Seaside
120120
if PAUSE_Ninja.match_template_color(self.device.image, offset=(10, 10)):
121121
return PAUSE_Ninja
122+
if PAUSE_ShadowPuppetry.match_luma(self.device.image, offset=(10, 10)):
123+
return PAUSE_ShadowPuppetry
122124
return False
123125

124126
def handle_combat_quit(self, offset=(20, 20), interval=3):

module/combat_ui/assets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
PAUSE_Nurse = Button(area={'cn': (1236, 33, 1251, 50), 'en': (1236, 33, 1251, 50), 'jp': (1236, 33, 1251, 50), 'tw': (1236, 33, 1251, 50)}, color={'cn': (200, 206, 209), 'en': (200, 206, 209), 'jp': (200, 206, 209), 'tw': (200, 206, 209)}, button={'cn': (1236, 33, 1251, 50), 'en': (1236, 33, 1251, 50), 'jp': (1236, 33, 1251, 50), 'tw': (1236, 33, 1251, 50)}, file={'cn': './assets/cn/combat_ui/PAUSE_Nurse.png', 'en': './assets/cn/combat_ui/PAUSE_Nurse.png', 'jp': './assets/cn/combat_ui/PAUSE_Nurse.png', 'tw': './assets/cn/combat_ui/PAUSE_Nurse.png'})
1818
PAUSE_Pharaoh = Button(area={'cn': (1229, 55, 1259, 62), 'en': (1229, 55, 1259, 62), 'jp': (1229, 55, 1259, 62), 'tw': (1229, 55, 1259, 62)}, color={'cn': (164, 119, 78), 'en': (164, 119, 78), 'jp': (164, 119, 78), 'tw': (164, 119, 78)}, button={'cn': (1229, 55, 1259, 62), 'en': (1229, 55, 1259, 62), 'jp': (1229, 55, 1259, 62), 'tw': (1229, 55, 1259, 62)}, file={'cn': './assets/cn/combat_ui/PAUSE_Pharaoh.png', 'en': './assets/cn/combat_ui/PAUSE_Pharaoh.png', 'jp': './assets/cn/combat_ui/PAUSE_Pharaoh.png', 'tw': './assets/cn/combat_ui/PAUSE_Pharaoh.png'})
1919
PAUSE_Seaside = Button(area={'cn': (1214, 31, 1239, 59), 'en': (1214, 31, 1239, 59), 'jp': (1214, 31, 1239, 59), 'tw': (1214, 31, 1239, 59)}, color={'cn': (172, 196, 212), 'en': (172, 196, 212), 'jp': (172, 196, 212), 'tw': (172, 196, 212)}, button={'cn': (1214, 31, 1239, 59), 'en': (1214, 31, 1239, 59), 'jp': (1214, 31, 1239, 59), 'tw': (1214, 31, 1239, 59)}, file={'cn': './assets/cn/combat_ui/PAUSE_Seaside.png', 'en': './assets/cn/combat_ui/PAUSE_Seaside.png', 'jp': './assets/cn/combat_ui/PAUSE_Seaside.png', 'tw': './assets/cn/combat_ui/PAUSE_Seaside.png'})
20+
PAUSE_ShadowPuppetry = Button(area={'cn': (1216, 37, 1234, 55), 'en': (1216, 37, 1234, 55), 'jp': (1216, 37, 1234, 55), 'tw': (1216, 37, 1234, 55)}, color={'cn': (139, 112, 72), 'en': (139, 112, 72), 'jp': (139, 112, 72), 'tw': (139, 112, 72)}, button={'cn': (1216, 37, 1234, 55), 'en': (1216, 37, 1234, 55), 'jp': (1216, 37, 1234, 55), 'tw': (1216, 37, 1234, 55)}, file={'cn': './assets/cn/combat_ui/PAUSE_ShadowPuppetry.png', 'en': './assets/cn/combat_ui/PAUSE_ShadowPuppetry.png', 'jp': './assets/cn/combat_ui/PAUSE_ShadowPuppetry.png', 'tw': './assets/cn/combat_ui/PAUSE_ShadowPuppetry.png'})
2021
PAUSE_Star = Button(area={'cn': (1234, 36, 1250, 57), 'en': (1234, 36, 1250, 57), 'jp': (1234, 36, 1250, 57), 'tw': (1234, 36, 1250, 57)}, color={'cn': (169, 179, 179), 'en': (169, 179, 179), 'jp': (169, 179, 179), 'tw': (169, 179, 179)}, button={'cn': (1234, 36, 1250, 57), 'en': (1234, 36, 1250, 57), 'jp': (1234, 36, 1250, 57), 'tw': (1234, 36, 1250, 57)}, file={'cn': './assets/cn/combat_ui/PAUSE_Star.png', 'en': './assets/cn/combat_ui/PAUSE_Star.png', 'jp': './assets/cn/combat_ui/PAUSE_Star.png', 'tw': './assets/cn/combat_ui/PAUSE_Star.png'})
2122
QUIT = Button(area={'cn': (420, 490, 593, 548), 'en': (473, 508, 567, 532), 'jp': (433, 490, 606, 547), 'tw': (433, 490, 606, 547)}, color={'cn': (199, 122, 114), 'en': (216, 168, 164), 'jp': (196, 120, 113), 'tw': (200, 126, 118)}, button={'cn': (420, 490, 593, 548), 'en': (473, 508, 567, 532), 'jp': (433, 490, 606, 547), 'tw': (433, 490, 606, 547)}, file={'cn': './assets/cn/combat_ui/QUIT.png', 'en': './assets/en/combat_ui/QUIT.png', 'jp': './assets/jp/combat_ui/QUIT.png', 'tw': './assets/tw/combat_ui/QUIT.png'})
2223
QUIT_Christmas = Button(area={'cn': (400, 506, 477, 525), 'en': (410, 507, 469, 524), 'jp': (400, 506, 477, 525), 'tw': (400, 506, 477, 525)}, color={'cn': (195, 139, 166), 'en': (207, 166, 185), 'jp': (195, 139, 166), 'tw': (195, 139, 166)}, button={'cn': (400, 506, 477, 525), 'en': (410, 507, 469, 524), 'jp': (400, 506, 477, 525), 'tw': (400, 506, 477, 525)}, file={'cn': './assets/cn/combat_ui/QUIT_Christmas.png', 'en': './assets/en/combat_ui/QUIT_Christmas.png', 'jp': './assets/cn/combat_ui/QUIT_Christmas.png', 'tw': './assets/cn/combat_ui/QUIT_Christmas.png'})

module/config/argument/args.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,14 +1590,6 @@
15901590
}
15911591
},
15921592
"GemsFarming": {
1593-
"ChangeFlagship": {
1594-
"type": "select",
1595-
"value": "ship",
1596-
"option": [
1597-
"ship",
1598-
"ship_equip"
1599-
]
1600-
},
16011593
"CommonCV": {
16021594
"type": "select",
16031595
"value": "any",
@@ -1614,8 +1606,7 @@
16141606
"value": "ship",
16151607
"option": [
16161608
"disabled",
1617-
"ship",
1618-
"ship_equip"
1609+
"ship"
16191610
]
16201611
},
16211612
"CommonDD": {

module/config/argument/argument.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,12 @@ C124LargeLeveling:
265265
value: 3
266266
option: [ 3, 4, 5 ]
267267
GemsFarming:
268-
ChangeFlagship:
269-
value: ship
270-
option: [ ship, ship_equip ]
271268
CommonCV:
272269
value: any
273270
option: [ any, langley, bogue, ranger, hermes ]
274271
ChangeVanguard:
275272
value: ship
276-
option: [ disabled, ship, ship_equip ]
273+
option: [ disabled, ship ]
277274
CommonDD:
278275
value: any
279276
option: [ any, favourite, aulick_or_foote , cassin_or_downes, z20_or_z21 ]

module/config/argument/menu.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
"page": "setting",
2424
"tasks": [
2525
"EventGeneral",
26-
"Coalition",
2726
"Event",
2827
"Event2",
2928
"Raid",
3029
"Hospital",
30+
"Coalition",
3131
"MaritimeEscort",
3232
"WarArchives"
3333
]

0 commit comments

Comments
 (0)