Skip to content

Commit 9e466d9

Browse files
authored
feat: 增加更多支援卡/允许ura剧本配置支援卡启发权重 (#202)
* feat: 支援卡选择页面框架 * feat: 重构支援卡保存结构,添加更多支援卡 * feat: 选择支援卡时渲染支援卡图片 * fix: 编译和小型调整前端 * feat: 允许ura剧本配置支援卡启发权重
1 parent 947d54c commit 9e466d9

File tree

167 files changed

+1840
-875
lines changed

Some content is hidden

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

167 files changed

+1840
-875
lines changed

module/umamusume/scenario/configs.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
class UraConfig:
2+
skill_event_weight: list[int]
3+
reset_skill_event_weight_list: list[str]
4+
5+
def __init__(self, config: dict):
6+
if "skillEventWeight" not in config or "resetSkillEventWeightList" not in config:
7+
raise ValueError("错误的配置: 必须配置 'skillEventWeight' 和 'resetSkillEventWeightList'")
8+
self.skill_event_weight = config["skillEventWeight"]
9+
self.reset_skill_event_weight_list = config["resetSkillEventWeightList"]
10+
11+
def removeSkillFromList(self, skill: str):
12+
if skill in self.reset_skill_event_weight_list:
13+
self.reset_skill_event_weight_list.remove(skill)
14+
# 如果技能列表空了, 重置权重
15+
# 如果一开始列表就是空的, 这个分支就不会触发, 也不会重置权重
16+
if len(self.reset_skill_event_weight_list) == 0:
17+
self.skill_event_weight = [0, 0, 0]
18+
19+
def getSkillEventWeight(self, date: int) -> int:
20+
if date <= 24:
21+
return self.skill_event_weight[0]
22+
elif date <= 48:
23+
return self.skill_event_weight[1]
24+
else:
25+
return self.skill_event_weight[2]
26+
127
class AoharuConfig:
228

329
preliminary_round_selections: list[int]
@@ -17,8 +43,9 @@ def get_opponent(self, round_index: int) -> int:
1743

1844
class ScenarioConfig:
1945
""" 所有场景的配置 """
20-
46+
ura_config: UraConfig = None
2147
aoharu_config: AoharuConfig = None
2248

23-
def __init__(self, aoharu_config: AoharuConfig = None):
49+
def __init__(self, ura_config: UraConfig = None, aoharu_config: AoharuConfig = None):
50+
self.ura_config = ura_config
2451
self.aoharu_config = aoharu_config

module/umamusume/script/cultivate_task/ai.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def get_operation(ctx: UmamusumeContext) -> TurnOperation | None:
1414
attribute_result = get_training_basic_attribute_score(ctx, ctx.cultivate_detail.turn_info,
1515
ctx.cultivate_detail.expect_attribute)
1616
support_card_result = get_training_support_card_score(ctx)
17+
support_card_event_result = get_support_card_event_score(ctx)
1718
training_level_result = get_training_level_score(ctx)
1819

1920
attribute_result_max = np.max(attribute_result)
@@ -79,7 +80,8 @@ def get_operation(ctx: UmamusumeContext) -> TurnOperation | None:
7980
training_score = []
8081
for i in range(5):
8182
training_score.append(normalized_attribute_result[i] * attr_weight + normalized_support_card_result[i] *
82-
support_card_weight + normalized_training_level_result[i] * training_level_weight)
83+
support_card_weight + normalized_training_level_result[i] * training_level_weight +
84+
support_card_event_result[i])
8385
# 将权重为-1的训练得分置为0
8486
extra_weight = [0, 0, 0, 0, 0]
8587
date = ctx.cultivate_detail.turn_info.date
@@ -151,7 +153,7 @@ def get_training_level_score(ctx: UmamusumeContext):
151153
result = []
152154
for i in range(len(expect_attribute)):
153155
result.append(expect_attribute[i] / sum(expect_attribute) * total_score)
154-
log.debug("每个训练设施的得分" + str(result))
156+
log.debug("每个训练设施的得分: " + str(result))
155157
return result
156158

157159

@@ -163,7 +165,26 @@ def get_training_support_card_score(ctx: UmamusumeContext) -> list[float]:
163165
for j in range(len(turn_info.training_info_list[i].support_card_info_list)):
164166
score += get_support_card_score(ctx, turn_info.training_info_list[i].support_card_info_list[j])
165167
result.append(score)
166-
log.debug("每个训练的支援卡得分:" + str(result))
168+
log.debug("每个训练的支援卡得分: " + str(result))
169+
return result
170+
171+
def get_support_card_event_score(ctx: UmamusumeContext) -> list[float]:
172+
# 只对URA有效
173+
if ctx.task.detail.scenario != ScenarioType.SCENARIO_TYPE_URA:
174+
return [0, 0, 0, 0, 0]
175+
turn_info = ctx.cultivate_detail.turn_info
176+
result = []
177+
for i in range (len(turn_info.training_info_list)):
178+
has_event = False
179+
for j in range(len(turn_info.training_info_list[i].support_card_info_list)):
180+
if turn_info.training_info_list[i].support_card_info_list[j].has_event:
181+
has_event = True
182+
break
183+
if has_event:
184+
result.append(1*ctx.task.detail.scenario_config.ura_config.getSkillEventWeight(ctx.cultivate_detail.turn_info.date))
185+
else:
186+
result.append(0)
187+
log.debug("每个训练的事件得分: " + str(result))
167188
return result
168189

169190

module/umamusume/script/cultivate_task/cultivate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,12 @@ def script_cultivate_learn_skill(ctx: UmamusumeContext):
526526
if skill_list[k]["skill_name"] == skill_list[j]["subsequent_skill"]:
527527
skill_list[k]["available"] = False
528528

529+
# 如果是URA, 标记已经学习的技能, 可能会用于重置启发事件权重
530+
# 由于上面计算过技能pt,可以保证list里面的技能都会被学到
531+
if ctx.task.detail.scenario == ScenarioType.SCENARIO_TYPE_URA:
532+
for skill in target_skill_list:
533+
ctx.task.detail.scenario_config.ura_config.removeSkillFromList(skill)
534+
529535
# 向上移动至对齐
530536
ctx.ctrl.swipe(x1=23, y1=950, x2=23, y2=968, duration=100, name="")
531537
time.sleep(1)

module/umamusume/task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def build_task(task_execute_mode: TaskExecuteMode, task_type: int,
6868
td.cultivate_result = {}
6969
# 剧本相关设置
7070
td.scenario_config = ScenarioConfig(
71-
aoharu_config=None if (attachment_data['aoharu_config'] is None) else AoharuConfig(attachment_data['aoharu_config']))
71+
ura_config = None if (attachment_data['ura_config'] is None) else UraConfig(attachment_data['ura_config']),
72+
aoharu_config = None if (attachment_data['aoharu_config'] is None) else AoharuConfig(attachment_data['aoharu_config']))
7273
# 限时: 富士奇石的表演秀
7374
td.fujikiseki_show_mode = attachment_data['fujikiseki_show_mode']
7475
td.fujikiseki_show_difficulty = attachment_data['fujikiseki_show_difficulty']

public/assets/10001.f296c5bf.png

61.8 KB

public/assets/10002.42e4b022.png

65.1 KB

public/assets/10003.015e898e.png

63.4 KB

public/assets/10004.4c60d0af.png

63.8 KB

public/assets/10005.bea82129.png

64.3 KB

public/assets/10006.655a518b.png

67.3 KB

0 commit comments

Comments
 (0)