feat(task): 正式支持 PRO 培育
This commit is contained in:
parent
73eb541ecf
commit
19e6fa5167
|
@ -223,7 +223,6 @@ def until_acquisition_clear():
|
|||
|
||||
@action('处理交流事件', screenshot_mode='manual-inherit')
|
||||
def commut_event():
|
||||
img = device.screenshot()
|
||||
ui = CommuEventButtonUI()
|
||||
buttons = ui.all(description=False, title=True)
|
||||
if buttons:
|
||||
|
|
|
@ -272,8 +272,11 @@ class ContestConfig(ConfigBaseModel):
|
|||
class ProduceConfig(ConfigBaseModel):
|
||||
enabled: bool = False
|
||||
"""是否启用培育"""
|
||||
mode: Literal['regular'] = 'regular'
|
||||
"""培育模式。"""
|
||||
mode: Literal['regular', 'pro'] = 'regular'
|
||||
"""
|
||||
培育模式。
|
||||
进行一次 REGULAR 培育需要 ~30min,进行一次 PRO 培育需要 ~1h。
|
||||
"""
|
||||
produce_count: int = 1
|
||||
"""培育的次数。"""
|
||||
idols: list[PIdol] = []
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import logging
|
||||
from itertools import cycle
|
||||
from typing import Optional
|
||||
from typing import Optional, Literal
|
||||
|
||||
from kotonebot.backend.dispatch import SimpleDispatcher
|
||||
from kotonebot.backend.util import Countdown, Interval
|
||||
from kotonebot.ui import user
|
||||
from kotonebot.backend.util import Countdown
|
||||
from kotonebot.backend.dispatch import SimpleDispatcher
|
||||
|
||||
from . import R
|
||||
from .common import conf, PIdol
|
||||
from .game_ui import button_state
|
||||
from .actions.scenes import at_home, goto_home
|
||||
from .actions.in_purodyuusu import hajime_regular
|
||||
from kotonebot import device, image, ocr, task, action, sleep, equals, contains, Rect
|
||||
from .actions.in_purodyuusu import hajime_pro, hajime_regular
|
||||
from kotonebot import device, image, ocr, task, action, sleep, equals, contains
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -116,7 +115,7 @@ def resume_produce():
|
|||
device.click(image.expect_wait(R.Produce.ButtonResume))
|
||||
|
||||
@action('执行培育', screenshot_mode='manual-inherit')
|
||||
def do_produce(idol: PIdol):
|
||||
def do_produce(idol: PIdol, mode: Literal['regular', 'pro']):
|
||||
"""
|
||||
进行培育流程
|
||||
|
||||
|
@ -124,6 +123,7 @@ def do_produce(idol: PIdol):
|
|||
结束状态:游戏首页\n
|
||||
|
||||
:param idol: 要培育的偶像。如果为 None,则使用配置文件中的偶像。
|
||||
:param mode: 培育模式。
|
||||
"""
|
||||
if not at_home():
|
||||
goto_home()
|
||||
|
@ -136,9 +136,10 @@ def do_produce(idol: PIdol):
|
|||
return
|
||||
|
||||
# 0. 进入培育页面
|
||||
mode_text = 'REGULAR' if mode == 'regular' else 'PRO'
|
||||
(SimpleDispatcher('enter_produce')
|
||||
.click(R.Produce.ButtonProduce)
|
||||
.click(contains('REGULAR'))
|
||||
.click(contains(mode_text))
|
||||
.until(R.Produce.ButtonPIdolOverview)
|
||||
).run()
|
||||
# 1. 选择 PIdol [screenshots/produce/select_p_idol.png]
|
||||
|
@ -172,17 +173,23 @@ def do_produce(idol: PIdol):
|
|||
device.click()
|
||||
if image.find(R.Common.ButtonConfirmNoIcon):
|
||||
device.click()
|
||||
hajime_regular()
|
||||
if mode == 'regular':
|
||||
hajime_regular()
|
||||
else:
|
||||
hajime_pro()
|
||||
|
||||
@task('培育')
|
||||
def produce_task(count: Optional[int] = None, idols: Optional[list[PIdol]] = None):
|
||||
def produce_task(
|
||||
mode: Literal['regular', 'pro'] | None = None,
|
||||
count: Optional[int] = None,
|
||||
idols: Optional[list[PIdol]] = None
|
||||
):
|
||||
"""
|
||||
培育任务
|
||||
|
||||
:param count:
|
||||
培育次数。若为 None,则从配置文件中读入。
|
||||
:param idols:
|
||||
要培育的偶像。若为 None,则从配置文件中读入。
|
||||
:param mode: 培育模式。若为 None,则从配置文件中读入。
|
||||
:param count: 培育次数。若为 None,则从配置文件中读入。
|
||||
:param idols: 要培育的偶像。若为 None,则从配置文件中读入。
|
||||
"""
|
||||
if not conf().produce.enabled:
|
||||
logger.info('Produce is disabled.')
|
||||
|
@ -192,6 +199,8 @@ def produce_task(count: Optional[int] = None, idols: Optional[list[PIdol]] = Non
|
|||
count = conf().produce.produce_count
|
||||
if idols is None:
|
||||
idols = conf().produce.idols
|
||||
if mode is None:
|
||||
mode = conf().produce.mode
|
||||
# 数据验证
|
||||
if count < 0:
|
||||
user.warning('培育次数不能小于 0。将跳过本次培育。')
|
||||
|
@ -200,7 +209,7 @@ def produce_task(count: Optional[int] = None, idols: Optional[list[PIdol]] = Non
|
|||
idol_iterator = cycle(idols)
|
||||
for _ in range(count):
|
||||
start_time = time.time()
|
||||
do_produce(next(idol_iterator))
|
||||
do_produce(next(idol_iterator), mode)
|
||||
end_time = time.time()
|
||||
logger.info(f"Produce time used: {format_time(end_time - start_time)}")
|
||||
|
||||
|
@ -209,6 +218,6 @@ if __name__ == '__main__':
|
|||
logging.basicConfig(level=logging.INFO, format='[%(asctime)s] [%(levelname)s] [%(name)s] [%(funcName)s] [%(lineno)d] %(message)s')
|
||||
logging.getLogger('kotonebot').setLevel(logging.DEBUG)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
do_produce(conf().produce.idols[0])
|
||||
do_produce(conf().produce.idols[0], 'pro')
|
||||
# a()
|
||||
# select_idol(PIdol.藤田ことね_学園生活)
|
|
@ -331,7 +331,7 @@ class KotoneBotUI:
|
|||
)
|
||||
with gr.Group(visible=self.current_config.options.produce.enabled) as produce_group:
|
||||
produce_mode = gr.Dropdown(
|
||||
choices=["regular"],
|
||||
choices=["regular", "pro"],
|
||||
value=self.current_config.options.produce.mode,
|
||||
label="培育模式",
|
||||
info=ProduceConfig.model_fields['mode'].description
|
||||
|
|
Loading…
Reference in New Issue