Skip to content

Commit cfd9d43

Browse files
authored
Merge pull request #1556 from runhey/dev
Dev
2 parents 9906c32 + 7635e0a commit cfd9d43

176 files changed

Lines changed: 725 additions & 533 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/i18n/zh-CN.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"skill_mode": "技能本模式",
88
"costume_shikigami_6": "月下火舞",
99
"costume_shikigami_7": "赤溟幽界",
10+
"costume_shikigami_8": "童梦基地",
11+
"costume_shikigami_9": "眠鹿之森",
1012
"costume_carpbanner_type": "鲤鱼旗皮肤",
1113
"costume_carpbanner_default": "吉鲤游风",
1214
"costume_carpbanner_1": "无垢莲台",
@@ -25,16 +27,13 @@
2527
"Usage": "使用说明",
2628
"checkin_big_god_usage_help": "自动领取网易大神APP的阴阳师福利礼包。\n\n使用前准备:\n1. 开启模拟器的Root模式\n2. 模拟器中安装并登录「网易大神」APP\n3. 在大神APP中绑定阴阳师角色\n\nFrida Server 会自动推送到模拟器并启动,无需手动操作。",
2729
"costume_main_14": "雪月华庭",
28-
"goto_main": "前往主界面",
30+
"goto_main": "前往庭院",
2931
"close_game": "关闭游戏",
30-
"close_emulator_or_goto_main": "关闭模拟器&前往主界面",
31-
"close_emulator_or_close_game": "关闭模拟器&关闭游戏",
32-
"close_game_limit_time": "关闭游戏等待时间",
33-
"close_game_limit_time_help": "此时间内不会关闭游戏, 防止运行间隔时间短的多个任务导致反复开关游戏",
34-
"close_emulator_limit_time": "关闭模拟器等待时间",
35-
"close_emulator_limit_time_help": "此时间内不会关闭模拟器, 防止运行间隔时间短的多个任务导致反复开关模拟器",
32+
"close_game_wait_duration": "关闭游戏的等待时长",
33+
"close_game_wait_duration_help": "距离下一个任务超过此分钟数时关闭游戏(上方选项为前往庭院时无效);设为0表示禁用",
34+
"close_emulator_wait_duration": "关闭模拟器的等待时长",
35+
"close_emulator_wait_duration_help": "距离下一个任务超过此分钟数时关闭模拟器;设为0表示禁用",
3636
"emulator_startup_lead_time": "模拟器预热时间",
3737
"emulator_startup_lead_time_help": "在开始运行任务之前提前启动模拟器的时间"
3838
}
3939

40-

script.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,6 @@ def _handle_wait_during_idle(self, next_run: datetime) -> bool:
330330
strategy_map = {
331331
"close_game": self._wait_close_game,
332332
"goto_main": self._wait_goto_main,
333-
"close_emulator_or_goto_main": self._wait_close_emulator_or_goto_main,
334-
"close_emulator_or_close_game": self._wait_close_emulator_or_close_game,
335333
}
336334
func = strategy_map.get(method)
337335
if func is None:
@@ -376,9 +374,23 @@ def _wait_close_game(self, next_run: datetime) -> bool:
376374
logger.info("Emulator is down, skip close_game/goto_main action and wait with preheat")
377375
return self._wait_until_with_emulator_preheat(next_run)
378376

379-
close_game_limit_time = self.config.script.optimization.close_game_limit_time
380-
close_game_limit = self._time_to_timedelta(close_game_limit_time)
381-
if close_game_limit > timedelta(0) and next_run > datetime.now() + close_game_limit:
377+
close_game_wait_duration = self.config.script.optimization.close_game_wait_duration
378+
close_game_wait = self._time_to_timedelta(close_game_wait_duration)
379+
close_emulator_wait_duration = self.config.script.optimization.close_emulator_wait_duration
380+
close_emulator_wait = self._time_to_timedelta(close_emulator_wait_duration)
381+
382+
if close_emulator_wait > timedelta(0) and next_run > datetime.now() + close_emulator_wait:
383+
logger.info("Close emulator during wait")
384+
self.device.emulator_stop()
385+
self._emulator_down = True
386+
387+
if not self._wait_until_with_emulator_preheat(next_run):
388+
return False
389+
390+
self.run("Restart")
391+
return True
392+
393+
if close_game_wait <= timedelta(0):
382394
logger.info("Close game during wait")
383395
self.device.app_stop()
384396
self.device.release_during_wait()
@@ -387,7 +399,16 @@ def _wait_close_game(self, next_run: datetime) -> bool:
387399
self.run("Restart")
388400
return True
389401

390-
logger.info("Wait without closing game (close_game limit time not reached)")
402+
if next_run > datetime.now() + close_game_wait:
403+
logger.info("Close game during wait")
404+
self.device.app_stop()
405+
self.device.release_during_wait()
406+
if not self.wait_until(next_run):
407+
return False
408+
self.run("Restart")
409+
return True
410+
411+
logger.info("Wait without closing game (close_game wait duration not reached)")
391412
self.device.release_during_wait()
392413
if not self.wait_until(next_run):
393414
return False
@@ -398,29 +419,11 @@ def _wait_goto_main(self, next_run: datetime) -> bool:
398419
logger.info("Emulator is down, skip goto_main and wait with preheat")
399420
return self._wait_until_with_emulator_preheat(next_run)
400421

401-
logger.info("Goto main page during wait")
402-
self.run("GotoMain")
403-
self.device.release_during_wait()
404-
return self.wait_until(next_run)
405-
406-
def _wait_close_emulator_or_goto_main(self, next_run: datetime) -> bool:
407-
return self._wait_close_emulator_or(next_run, self._wait_goto_main)
408-
409-
def _wait_close_emulator_or_close_game(self, next_run: datetime) -> bool:
410-
return self._wait_close_emulator_or(next_run, self._wait_close_game)
411-
412-
def _wait_close_emulator_or(self, next_run: datetime, fallback_waiter: Callable[[datetime], bool]) -> bool:
413-
close_emulator_limit_time = self.config.script.optimization.close_emulator_limit_time
414-
close_emulator_limit = self._time_to_timedelta(close_emulator_limit_time)
415-
416-
now = datetime.now()
417-
if close_emulator_limit > timedelta(0) and next_run > now + close_emulator_limit:
422+
close_emulator_wait_duration = self.config.script.optimization.close_emulator_wait_duration
423+
close_emulator_wait = self._time_to_timedelta(close_emulator_wait_duration)
424+
if close_emulator_wait > timedelta(0) and next_run > datetime.now() + close_emulator_wait:
418425
logger.info("Close emulator during wait")
419-
if not self._emulator_down:
420-
self.device.emulator_stop()
421-
else:
422-
logger.info("Emulator already closed")
423-
426+
self.device.emulator_stop()
424427
self._emulator_down = True
425428

426429
if not self._wait_until_with_emulator_preheat(next_run):
@@ -429,7 +432,10 @@ def _wait_close_emulator_or(self, next_run: datetime, fallback_waiter: Callable[
429432
self.run("Restart")
430433
return True
431434

432-
return fallback_waiter(next_run)
435+
logger.info("Goto main page during wait")
436+
self.run("GotoMain")
437+
self.device.release_during_wait()
438+
return self.wait_until(next_run)
433439

434440
def _wait_stay_there(self, next_run: datetime) -> bool:
435441
if self._emulator_down:

tasks/Component/Costume/assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class CostumeAssets:
116116

117117
# Image Rule Assets
118118
# description
119-
I_CHECK_MAIN_4 = RuleImage(roi_front=(513,139,48,55), roi_back=(149,108,1068,100), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main4/main4_check_main_4.png")
119+
I_CHECK_MAIN_4 = RuleImage(roi_front=(885,192,37,32), roi_back=(149,108,1005,144), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main4/main4_check_main_4.png")
120120
# description
121121
I_MAIN_GOTO_EXPLORATION_4 = RuleImage(roi_front=(439,234,32,48), roi_back=(150,201,847,100), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main4/main4_main_goto_exploration_4.png")
122122
#

tasks/Component/Costume/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ShikigamiType(str, Enum):
4848
COSTUME_SHIKIGAMI_6 = 'costume_shikigami_6' # 月下火舞
4949
COSTUME_SHIKIGAMI_7 = 'costume_shikigami_7' # 赤溟幽界
5050
COSTUME_SHIKIGAMI_8 = 'costume_shikigami_8' # 童梦基地
51+
COSTUME_SHIKIGAMI_9 = 'costume_shikigami_9' # 眠鹿之森
5152

5253
# 签到主题
5354
class SignType(str, Enum):

tasks/Component/Costume/costume_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
'I_ST_SOULS': f'I_ST_SOULS_{i}',
7878
'I_ST_REPLACE': f'I_ST_REPLACE_{i}',
7979
}
80-
for i in range(1, 9) # 目前支持 COSTUME_SHIKIGAMI_1 到 COSTUME_SHIKIGAMI_8
80+
for i in range(1, 10) # 目前支持 COSTUME_SHIKIGAMI_1 到 COSTUME_SHIKIGAMI_9
8181
}
8282

8383
class CostumeBase:

tasks/Component/Costume/main4/image.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
"itemName": "check_main_4",
44
"imageName": "main4_check_main_4.png",
5-
"roiFront": "513,139,48,55",
6-
"roiBack": "149,108,1068,100",
5+
"roiFront": "885,192,37,32",
6+
"roiBack": "149,108,1005,144",
77
"method": "Template matching",
88
"threshold": 0.8,
99
"description": "description"
-1.37 KB
Loading

0 commit comments

Comments
 (0)