feat(task): 培育中支持优先选择 SP 课程

This commit is contained in:
XcantloadX 2025-03-02 21:15:49 +08:00
parent 47287fdc19
commit ee3808c58d
5 changed files with 40 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 KiB

View File

@ -0,0 +1 @@
{"definitions":{"d982d2b5-4bc0-4ae9-a516-f29c2848d64b":{"name":"InPurodyuusu.IconSp","displayName":"SP 课程图标","type":"template","annotationId":"d982d2b5-4bc0-4ae9-a516-f29c2848d64b","useHintRect":false}},"annotations":[{"id":"d982d2b5-4bc0-4ae9-a516-f29c2848d64b","type":"rect","data":{"x1":188,"y1":926,"x2":220,"y2":952}}]}

View File

@ -9,7 +9,6 @@ import cv2
import numpy as np
from cv2.typing import MatLike
from .. import R
from . import loading
from ..common import conf
@ -80,6 +79,20 @@ def enter_recommended_action_ocr(final_week: bool = False) -> ActionType:
device.double_click(image.expect_wait(template))
return 'lesson'
@action('执行 SP 课程')
def handle_sp_lesson():
"""
执行 SP 课程
前置条件行动页面\n
结束状态练习场景以及中间可能出现的加载支援卡奖励交流等
"""
if image.find(R.InPurodyuusu.IconSp) is not None:
device.double_click(image.expect(R.InPurodyuusu.IconSp))
return True
else:
return False
@action('执行推荐行动')
def handle_recommended_action(final_week: bool = False) -> ActionType:
"""
@ -754,7 +767,14 @@ def produce_end():
def week_normal(week_first: bool = False):
until_action_scene(week_first)
executed_action = handle_recommended_action()
# SP 课程
if (
conf().produce.prefer_lesson_ap
and handle_sp_lesson()
):
executed_action = 'lesson'
else:
executed_action = handle_recommended_action()
logger.info("Executed recommended action: %s", executed_action)
# 推荐练习
if executed_action == 'lesson':

View File

@ -333,7 +333,13 @@ class ProduceConfig(ConfigBaseModel):
"""是否关注租借了支援卡的制作人。"""
self_study_lesson: Literal['dance', 'visual', 'vocal'] = 'dance'
"""自习课类型。"""
prefer_lesson_ap: bool = False
"""
优先 SP 课程
启用后若出现 SP 课程则会优先执行 SP 课程而不是推荐课程
若出现多个 SP 课程随机选择一个
"""
class MissionRewardConfig(ConfigBaseModel):
enabled: bool = False

View File

@ -251,6 +251,7 @@ class KotoneBotUI:
use_note_boost: bool,
follow_producer: bool,
self_study_lesson: Literal['dance', 'visual', 'vocal'],
prefer_lesson_ap: bool,
mission_reward_enabled: bool,
) -> str:
ap_items_enum: List[Literal[0, 1, 2, 3]] = []
@ -304,7 +305,8 @@ class KotoneBotUI:
use_pt_boost=use_pt_boost,
use_note_boost=use_note_boost,
follow_producer=follow_producer,
self_study_lesson=self_study_lesson
self_study_lesson=self_study_lesson,
prefer_lesson_ap=prefer_lesson_ap
),
mission_reward=MissionRewardConfig(
enabled=mission_reward_enabled
@ -499,7 +501,7 @@ class KotoneBotUI:
)
return assignment_enabled, mini_live_reassign, mini_live_duration, online_live_reassign, online_live_duration
def _create_produce_settings(self) -> Tuple[gr.Checkbox, gr.Dropdown, gr.Number, gr.Dropdown, gr.Dropdown, gr.Checkbox, gr.Checkbox, gr.Checkbox, gr.Checkbox, gr.Checkbox, gr.Dropdown]:
def _create_produce_settings(self):
with gr.Column():
gr.Markdown("### 培育设置")
produce_enabled = gr.Checkbox(
@ -573,6 +575,11 @@ class KotoneBotUI:
label='文化课自习时选项',
info='选择自习课类型'
)
prefer_lesson_ap = gr.Checkbox(
label="SP 课程优先",
value=self.current_config.options.produce.prefer_lesson_ap,
info=ProduceConfig.model_fields['prefer_lesson_ap'].description
)
produce_enabled.change(
fn=lambda x: gr.Group(visible=x),
@ -585,7 +592,7 @@ class KotoneBotUI:
inputs=[auto_set_memory],
outputs=[memory_sets_group]
)
return produce_enabled, produce_mode, produce_count, produce_idols, memory_sets, auto_set_memory, auto_set_support, use_pt_boost, use_note_boost, follow_producer, self_study_lesson
return produce_enabled, produce_mode, produce_count, produce_idols, memory_sets, auto_set_memory, auto_set_support, use_pt_boost, use_note_boost, follow_producer, self_study_lesson, prefer_lesson_ap
def _create_settings_tab(self) -> None:
with gr.Tab("设置"):