Skip to content

Commit 6b3bd44

Browse files
authored
feat: 技能学习更新和优化 (#219)
* ci: 仅在release时编译 * feat: 优化若干技能学习功能
1 parent 54e0924 commit 6b3bd44

File tree

13 files changed

+872
-880
lines changed

13 files changed

+872
-880
lines changed

.github/workflows/python-build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ name: Python Build and Release
22

33
on:
44
push:
5-
branches:
6-
- '**'
75
tags:
86
- 'v*'
9-
pull_request:
10-
branches:
11-
- '**'
127

138
concurrency:
149
group: ${{ github.workflow }}-${{ github.ref }}

bot/base/localization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class LocalizationMap:
5151
RACE_TACTIC_TYPE_ESCAPE = '领跑'
5252

5353
TASK_STATUS_INVALID = '任务无效'
54-
TASK_STATUS_PENDING = '任务暂停'
55-
TASK_STATUS_RUNNING = '任务运行'
56-
TASK_STATUS_INTERRUPT = '任务被打断'
54+
TASK_STATUS_PENDING = '任务等待中'
55+
TASK_STATUS_RUNNING = '任务运行中'
56+
TASK_STATUS_INTERRUPT = '任务被中断'
5757
TASK_STATUS_SUCCESS = '任务完成'
5858
TASK_STATUS_FAILED = '任务失败'
5959
TASK_STATUS_SCHEDULED = '任务定时'

bot/base/task.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ class TaskStatus(Enum):
2929

3030
class EndTaskReason(Enum):
3131
COMPLETE = "任务已完成"
32+
STOP_AT_SKILL_LEARN = "任务完成并在学习技能页面停止"
3233
MANUAL_ABORTED = "任务被手动中止"
34+
CANCELLED_DUE_TO_STOP_AT_SKILL_LEARN = "因其它任务等待学习技能而取消"
3335
SYSTEM_ERROR = "系统异常"
3436
SCENARIO_NOT_FOUND = "找不到育成剧本"
3537

module/umamusume/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CultivateContextDetail:
2626
learn_skill_threshold: int
2727
learn_skill_only_user_provided: bool
2828
learn_skill_before_race: bool
29+
learn_skill_cooldown: int
2930
allow_recover_tp: bool
3031
parse_factor_done: bool
3132
extra_weight: list
@@ -44,6 +45,7 @@ def __init__(self):
4445
self.debut_race_win = False
4546
self.clock_use_limit = 0
4647
self.clock_used = 0
48+
self.learn_skill_cooldown = 0
4749
self.allow_recover_tp = False
4850
self.parse_factor_done = False
4951
self.extra_weight = []

module/umamusume/script/cultivate_task/cultivate.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66

77
from bot.base.task import TaskStatus, EndTaskReason
8+
from bot.engine.scheduler import scheduler
89
from module.umamusume.asset.point import *
910
from module.umamusume.types import TurnInfo
1011
from module.umamusume.script.cultivate_task.const import SKILL_LEARN_PRIORITY_LIST
@@ -28,6 +29,8 @@ def script_cultivate_main_menu(ctx: UmamusumeContext):
2829
ctx.cultivate_detail.turn_info.date = current_date
2930
log.debug("进入新回合,日期:" + str(current_date))
3031
ctx.cultivate_detail.reset_skill_learn()
32+
# 进入新会合后降低技能学习冷却倒计时
33+
ctx.cultivate_detail.learn_skill_cooldown = max(0, ctx.cultivate_detail.learn_skill_cooldown - 1)
3134

3235
# 解析主界面
3336
if not ctx.cultivate_detail.turn_info.parse_main_menu_finish:
@@ -42,7 +45,11 @@ def script_cultivate_main_menu(ctx: UmamusumeContext):
4245

4346
if (ctx.cultivate_detail.turn_info.uma_attribute.skill_point > ctx.cultivate_detail.learn_skill_threshold
4447
and not ctx.cultivate_detail.turn_info.turn_learn_skill_done):
45-
if len(ctx.cultivate_detail.learn_skill_list) > 0 or not ctx.cultivate_detail.learn_skill_only_user_provided:
48+
if (any(len(skill_list) for skill_list in ctx.cultivate_detail.learn_skill_list) \
49+
or not ctx.cultivate_detail.learn_skill_only_user_provided) \
50+
and ctx.cultivate_detail.learn_skill_cooldown == 0:
51+
# 如果只允许学习用户的技能, 且技能列表为空,则不学习技能
52+
# 如果冷却倒计时为0, 则可以学习技能 (无需判断是否育成结束)
4653
ctx.ctrl.click_by_point(CULTIVATE_SKILL_LEARN)
4754
else:
4855
ctx.cultivate_detail.learn_skill_done = True
@@ -452,6 +459,16 @@ def script_cultivate_finish(ctx: UmamusumeContext):
452459

453460

454461
def script_cultivate_learn_skill(ctx: UmamusumeContext):
462+
# 如果指定育成结束后停留在学习技能页面:
463+
if ctx.cultivate_detail.cultivate_finish and ctx.task.detail.stop_at_skill_learn:
464+
ctx.task.end_task(TaskStatus.TASK_STATUS_SUCCESS, EndTaskReason.STOP_AT_SKILL_LEARN)
465+
# 终止所有待处理任务
466+
task_list = scheduler.get_task_list()
467+
for task in task_list:
468+
if task.task_status == TaskStatus.TASK_STATUS_PENDING:
469+
task.end_task(TaskStatus.TASK_STATUS_FAILED, EndTaskReason.CANCELLED_DUE_TO_STOP_AT_SKILL_LEARN)
470+
return
471+
455472
if ctx.cultivate_detail.learn_skill_done:
456473
if ctx.cultivate_detail.learn_skill_selected:
457474
ctx.ctrl.click_by_point(CULTIVATE_LEARN_SKILL_CONFIRM)
@@ -461,13 +478,13 @@ def script_cultivate_learn_skill(ctx: UmamusumeContext):
461478
learn_skill_list: list[list[str]]
462479
learn_skill_blacklist: list[str] = ctx.cultivate_detail.learn_skill_blacklist
463480
if ctx.cultivate_detail.cultivate_finish or not ctx.cultivate_detail.learn_skill_only_user_provided:
464-
if len(ctx.cultivate_detail.learn_skill_list) == 0:
481+
if not any(len(skill_list) for skill_list in ctx.cultivate_detail.learn_skill_list):
465482
learn_skill_list = SKILL_LEARN_PRIORITY_LIST
466483
else:
467484
#如果用户自定义了技能优先级,那么不再采用预设的优先级
468485
learn_skill_list = ctx.cultivate_detail.learn_skill_list
469486
else:
470-
if len(ctx.cultivate_detail.learn_skill_list) == 0:
487+
if not any(len(skill_list) for skill_list in ctx.cultivate_detail.learn_skill_list):
471488
ctx.ctrl.click_by_point(RETURN_TO_CULTIVATE_FINISH)
472489
ctx.cultivate_detail.learn_skill_done = True
473490
ctx.cultivate_detail.turn_info.turn_learn_skill_done = True
@@ -548,6 +565,10 @@ def script_cultivate_learn_skill(ctx: UmamusumeContext):
548565
#如果一个优先级全为空,则直接将其删除
549566
ctx.cultivate_detail.learn_skill_list = [x for x in ctx.cultivate_detail.learn_skill_list if x != []]
550567

568+
if len(target_skill_list) == 0:
569+
# 如果什么技能都没学, 则至少冷却12回合后再检查
570+
ctx.cultivate_detail.learn_skill_cooldown = 12
571+
551572
# 点技能
552573
while True:
553574
img = ctx.ctrl.get_screen()

module/umamusume/task.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class TaskDetail:
1616
clock_use_limit: int
1717
learn_skill_threshold: int
1818
learn_skill_only_user_provided: bool
19+
stop_at_skill_learn: bool
1920
allow_recover_tp: bool
2021
cultivate_progress_info: dict
2122
extra_weight: list
@@ -63,6 +64,7 @@ def build_task(task_execute_mode: TaskExecuteMode, task_type: int,
6364
td.clock_use_limit = attachment_data['clock_use_limit']
6465
td.learn_skill_threshold = attachment_data['learn_skill_threshold']
6566
td.learn_skill_only_user_provided = attachment_data['learn_skill_only_user_provided']
67+
td.stop_at_skill_learn = attachment_data['stop_at_skill_learn']
6668
td.allow_recover_tp = attachment_data['allow_recover_tp']
6769
td.extra_weight = attachment_data['extra_weight']
6870
td.cultivate_result = {}

module/umamusume/types.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -151,50 +151,3 @@ def log_turn_info(self, scenario_type : ScenarioType):
151151
self.training_info_list[3].log_training_info(scenario_type)
152152
log.info("智力训练结果:")
153153
self.training_info_list[4].log_training_info(scenario_type)
154-
155-
156-
class CultivateContextDetail:
157-
turn_info: TurnInfo | None
158-
turn_info_history: list[TurnInfo]
159-
scenario : "base_scenario.BaseScenario"
160-
expect_attribute: list[int] | None
161-
follow_support_card_name: str
162-
follow_support_card_level: int
163-
extra_race_list: list[int]
164-
learn_skill_list: list[list[str]]
165-
learn_skill_blacklist: list[str]
166-
learn_skill_done: bool
167-
learn_skill_selected: bool
168-
cultivate_finish: bool
169-
tactic_list: list[int]
170-
debut_race_win: bool
171-
clock_use_limit: int
172-
clock_used: int
173-
learn_skill_threshold: int
174-
learn_skill_only_user_provided: bool
175-
learn_skill_before_race: bool
176-
allow_recover_tp: bool
177-
parse_factor_done: bool
178-
extra_weight: list
179-
180-
def __init__(self):
181-
self.expect_attribute = None
182-
self.turn_info = TurnInfo()
183-
self.turn_info_history = []
184-
self.extra_race_list = []
185-
self.learn_skill_list = []
186-
self.learn_skill_blacklist = []
187-
self.learn_skill_done = False
188-
self.learn_skill_selected = False
189-
self.cultivate_finish = False
190-
self.tactic_list = []
191-
self.debut_race_win = False
192-
self.clock_use_limit = 0
193-
self.clock_used = 0
194-
self.allow_recover_tp = False
195-
self.parse_factor_done = False
196-
self.extra_weight = []
197-
198-
def reset_skill_learn(self):
199-
self.learn_skill_done = False
200-
self.learn_skill_selected = False

public/assets/index.161d56bd.js

Lines changed: 810 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/index.3df44b70.css renamed to public/assets/index.5ae02e0c.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/index.aab249b5.js

Lines changed: 0 additions & 810 deletions
This file was deleted.

0 commit comments

Comments
 (0)