Skip to content

Commit

Permalink
Merge pull request #661 from LmeSzinc/master
Browse files Browse the repository at this point in the history
[pull] mydev from LmeSzinc:master
  • Loading branch information
pull[bot] authored Sep 10, 2024
2 parents cfa4609 + e4c4f41 commit ecb872b
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 28 deletions.
Binary file added assets/mask/MASK_MAIN_WHITE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tw/guild/EXP_INFO_CF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion campaign/campaign_main/campaign_15_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def merge(self, info, mode='normal'):


class CampaignBase(CampaignBase_):
ENEMY_FILTER = '1T > 1L > 1E > 1M > 2T > 2L > 2E > 2M > 3T > 3L > 3E > 3M'
ENEMY_FILTER = '1L > 1M > 1E > 2L > 3L > 2M > 2E > 1C > 2C > 3M > 3E > 3C'

def map_data_init(self, map_):
super().map_data_init(map_)
Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20240815_cn/b2.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def before_boss(self):
# Handle giant boss at A8
logger.info('B2 before boss')
grid = SelectedGrids([B6, C7]).sort('weight', 'cost')[0]
self.goto(grid)
self.goto(B8)
self.fleet_boss.goto(grid)
self.fleet_boss.goto(B8)

def clear_boss(self):
self.before_boss()
Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20240815_cn/d2.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def before_boss(self):
# Handle giant boss at A8
logger.info('B2 before boss')
grid = SelectedGrids([B6, C7]).sort('weight', 'cost')[0]
self.goto(grid)
self.goto(B8)
self.fleet_boss.goto(grid)
self.fleet_boss.goto(B8)

def clear_boss(self):
self.before_boss()
Expand Down
2 changes: 1 addition & 1 deletion config/template.maa.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
"ServerUpdate": "04:00"
},
"MaaRoguelike": {
"Theme": "Sami",
"Theme": "Sarkaz",
"Mode": 0,
"StartsCount": 9999999,
"InvestmentsCount": 9999999,
Expand Down
9 changes: 8 additions & 1 deletion module/device/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,25 @@ def adb_brute_force_connect(self, serial_list):
serial_list (list[str]):
"""
import asyncio
from concurrent.futures import ThreadPoolExecutor
ev = asyncio.new_event_loop()
pool = ThreadPoolExecutor(
max_workers=len(serial_list),
thread_name_prefix='adb_brute_force_connect',
)

def _connect(serial):
msg = self.adb_client.connect(serial)
logger.info(msg)
return msg

async def connect():
tasks = [ev.run_in_executor(None, _connect, serial) for serial in serial_list]
tasks = [ev.run_in_executor(pool, _connect, serial) for serial in serial_list]
await asyncio.gather(*tasks)

ev.run_until_complete(connect())
pool.shutdown(wait=False)
ev.close()

@Config.when(DEVICE_OVER_HTTP=True)
def adb_connect(self):
Expand Down
16 changes: 15 additions & 1 deletion module/device/method/nemu_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,25 @@ def __enter__(self):

def __exit__(self, exc_type, exc_val, exc_tb):
self.disconnect()
if has_cached_property(self, '_ev'):
self._ev.close()
del_cached_property(self, '_ev')
if has_cached_property(self, '_pool'):
self._pool.shutdown(wait=False)
del_cached_property(self, '_pool')

@cached_property
def _ev(self):
return asyncio.new_event_loop()

@cached_property
def _pool(self):
from concurrent.futures import ThreadPoolExecutor
return ThreadPoolExecutor(
max_workers=1,
thread_name_prefix='NemuIpc',
)

async def ev_run_async(self, func, *args, timeout=0.15, **kwargs):
"""
Args:
Expand All @@ -294,7 +308,7 @@ async def ev_run_async(self, func, *args, timeout=0.15, **kwargs):
func_wrapped = partial(func, *args, **kwargs)
# Increased timeout for slow PCs
# Default screenshot interval is 0.2s, so a 0.15s timeout would have a fast retry without extra time costs
result = await asyncio.wait_for(self._ev.run_in_executor(None, func_wrapped), timeout=timeout)
result = await asyncio.wait_for(self._ev.run_in_executor(self._pool, func_wrapped), timeout=timeout)
return result

def ev_run_sync(self, func, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion module/guild/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Don't modify it manually.

BATTLE_STATUS_CF = Button(area={'cn': (260, 196, 276, 288), 'en': (278, 219, 284, 257), 'jp': (291, 198, 302, 277), 'tw': (204, 197, 214, 288)}, color={'cn': (255, 244, 134), 'en': (253, 236, 137), 'jp': (252, 247, 142), 'tw': (255, 230, 139)}, button={'cn': (1138, 646, 1216, 682), 'en': (1138, 646, 1216, 682), 'jp': (1138, 646, 1216, 682), 'tw': (1138, 646, 1216, 682)}, file={'cn': './assets/cn/guild/BATTLE_STATUS_CF.png', 'en': './assets/en/guild/BATTLE_STATUS_CF.png', 'jp': './assets/jp/guild/BATTLE_STATUS_CF.png', 'tw': './assets/tw/guild/BATTLE_STATUS_CF.png'})
EXP_INFO_CF = Button(area={'cn': (138, 63, 148, 118), 'en': (149, 77, 152, 100), 'jp': (155, 64, 162, 115), 'tw': (321, 93, 328, 114)}, color={'cn': (255, 244, 134), 'en': (253, 235, 137), 'jp': (252, 247, 140), 'tw': (255, 255, 159)}, button={'cn': (1138, 646, 1216, 682), 'en': (1138, 646, 1216, 682), 'jp': (1138, 646, 1216, 682), 'tw': (1138, 646, 1216, 682)}, file={'cn': './assets/cn/guild/EXP_INFO_CF.png', 'en': './assets/en/guild/EXP_INFO_CF.png', 'jp': './assets/jp/guild/EXP_INFO_CF.png', 'tw': './assets/tw/guild/EXP_INFO_CF.png'})
EXP_INFO_CF = Button(area={'cn': (138, 63, 148, 118), 'en': (149, 77, 152, 100), 'jp': (155, 64, 162, 115), 'tw': (104, 63, 111, 119)}, color={'cn': (255, 244, 134), 'en': (253, 235, 137), 'jp': (252, 247, 140), 'tw': (255, 231, 140)}, button={'cn': (1138, 646, 1216, 682), 'en': (1138, 646, 1216, 682), 'jp': (1138, 646, 1216, 682), 'tw': (1138, 646, 1216, 682)}, file={'cn': './assets/cn/guild/EXP_INFO_CF.png', 'en': './assets/en/guild/EXP_INFO_CF.png', 'jp': './assets/jp/guild/EXP_INFO_CF.png', 'tw': './assets/tw/guild/EXP_INFO_CF.png'})
GUILD_BOSS_AVAILABLE = Button(area={'cn': (1229, 614, 1242, 632), 'en': (1229, 614, 1242, 632), 'jp': (1229, 614, 1242, 632), 'tw': (1229, 614, 1242, 632)}, color={'cn': (58, 100, 61), 'en': (58, 100, 61), 'jp': (40, 70, 53), 'tw': (58, 100, 61)}, button={'cn': (1229, 614, 1242, 632), 'en': (1229, 614, 1242, 632), 'jp': (1229, 614, 1242, 632), 'tw': (1229, 614, 1242, 632)}, file={'cn': './assets/cn/guild/GUILD_BOSS_AVAILABLE.png', 'en': './assets/en/guild/GUILD_BOSS_AVAILABLE.png', 'jp': './assets/jp/guild/GUILD_BOSS_AVAILABLE.png', 'tw': './assets/tw/guild/GUILD_BOSS_AVAILABLE.png'})
GUILD_BOSS_ENTER = Button(area={'cn': (1132, 642, 1261, 687), 'en': (1115, 646, 1257, 683), 'jp': (1140, 643, 1261, 687), 'tw': (1144, 642, 1261, 687)}, color={'cn': (71, 156, 246), 'en': (77, 158, 249), 'jp': (80, 161, 242), 'tw': (75, 162, 246)}, button={'cn': (1132, 642, 1261, 687), 'en': (1115, 646, 1257, 683), 'jp': (1140, 643, 1261, 687), 'tw': (1144, 642, 1261, 687)}, file={'cn': './assets/cn/guild/GUILD_BOSS_ENTER.png', 'en': './assets/en/guild/GUILD_BOSS_ENTER.png', 'jp': './assets/jp/guild/GUILD_BOSS_ENTER.png', 'tw': './assets/tw/guild/GUILD_BOSS_ENTER.png'})
GUILD_DISPATCH_CLOSE = Button(area={'cn': (1236, 102, 1266, 133), 'en': (1236, 102, 1266, 133), 'jp': (1236, 102, 1266, 133), 'tw': (1236, 102, 1266, 133)}, color={'cn': (88, 39, 38), 'en': (88, 39, 38), 'jp': (88, 39, 38), 'tw': (88, 39, 38)}, button={'cn': (1236, 102, 1266, 133), 'en': (1236, 102, 1266, 133), 'jp': (1236, 102, 1266, 133), 'tw': (1236, 102, 1266, 133)}, file={'cn': './assets/cn/guild/GUILD_DISPATCH_CLOSE.png', 'en': './assets/en/guild/GUILD_DISPATCH_CLOSE.png', 'jp': './assets/jp/guild/GUILD_DISPATCH_CLOSE.png', 'tw': './assets/tw/guild/GUILD_DISPATCH_CLOSE.png'})
Expand Down
3 changes: 2 additions & 1 deletion module/handler/sensitive_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from module.ui.page import MAIN_GOTO_CAMPAIGN_WHITE, MAIN_GOTO_FLEET

MASK_MAIN = Mask('./assets/mask/MASK_MAIN.png')
MASK_MAIN_WHITE = Mask('./assets/mask/MASK_MAIN_WHITE.png')
MASK_PLAYER = Mask('./assets/mask/MASK_PLAYER.png')


Expand All @@ -21,7 +22,7 @@ def handle_sensitive_image(image):
if MAIN_GOTO_FLEET.match(image, offset=(30, 30)):
image = MASK_MAIN.apply(image)
if MAIN_GOTO_CAMPAIGN_WHITE.match(image, offset=(30, 30)):
image = MASK_MAIN.apply(image)
image = MASK_MAIN_WHITE.apply(image)

return image

Expand Down
9 changes: 8 additions & 1 deletion module/retire/retirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def handle_retirement(self):
self._retire_handler(mode='one_click_retire')
self._unable_to_enhance = False
self.interval_reset(IN_RETIREMENT_CHECK)
self.map_cat_attack_timer.reset()
return True
elif self.config.Retirement_RetireMode == 'enhance':
if self.appear_then_click(RETIRE_APPEAR_3, offset=(20, 20), interval=3):
Expand All @@ -367,16 +368,19 @@ def handle_retirement(self):
logger.info('Too few spare docks, retire next time')
self._unable_to_enhance = True
self.interval_reset(DOCK_CHECK)
self.map_cat_attack_timer.reset()
return True
else:
if self.appear_then_click(RETIRE_APPEAR_1, offset=(20, 20), interval=3):
self.interval_clear(IN_RETIREMENT_CHECK)
self.interval_reset([AUTO_SEARCH_MAP_OPTION_OFF, AUTO_SEARCH_MAP_OPTION_ON])
self.map_cat_attack_timer.reset()
return False
if self.appear(IN_RETIREMENT_CHECK, offset=(20, 20), interval=10):
self._retire_handler()
self._unable_to_enhance = False
self.interval_reset(IN_RETIREMENT_CHECK)
self.map_cat_attack_timer.reset()
return True

return False
Expand Down Expand Up @@ -500,7 +504,10 @@ def retirement_get_common_rarity_cv(self, skip_first_screenshot=False):
if button is not None:
return button

while RETIRE_CONFIRM_SCROLL.appear(main=self):
for _ in range(7):
if not RETIRE_CONFIRM_SCROLL.appear(main=self):
logger.info('Scroll bar disappeared, stop')
break
RETIRE_CONFIRM_SCROLL.next_page(main=self)
button = self.retirement_get_common_rarity_cv_in_page()
if button is not None:
Expand Down
12 changes: 8 additions & 4 deletions submodule/AlasMaaBridge/module/config/argument/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@
"display": "hide"
},
"OnePushConfig": {
"type": "input",
"type": "textarea",
"value": "provider: null",
"mode": "yaml",
"display": "hide"
"mode": "yaml"
}
},
"Optimization": {
Expand Down Expand Up @@ -953,7 +952,8 @@
"option": [
"Phantom",
"Mizuki",
"Sami"
"Sami",
"Sarkaz"
]
},
"Mode": {
Expand Down Expand Up @@ -981,6 +981,10 @@
"type": "select",
"value": "指挥分队",
"option": [
"魂灵护送分队",
"博闻广记分队",
"蓝图测绘分队",
"因地制宜分队",
"永恒狩猎分队",
"生活至上分队",
"科学主义分队",
Expand Down
8 changes: 4 additions & 4 deletions submodule/AlasMaaBridge/module/config/argument/argument.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Error:
value: false
display: hide
OnePushConfig:
type: textarea
mode: yaml
value: 'provider: null'
display: hide
Optimization:
WhenTaskQueueEmpty:
value: stay_there
Expand Down Expand Up @@ -151,8 +151,8 @@ MaaMall:

MaaRoguelike:
Theme:
value: Sami
option: [ Phantom, Mizuki, Sami ]
value: Sarkaz
option: [ Phantom, Mizuki, Sami, Sarkaz ]
Mode:
value: 0
option: [ 0, 1, 4 ]
Expand All @@ -161,7 +161,7 @@ MaaRoguelike:
StopWhenInvestmentFull: false
Squad:
value: 指挥分队
option: [ 永恒狩猎分队, 生活至上分队, 科学主义分队, 特训分队, 心胜于物分队, 物尽其用分队, 以人为本分队, 指挥分队, 集群分队, 后勤分队, 矛头分队, 突击战术分队, 堡垒战术分队, 远程战术分队, 破坏战术分队, 研究分队, 高规格分队 ]
option: [ 魂灵护送分队, 博闻广记分队, 蓝图测绘分队, 因地制宜分队, 永恒狩猎分队, 生活至上分队, 科学主义分队, 特训分队, 心胜于物分队, 物尽其用分队, 以人为本分队, 指挥分队, 集群分队, 后勤分队, 矛头分队, 突击战术分队, 堡垒战术分队, 远程战术分队, 破坏战术分队, 研究分队, 高规格分队 ]
Roles:
value: 取长补短
option: [ 先手必胜, 稳扎稳打, 取长补短, 随心所欲 ]
Expand Down
4 changes: 2 additions & 2 deletions submodule/AlasMaaBridge/module/config/config_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ class GeneratedConfig:
MaaMall_BlackList = '碳 > 家具 > 加急许可'

# Group `MaaRoguelike`
MaaRoguelike_Theme = 'Sami' # Phantom, Mizuki, Sami
MaaRoguelike_Theme = 'Sarkaz' # Phantom, Mizuki, Sami, Sarkaz
MaaRoguelike_Mode = 0 # 0, 1, 4
MaaRoguelike_StartsCount = 9999999
MaaRoguelike_InvestmentsCount = 9999999
MaaRoguelike_StopWhenInvestmentFull = False
MaaRoguelike_Squad = '指挥分队' # 永恒狩猎分队, 生活至上分队, 科学主义分队, 特训分队, 心胜于物分队, 物尽其用分队, 以人为本分队, 指挥分队, 集群分队, 后勤分队, 矛头分队, 突击战术分队, 堡垒战术分队, 远程战术分队, 破坏战术分队, 研究分队, 高规格分队
MaaRoguelike_Squad = '指挥分队' # 魂灵护送分队, 博闻广记分队, 蓝图测绘分队, 因地制宜分队, 永恒狩猎分队, 生活至上分队, 科学主义分队, 特训分队, 心胜于物分队, 物尽其用分队, 以人为本分队, 指挥分队, 集群分队, 后勤分队, 矛头分队, 突击战术分队, 堡垒战术分队, 远程战术分队, 破坏战术分队, 研究分队, 高规格分队
MaaRoguelike_Roles = '取长补短' # 先手必胜, 稳扎稳打, 取长补短, 随心所欲
MaaRoguelike_CoreChar = None
MaaRoguelike_Support = 'no_use' # no_use, friend_support, nonfriend_support
Expand Down
7 changes: 6 additions & 1 deletion submodule/AlasMaaBridge/module/config/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@
"help": "MaaRoguelike.Theme.help",
"Phantom": "Phantom",
"Mizuki": "Mizuki",
"Sami": "Sami"
"Sami": "Sami",
"Sarkaz": "Sarkaz"
},
"Mode": {
"name": "MaaRoguelike.Mode.name",
Expand All @@ -537,6 +538,10 @@
"Squad": {
"name": "MaaRoguelike.Squad.name",
"help": "MaaRoguelike.Squad.help",
"魂灵护送分队": "Soul Escort (Sarkaz)",
"博闻广记分队": "Well-Informed (Sarkaz)",
"蓝图测绘分队": "Blueprint Surveying (Sarkaz)",
"因地制宜分队": "Adapting To Local Conditions (Sarkaz)",
"永恒狩猎分队": "Eternal Hunting (Sami)",
"生活至上分队": "Life Prioritizing (Sami)",
"科学主义分队": "Scientific Thinking (Sami)",
Expand Down
7 changes: 6 additions & 1 deletion submodule/AlasMaaBridge/module/config/i18n/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@
"help": "MaaRoguelike.Theme.help",
"Phantom": "Phantom",
"Mizuki": "Mizuki",
"Sami": "Sami"
"Sami": "Sami",
"Sarkaz": "Sarkaz"
},
"Mode": {
"name": "MaaRoguelike.Mode.name",
Expand All @@ -537,6 +538,10 @@
"Squad": {
"name": "MaaRoguelike.Squad.name",
"help": "MaaRoguelike.Squad.help",
"魂灵护送分队": "魂灵护送分队",
"博闻广记分队": "博闻广记分队",
"蓝图测绘分队": "蓝图测绘分队",
"因地制宜分队": "因地制宜分队",
"永恒狩猎分队": "永恒狩猎分队",
"生活至上分队": "生活至上分队",
"科学主义分队": "科学主义分队",
Expand Down
7 changes: 6 additions & 1 deletion submodule/AlasMaaBridge/module/config/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@
"help": "需在集成战略界面手动将对应主题添加到终端",
"Phantom": "傀影与猩红血钻",
"Mizuki": "水月与深蓝之树",
"Sami": "探索者的银凇止境"
"Sami": "探索者的银凇止境",
"Sarkaz": "萨卡兹的无终奇语"
},
"Mode": {
"name": "策略",
Expand All @@ -537,6 +538,10 @@
"Squad": {
"name": "开局分队",
"help": "",
"魂灵护送分队": "魂灵护送分队(萨卡兹)",
"博闻广记分队": "博闻广记分队(萨卡兹)",
"蓝图测绘分队": "蓝图测绘分队(萨卡兹)",
"因地制宜分队": "因地制宜分队(萨卡兹)",
"永恒狩猎分队": "永恒狩猎分队(萨米)",
"生活至上分队": "生活至上分队(萨米)",
"科学主义分队": "科学主义分队(萨米)",
Expand Down
7 changes: 6 additions & 1 deletion submodule/AlasMaaBridge/module/config/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@
"help": "MaaRoguelike.Theme.help",
"Phantom": "Phantom",
"Mizuki": "Mizuki",
"Sami": "Sami"
"Sami": "Sami",
"Sarkaz": "Sarkaz"
},
"Mode": {
"name": "MaaRoguelike.Mode.name",
Expand All @@ -537,6 +538,10 @@
"Squad": {
"name": "MaaRoguelike.Squad.name",
"help": "MaaRoguelike.Squad.help",
"魂灵护送分队": "魂灵护送分队",
"博闻广记分队": "博闻广记分队",
"蓝图测绘分队": "蓝图测绘分队",
"因地制宜分队": "因地制宜分队",
"永恒狩猎分队": "永恒狩猎分队",
"生活至上分队": "生活至上分队",
"科学主义分队": "科学主义分队",
Expand Down
12 changes: 9 additions & 3 deletions submodule/AlasMaaBridge/module/handler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def task_end_callback(self, m, d):
所有其他回调处理函数应遵循同样格式,
在需要使用的时候加入callback_list,
可以被随时移除,或在任务结束时自动清空。
参数的详细说明见https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/master/docs/3.2-回调信息协议.md
参数的详细说明见https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/master/docs/zh-cn/protocol/callback-schema.md
Args:
m (Message): 消息类型
Expand Down Expand Up @@ -207,7 +207,9 @@ def connect(self):
def startup(self):
self.connect()
if self.config.Scheduler_NextRun.strftime('%H:%M') == self.config.Scheduler_ServerUpdate:
self.maa_start('CloseDown', {})
self.maa_start('CloseDown', {
"client_type": self.config.MaaEmulator_PackageName
})

self.maa_start('StartUp', {
"client_type": self.config.MaaEmulator_PackageName,
Expand Down Expand Up @@ -458,7 +460,11 @@ def roguelike(self):
self.config.MaaRoguelike_Theme != "Sami" and self.config.MaaRoguelike_Squad in ["永恒狩猎分队",
"生活至上分队",
"科学主义分队",
"特训分队"]):
"特训分队"]) or (
self.config.MaaRoguelike_Theme != "Sarkaz" and self.config.MaaRoguelike_Squad in ["魂灵护送分队",
"博闻广记分队",
"蓝图测绘分队",
"因地制宜分队"]):

args["squad"] = "指挥分队"
if self.config.MaaRoguelike_CoreChar:
Expand Down

0 comments on commit ecb872b

Please sign in to comment.