Skip to content

Commit 66d69ef

Browse files
authored
feat: 增加钻石回复体力 (#221)
1 parent c0668f1 commit 66d69ef

File tree

13 files changed

+63
-33
lines changed

13 files changed

+63
-33
lines changed

bot/base/task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class EndTaskReason(Enum):
3434
CANCELLED_DUE_TO_STOP_AT_SKILL_LEARN = "因其它任务等待学习技能而取消"
3535
SYSTEM_ERROR = "系统异常"
3636
SCENARIO_NOT_FOUND = "找不到育成剧本"
37+
UMAMUSUME_HALL_FULL = "名人堂优俊少女已满"
3738

3839

3940
class Task(metaclass=ABCMeta):

module/umamusume/asset/point.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102

103103
TO_RECOVER_TP = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(520, 830), "回复训练值", None)
104104
USE_TP_DRINK = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(610, 320), "使用tp饮料", None)
105+
USE_DIAMOND_RECOVER_TP = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(610, 180), "使用钻石回复tp", None)
106+
USE_DIAMOND_RECOVER_TP_ADD = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(520, 670), "", None)
105107
USE_TP_DRINK_CONFIRM = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(525, 920), "使用tp饮料-确认", None)
108+
USE_DIAMOND_RECOVER_CONFIRM = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(525, 920), "使用钻石回复tp-确认", None)
106109
USE_TP_DRINK_RESULT_CLOSE = ClickPoint(ClickPointType.CLICK_POINT_TYPE_COORDINATE, None, Coordinate(360, 835), "回复完成-关闭", None)
107110

module/umamusume/asset/template.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,14 @@
145145

146146
REF_RECOVER_TP_1 = Template("RECOVER_TP_1", UMAMUSUME_REF_TEMPLATE_PATH)
147147
REF_RECOVER_TP_2 = Template("RECOVER_TP_2", UMAMUSUME_REF_TEMPLATE_PATH)
148+
REF_RECOVER_TP_2_DIAMOND = Template("RECOVER_TP_2_DIAMOND", UMAMUSUME_REF_TEMPLATE_PATH)
148149
REF_RECOVER_TP_3 = Template("RECOVER_TP_3", UMAMUSUME_REF_TEMPLATE_PATH)
150+
REF_RECOVER_TP_3_DIAMOND = Template("RECOVER_TP_3_DIAMOND", UMAMUSUME_REF_TEMPLATE_PATH)
149151

150152
REF_FACTOR_DETECT_LABEL = Template("FACTOR_DETECT_LABEL", UMAMUSUME_REF_TEMPLATE_PATH)
151153

154+
REF_TP_RECOVER_DRINK = Template("TP_RECOVER_DRINK", UMAMUSUME_REF_TEMPLATE_PATH)
155+
152156
URA_DATE_1 = Template("URA_DATE_1", UMAMUSUME_REF_TEMPLATE_PATH)
153157
URA_DATE_2 = Template("URA_DATE_2", UMAMUSUME_REF_TEMPLATE_PATH)
154158

module/umamusume/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CultivateContextDetail:
2727
learn_skill_only_user_provided: bool
2828
learn_skill_before_race: bool
2929
learn_skill_cooldown: int
30-
allow_recover_tp: bool
30+
allow_recover_tp: int
3131
parse_factor_done: bool
3232
extra_weight: list
3333

module/umamusume/script/cultivate_task/info.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
# 青春杯
5252
"自动编成",
5353
"对战确认",
54+
# TODO: 重新修改编号方便添加新的title
55+
"名人堂优俊少女上限",
5456
]
5557

5658

@@ -139,16 +141,32 @@ def script_info(ctx: UmamusumeContext):
139141
if title_text == TITLE[25]:
140142
ctx.ctrl.click_by_point(ACTIVITY_STORY_UNLOCK_CONFIRM)
141143
if title_text == TITLE[26]:
142-
if not ctx.cultivate_detail.allow_recover_tp:
144+
if ctx.cultivate_detail.allow_recover_tp == 0: # 不允许用体力药或者钻石
143145
ctx.task.end_task(TaskStatus.TASK_STATUS_FAILED, UEndTaskReason.TP_NOT_ENOUGH)
144146
else:
145147
ctx.ctrl.click_by_point(TO_RECOVER_TP)
146148
if title_text == TITLE[27]:
147-
if image_match(ctx.ctrl.get_screen(to_gray=True), REF_RECOVER_TP_1).find_match:
148-
ctx.ctrl.click_by_point(USE_TP_DRINK)
149-
elif image_match(ctx.ctrl.get_screen(to_gray=True), REF_RECOVER_TP_2).find_match:
149+
# 到这里时, 一定已经允许恢复体力了
150+
screen = ctx.ctrl.get_screen(to_gray=True)
151+
if image_match(screen, REF_RECOVER_TP_1).find_match:
152+
if image_match(screen, REF_TP_RECOVER_DRINK).find_match: # 如果还有tp饮料, 就直接喝饮料
153+
ctx.ctrl.click_by_point(USE_TP_DRINK)
154+
else:
155+
# TODO: 没有考虑钻石也没了的情况
156+
if ctx.cultivate_detail.allow_recover_tp == 2: # 允许用钻石回复TP
157+
ctx.ctrl.click_by_point(USE_DIAMOND_RECOVER_TP)
158+
else: # 只允许用体力药
159+
# 直接结束任务
160+
ctx.task.end_task(TaskStatus.TASK_STATUS_FAILED, UEndTaskReason.TP_DRINK_NOT_ENOUGH)
161+
162+
elif image_match(screen, REF_RECOVER_TP_2).find_match:
150163
ctx.ctrl.click_by_point(USE_TP_DRINK_CONFIRM)
151-
elif image_match(ctx.ctrl.get_screen(to_gray=True), REF_RECOVER_TP_3).find_match:
164+
elif image_match(screen, REF_RECOVER_TP_2_DIAMOND).find_match:
165+
ctx.ctrl.click_by_point(USE_DIAMOND_RECOVER_TP_ADD)
166+
time.sleep(2)
167+
ctx.ctrl.click_by_point(USE_DIAMOND_RECOVER_CONFIRM)
168+
elif image_match(screen, REF_RECOVER_TP_3).find_match or\
169+
image_match(screen, REF_RECOVER_TP_3_DIAMOND).find_match:
152170
ctx.ctrl.click_by_point(USE_TP_DRINK_RESULT_CLOSE)
153171
if title_text == TITLE[28]:
154172
# 限时: 富士奇石的表演秀
@@ -190,5 +208,7 @@ def script_info(ctx: UmamusumeContext):
190208
if title_text == TITLE[32]:
191209
# 确认青春杯对手
192210
ctx.ctrl.click(520, 920, "确认对战")
211+
if title_text == TITLE[33]:
212+
ctx.task.end_task(TaskStatus.TASK_STATUS_FAILED, EndTaskReason.UMAMUSUME_HALL_FULL)
193213
time.sleep(1)
194214

module/umamusume/task.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TaskDetail:
1717
learn_skill_threshold: int
1818
learn_skill_only_user_provided: bool
1919
stop_at_skill_learn: bool
20-
allow_recover_tp: bool
20+
allow_recover_tp: int # 0=仅使用TP(不自动恢复), 1=使用体力药, 2=体力药+钻石
2121
cultivate_progress_info: dict
2222
extra_weight: list
2323
# 剧本相关配置
@@ -29,6 +29,7 @@ class TaskDetail:
2929

3030
class EndTaskReason(Enum):
3131
TP_NOT_ENOUGH = "训练值不足"
32+
TP_DRINK_NOT_ENOUGH = "体力药不足"
3233
DIFFICULTY_LOCKED = "难度未解锁"
3334

3435

@@ -65,7 +66,7 @@ def build_task(task_execute_mode: TaskExecuteMode, task_type: int,
6566
td.learn_skill_threshold = attachment_data['learn_skill_threshold']
6667
td.learn_skill_only_user_provided = attachment_data['learn_skill_only_user_provided']
6768
td.stop_at_skill_learn = attachment_data['stop_at_skill_learn']
68-
td.allow_recover_tp = attachment_data['allow_recover_tp']
69+
td.allow_recover_tp = int(attachment_data['allow_recover_tp'])
6970
td.extra_weight = attachment_data['extra_weight']
7071
td.cultivate_result = {}
7172
# 剧本相关设置

public/assets/index.3757966e.css renamed to public/assets/index.67b15802.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.e7e7ff2c.js renamed to public/assets/index.fa80c008.js

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

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<meta charset="utf-8">
99
<meta http-equiv="X-UA-Compatible" content="IE=edge">
1010
<meta name="viewport" content="width=device-width,initial-scale=1.0">
11-
<script type="module" crossorigin src="./assets/index.e7e7ff2c.js"></script>
12-
<link rel="stylesheet" href="./assets/index.3757966e.css">
11+
<script type="module" crossorigin src="./assets/index.fa80c008.js"></script>
12+
<link rel="stylesheet" href="./assets/index.67b15802.css">
1313
</head>
1414
<body>
1515
<div id="app"></div>
7.68 KB
Loading

0 commit comments

Comments
 (0)