Skip to content

Commit fac39e7

Browse files
authored
Merge pull request #4157 from LmeSzinc/dev
Bug fix
2 parents ade9ed8 + 4b07f50 commit fac39e7

10 files changed

Lines changed: 41 additions & 13 deletions

File tree

assets/mask/MASK_MAIN_WHITE.png

7.86 KB
Loading

campaign/campaign_main/campaign_15_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def merge(self, info, mode='normal'):
4343

4444

4545
class CampaignBase(CampaignBase_):
46-
ENEMY_FILTER = '1T > 1L > 1E > 1M > 2T > 2L > 2E > 2M > 3T > 3L > 3E > 3M'
46+
ENEMY_FILTER = '1L > 1M > 1E > 2L > 3L > 2M > 2E > 1C > 2C > 3M > 3E > 3C'
4747

4848
def map_data_init(self, map_):
4949
super().map_data_init(map_)

campaign/event_20240815_cn/b2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def before_boss(self):
8585
# Handle giant boss at A8
8686
logger.info('B2 before boss')
8787
grid = SelectedGrids([B6, C7]).sort('weight', 'cost')[0]
88-
self.goto(grid)
89-
self.goto(B8)
88+
self.fleet_boss.goto(grid)
89+
self.fleet_boss.goto(B8)
9090

9191
def clear_boss(self):
9292
self.before_boss()

campaign/event_20240815_cn/d2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def before_boss(self):
9494
# Handle giant boss at A8
9595
logger.info('B2 before boss')
9696
grid = SelectedGrids([B6, C7]).sort('weight', 'cost')[0]
97-
self.goto(grid)
98-
self.goto(B8)
97+
self.fleet_boss.goto(grid)
98+
self.fleet_boss.goto(B8)
9999

100100
def clear_boss(self):
101101
self.before_boss()

module/device/connection.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,18 +715,25 @@ def adb_brute_force_connect(self, serial_list):
715715
serial_list (list[str]):
716716
"""
717717
import asyncio
718+
from concurrent.futures import ThreadPoolExecutor
718719
ev = asyncio.new_event_loop()
720+
pool = ThreadPoolExecutor(
721+
max_workers=len(serial_list),
722+
thread_name_prefix='adb_brute_force_connect',
723+
)
719724

720725
def _connect(serial):
721726
msg = self.adb_client.connect(serial)
722727
logger.info(msg)
723728
return msg
724729

725730
async def connect():
726-
tasks = [ev.run_in_executor(None, _connect, serial) for serial in serial_list]
731+
tasks = [ev.run_in_executor(pool, _connect, serial) for serial in serial_list]
727732
await asyncio.gather(*tasks)
728733

729734
ev.run_until_complete(connect())
735+
pool.shutdown(wait=False)
736+
ev.close()
730737

731738
@Config.when(DEVICE_OVER_HTTP=True)
732739
def adb_connect(self):

module/device/method/nemu_ipc.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,25 @@ def __enter__(self):
275275

276276
def __exit__(self, exc_type, exc_val, exc_tb):
277277
self.disconnect()
278+
if has_cached_property(self, '_ev'):
279+
self._ev.close()
280+
del_cached_property(self, '_ev')
281+
if has_cached_property(self, '_pool'):
282+
self._pool.shutdown(wait=False)
283+
del_cached_property(self, '_pool')
278284

279285
@cached_property
280286
def _ev(self):
281287
return asyncio.new_event_loop()
282288

289+
@cached_property
290+
def _pool(self):
291+
from concurrent.futures import ThreadPoolExecutor
292+
return ThreadPoolExecutor(
293+
max_workers=1,
294+
thread_name_prefix='NemuIpc',
295+
)
296+
283297
async def ev_run_async(self, func, *args, timeout=0.15, **kwargs):
284298
"""
285299
Args:
@@ -294,7 +308,7 @@ async def ev_run_async(self, func, *args, timeout=0.15, **kwargs):
294308
func_wrapped = partial(func, *args, **kwargs)
295309
# Increased timeout for slow PCs
296310
# Default screenshot interval is 0.2s, so a 0.15s timeout would have a fast retry without extra time costs
297-
result = await asyncio.wait_for(self._ev.run_in_executor(None, func_wrapped), timeout=timeout)
311+
result = await asyncio.wait_for(self._ev.run_in_executor(self._pool, func_wrapped), timeout=timeout)
298312
return result
299313

300314
def ev_run_sync(self, func, *args, **kwargs):

module/handler/sensitive_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from module.ui.page import MAIN_GOTO_CAMPAIGN_WHITE, MAIN_GOTO_FLEET
66

77
MASK_MAIN = Mask('./assets/mask/MASK_MAIN.png')
8+
MASK_MAIN_WHITE = Mask('./assets/mask/MASK_MAIN_WHITE.png')
89
MASK_PLAYER = Mask('./assets/mask/MASK_PLAYER.png')
910

1011

@@ -21,7 +22,7 @@ def handle_sensitive_image(image):
2122
if MAIN_GOTO_FLEET.match(image, offset=(30, 30)):
2223
image = MASK_MAIN.apply(image)
2324
if MAIN_GOTO_CAMPAIGN_WHITE.match(image, offset=(30, 30)):
24-
image = MASK_MAIN.apply(image)
25+
image = MASK_MAIN_WHITE.apply(image)
2526

2627
return image
2728

module/retire/retirement.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ def handle_retirement(self):
348348
self._retire_handler(mode='one_click_retire')
349349
self._unable_to_enhance = False
350350
self.interval_reset(IN_RETIREMENT_CHECK)
351+
self.map_cat_attack_timer.reset()
351352
return True
352353
elif self.config.Retirement_RetireMode == 'enhance':
353354
if self.appear_then_click(RETIRE_APPEAR_3, offset=(20, 20), interval=3):
@@ -367,16 +368,19 @@ def handle_retirement(self):
367368
logger.info('Too few spare docks, retire next time')
368369
self._unable_to_enhance = True
369370
self.interval_reset(DOCK_CHECK)
371+
self.map_cat_attack_timer.reset()
370372
return True
371373
else:
372374
if self.appear_then_click(RETIRE_APPEAR_1, offset=(20, 20), interval=3):
373375
self.interval_clear(IN_RETIREMENT_CHECK)
374376
self.interval_reset([AUTO_SEARCH_MAP_OPTION_OFF, AUTO_SEARCH_MAP_OPTION_ON])
377+
self.map_cat_attack_timer.reset()
375378
return False
376379
if self.appear(IN_RETIREMENT_CHECK, offset=(20, 20), interval=10):
377380
self._retire_handler()
378381
self._unable_to_enhance = False
379382
self.interval_reset(IN_RETIREMENT_CHECK)
383+
self.map_cat_attack_timer.reset()
380384
return True
381385

382386
return False
@@ -500,7 +504,10 @@ def retirement_get_common_rarity_cv(self, skip_first_screenshot=False):
500504
if button is not None:
501505
return button
502506

503-
while RETIRE_CONFIRM_SCROLL.appear(main=self):
507+
for _ in range(7):
508+
if not RETIRE_CONFIRM_SCROLL.appear(main=self):
509+
logger.info('Scroll bar disappeared, stop')
510+
break
504511
RETIRE_CONFIRM_SCROLL.next_page(main=self)
505512
button = self.retirement_get_common_rarity_cv_in_page()
506513
if button is not None:

submodule/AlasMaaBridge/module/config/argument/args.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@
6464
"display": "hide"
6565
},
6666
"OnePushConfig": {
67-
"type": "input",
67+
"type": "textarea",
6868
"value": "provider: null",
69-
"mode": "yaml",
70-
"display": "hide"
69+
"mode": "yaml"
7170
}
7271
},
7372
"Optimization": {

submodule/AlasMaaBridge/module/config/argument/argument.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Error:
2727
value: false
2828
display: hide
2929
OnePushConfig:
30+
type: textarea
3031
mode: yaml
3132
value: 'provider: null'
32-
display: hide
3333
Optimization:
3434
WhenTaskQueueEmpty:
3535
value: stay_there

0 commit comments

Comments
 (0)