|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
|
|
from time import sleep
|
|
from time import sleep
|
|
|
|
|
|
|
|
|
|
+import random
|
|
|
from cached_property import cached_property
|
|
from cached_property import cached_property
|
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
|
from datetime import timedelta, time
|
|
from datetime import timedelta, time
|
|
@@ -36,57 +37,40 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
first_catch = True # 用于记录是否是第一次捕捉
|
|
first_catch = True # 用于记录是否是第一次捕捉
|
|
|
|
|
|
|
|
def run(self):
|
|
def run(self):
|
|
|
- # 引用配置
|
|
|
|
|
cong = self.config.bondling_fairyland
|
|
cong = self.config.bondling_fairyland
|
|
|
|
|
|
|
|
- if cong.bondling_check.check_enable:
|
|
|
|
|
|
|
+ if cong.bondling_config.check_enable:
|
|
|
logger.hr('第一步, 检查契忆数量', 2)
|
|
logger.hr('第一步, 检查契忆数量', 2)
|
|
|
self.ui_get_current_page()
|
|
self.ui_get_current_page()
|
|
|
self.ui_goto(page_mall, confirm_wait=2.5)
|
|
self.ui_goto(page_mall, confirm_wait=2.5)
|
|
|
self.ui_click(self.I_MALL_SCCALES, self.I_MALL_SCCALES_CHECK)
|
|
self.ui_click(self.I_MALL_SCCALES, self.I_MALL_SCCALES_CHECK)
|
|
|
self.ui_click(self.I_MALL_BONDLINGS_SURE, self.I_MALL_BONDLINGS_ON)
|
|
self.ui_click(self.I_MALL_BONDLINGS_SURE, self.I_MALL_BONDLINGS_ON)
|
|
|
-
|
|
|
|
|
- MAX_COUNT = cong.bondling_check.limit_num
|
|
|
|
|
|
|
+ MAX_COUNT = cong.bondling_config.limit_num
|
|
|
cu, re, total = self.O_BL_CHECK_MONEY.ocr(self.device.image)
|
|
cu, re, total = self.O_BL_CHECK_MONEY.ocr(self.device.image)
|
|
|
-
|
|
|
|
|
if cu >= MAX_COUNT:
|
|
if cu >= MAX_COUNT:
|
|
|
logger.info(f'契忆数量: {cu} 大于 {MAX_COUNT}')
|
|
logger.info(f'契忆数量: {cu} 大于 {MAX_COUNT}')
|
|
|
self.ui_get_current_page()
|
|
self.ui_get_current_page()
|
|
|
self.ui_goto(page_main)
|
|
self.ui_goto(page_main)
|
|
|
self.set_next_run(task='BondlingFairyland', finish=True, success=True)
|
|
self.set_next_run(task='BondlingFairyland', finish=True, success=True)
|
|
|
raise TaskEnd
|
|
raise TaskEnd
|
|
|
-
|
|
|
|
|
logger.info(f'契忆数量: {cu} 小于 {MAX_COUNT}, 继续任务')
|
|
logger.info(f'契忆数量: {cu} 小于 {MAX_COUNT}, 继续任务')
|
|
|
-
|
|
|
|
|
logger.hr('第二步, 切换御魂', 2)
|
|
logger.hr('第二步, 切换御魂', 2)
|
|
|
- # 御魂切换方式一
|
|
|
|
|
- if cong.switch_soul_config.enable:
|
|
|
|
|
- self.ui_get_current_page()
|
|
|
|
|
- self.ui_goto(page_shikigami_records)
|
|
|
|
|
- self.run_switch_soul(cong.switch_soul_config.switch_group_team)
|
|
|
|
|
- # 御魂切换方式二
|
|
|
|
|
- if cong.switch_soul_config.enable_switch_by_name:
|
|
|
|
|
- self.ui_get_current_page()
|
|
|
|
|
- self.ui_goto(page_shikigami_records)
|
|
|
|
|
- self.run_switch_soul_by_name(cong.switch_soul_config.group_name, cong.switch_soul_config.team_name)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ self.switch_soul()
|
|
|
logger.hr('第三步, 前往契灵主界面', 2)
|
|
logger.hr('第三步, 前往契灵主界面', 2)
|
|
|
- self.ui_get_current_page()
|
|
|
|
|
- self.ui_goto(page_bondling_fairyland)
|
|
|
|
|
-
|
|
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if self.appear(self.I_CHECK_BONDLING_FAIRYLAND, interval=1):
|
|
|
|
|
- break
|
|
|
|
|
- if self.appear(self.I_BALL_HELP, interval=1):
|
|
|
|
|
- self.ui_get_current_page()
|
|
|
|
|
- self.ui_goto(page_bondling_fairyland)
|
|
|
|
|
- continue
|
|
|
|
|
-
|
|
|
|
|
|
|
+ self.ui_goto_page(page_bondling_fairyland)
|
|
|
logger.hr('第四步, 开始战斗准备', 2)
|
|
logger.hr('第四步, 开始战斗准备', 2)
|
|
|
self.current_count = 0
|
|
self.current_count = 0
|
|
|
self.limit_count = cong.bondling_config.limit_count # 默认limit_count值
|
|
self.limit_count = cong.bondling_config.limit_count # 默认limit_count值
|
|
|
-
|
|
|
|
|
|
|
+ logger.hr('Goto bondling area')
|
|
|
|
|
+ self.goto_ball_area(BondlingClass.get_index(cong.bondling_config.bondling_stone_class))
|
|
|
|
|
+
|
|
|
|
|
+ if cong.bondling_config.bondling_mode == BondlingMode.MODE1: # model1只刷探查
|
|
|
|
|
+ if cong.bondling_config.user_status != UserStatus.ALONE:
|
|
|
|
|
+ raise ValueError(f'Now is model1, but user status is not alone, current: {cong.bondling_config.user_status.value}')
|
|
|
|
|
+ self.run_search(cong.bondling_config)
|
|
|
|
|
+ self.ui_goto_page(page_main)
|
|
|
|
|
+ self.set_next_run(task='BondlingFairyland', finish=True, success=True)
|
|
|
|
|
+ raise TaskEnd
|
|
|
match cong.bondling_config.user_status:
|
|
match cong.bondling_config.user_status:
|
|
|
case UserStatus.handoff1:
|
|
case UserStatus.handoff1:
|
|
|
self.limit_count //= 2
|
|
self.limit_count //= 2
|
|
@@ -132,7 +116,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
self.appear_then_click(self.I_CREATE_TEAM, interval=2)
|
|
self.appear_then_click(self.I_CREATE_TEAM, interval=2)
|
|
|
continue
|
|
continue
|
|
|
# 求援
|
|
# 求援
|
|
|
- if self.appear(self.I_CHECK_BONDLING_FAIRYLAND, interval=1):
|
|
|
|
|
|
|
+ if self.appear(self.I_BALL_AREA, interval=1):
|
|
|
return False
|
|
return False
|
|
|
if self.appear(self.I_BALL_HELP, interval=1):
|
|
if self.appear(self.I_BALL_HELP, interval=1):
|
|
|
cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
|
|
cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
|
|
@@ -256,7 +240,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
|
|
|
|
|
while 1:
|
|
while 1:
|
|
|
# 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
|
|
# 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
|
|
|
- if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND) or self.appear(self.I_BALL_HELP) :
|
|
|
|
|
|
|
+ if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_BALL_AREA) or self.appear(self.I_BALL_HELP) :
|
|
|
break
|
|
break
|
|
|
# 如果可能在房间就退出
|
|
# 如果可能在房间就退出
|
|
|
if self.exit_room():
|
|
if self.exit_room():
|
|
@@ -276,41 +260,39 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
cong = self.config.bondling_fairyland
|
|
cong = self.config.bondling_fairyland
|
|
|
|
|
|
|
|
bondling_config = cong.bondling_config
|
|
bondling_config = cong.bondling_config
|
|
|
- bondling_switch_soul = cong.bondling_switch_soul
|
|
|
|
|
battle_config = cong.battle_config
|
|
battle_config = cong.battle_config
|
|
|
|
|
|
|
|
logger.info(f'抓捕契灵: [{bondling_config.bondling_stone_class}] ')
|
|
logger.info(f'抓捕契灵: [{bondling_config.bondling_stone_class}] ')
|
|
|
- match bondling_config.bondling_stone_class:
|
|
|
|
|
- case BondlingClass.TOMB_GUARD:
|
|
|
|
|
- current_ball_index = 1
|
|
|
|
|
- case BondlingClass.AZURE_BASAN:
|
|
|
|
|
- current_ball_index = 2
|
|
|
|
|
- case BondlingClass.SNOWBALL:
|
|
|
|
|
- current_ball_index = 3
|
|
|
|
|
- case BondlingClass.LITTLE_KURO:
|
|
|
|
|
- current_ball_index = 4
|
|
|
|
|
- case _:
|
|
|
|
|
- current_ball_index = 1
|
|
|
|
|
-
|
|
|
|
|
|
|
+ idx = BondlingClass.get_index(bondling_config.bondling_stone_class)
|
|
|
|
|
+ current_ball_index = idx if idx is not None else 1
|
|
|
|
|
+ capture_setting_checked = False
|
|
|
while 1:
|
|
while 1:
|
|
|
-
|
|
|
|
|
if not self.in_search_ui(screenshot=True):
|
|
if not self.in_search_ui(screenshot=True):
|
|
|
self.ui_get_current_page()
|
|
self.ui_get_current_page()
|
|
|
self.ui_goto(page_bondling_fairyland)
|
|
self.ui_goto(page_bondling_fairyland)
|
|
|
continue
|
|
continue
|
|
|
-
|
|
|
|
|
if bondling_config.bondling_mode != BondlingMode.MODE1:
|
|
if bondling_config.bondling_mode != BondlingMode.MODE1:
|
|
|
if self.ball_click(current_ball_index):
|
|
if self.ball_click(current_ball_index):
|
|
|
- logger.info(f'Current ball number: {current_ball_index} ')
|
|
|
|
|
|
|
+ logger.info(f'Current ball index: {current_ball_index} ')
|
|
|
else:
|
|
else:
|
|
|
- if self.run_stone(bondling_config.bondling_stone_enable, bondling_config.bondling_stone_class):
|
|
|
|
|
|
|
+ if self.run_stone(bondling_config.bondling_stone_enable):
|
|
|
continue
|
|
continue
|
|
|
|
|
+ elif bondling_config.bondling_search_enable and bondling_config.user_status == UserStatus.ALONE:
|
|
|
|
|
+ if self.run_search(bondling_config, limit_cnt=random.randint(5, 20)):
|
|
|
|
|
+ logger.info('Bondling search finish, try to run catch')
|
|
|
|
|
+ continue
|
|
|
|
|
+ else:
|
|
|
|
|
+ break # 时间到了或次数到了直接退出
|
|
|
else:
|
|
else:
|
|
|
logger.info('No bondling stone, exit')
|
|
logger.info('No bondling stone, exit')
|
|
|
break
|
|
break
|
|
|
|
|
+ # 检查结契设置
|
|
|
|
|
+ if not capture_setting_checked:
|
|
|
|
|
+ self.capture_setting(bondling_config.bondling_mode)
|
|
|
|
|
+ capture_setting_checked = True
|
|
|
try:
|
|
try:
|
|
|
# 执行捕捉
|
|
# 执行捕捉
|
|
|
- if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
|
|
|
|
|
|
|
+ if self.run_catch(bondling_config, battle_config):
|
|
|
logger.info(f'Catch successful and current ball number: {current_ball_index} ')
|
|
logger.info(f'Catch successful and current ball number: {current_ball_index} ')
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
@@ -335,51 +317,54 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
self.set_next_run(task='BondlingFairyland', finish=True, success=True)
|
|
self.set_next_run(task='BondlingFairyland', finish=True, success=True)
|
|
|
raise TaskEnd
|
|
raise TaskEnd
|
|
|
|
|
|
|
|
- def run_stone(self, bondling_stone_enable: bool, bondling_stone_class: BondlingClass):
|
|
|
|
|
|
|
+ def run_stone(self, bondling_stone_enable: bool):
|
|
|
"""
|
|
"""
|
|
|
使用结契石 进行召唤 契灵
|
|
使用结契石 进行召唤 契灵
|
|
|
- :param bondling_stone_class:
|
|
|
|
|
:param bondling_stone_enable:
|
|
:param bondling_stone_enable:
|
|
|
:return:
|
|
:return:
|
|
|
(0) 不开启使用结契石,(探查界面)返回False
|
|
(0) 不开启使用结契石,(探查界面)返回False
|
|
|
(1) 没有结契石了,(探查界面)返回False
|
|
(1) 没有结契石了,(探查界面)返回False
|
|
|
"""
|
|
"""
|
|
|
- if not bondling_stone_enable:
|
|
|
|
|
|
|
+ # 没有启用使用石头购买契灵或者当前不在购买界面则直接退出
|
|
|
|
|
+ if not bondling_stone_enable or not self.appear(self.I_STONE_SURE):
|
|
|
|
|
+ self.ui_click_until_disappear(self.I_STONE_CLOSE, interval=1.2)
|
|
|
|
|
+ return False
|
|
|
|
|
+ cu, res, total = self.O_B_STONE_NUMBER.ocr(self.device.image)
|
|
|
|
|
+ # 如果没有石头了
|
|
|
|
|
+ if cu == 0 and cu + res == total:
|
|
|
|
|
+ self.ui_click_until_disappear(self.I_STONE_CLOSE, interval=1.2)
|
|
|
|
|
+ logger.warning(f'已经没有鸣契石召唤契灵了')
|
|
|
return False
|
|
return False
|
|
|
while 1:
|
|
while 1:
|
|
|
self.screenshot()
|
|
self.screenshot()
|
|
|
if not self.appear(self.I_STONE_SURE):
|
|
if not self.appear(self.I_STONE_SURE):
|
|
|
- return False
|
|
|
|
|
- # 如果没有石头了
|
|
|
|
|
- cu, res, total = self.O_B_STONE_NUMBER.ocr(self.device.image)
|
|
|
|
|
- if cu == 0 and cu + res == total:
|
|
|
|
|
- logger.warning(f'已经没有鸣契石召唤契灵了')
|
|
|
|
|
- return False
|
|
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if not self.appear(self.I_STONE_SURE):
|
|
|
|
|
- return True
|
|
|
|
|
- for i in range(3):
|
|
|
|
|
- if self.appear_then_click(self.I_BUY_PLUS, interval=1):
|
|
|
|
|
- sleep(0.5)
|
|
|
|
|
- if self.appear_then_click(self.I_GI_SURE, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
- if self.appear_then_click(self.I_STONE_SURE, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
|
|
+ sleep(random.uniform(1.5, 2)) # 等待购买后的动画, 否则已经买了但是下次再点击还会出现该界面
|
|
|
|
|
+ return True
|
|
|
|
|
+ for i in range(3):
|
|
|
|
|
+ if self.appear_then_click(self.I_BUY_PLUS, interval=1):
|
|
|
|
|
+ sleep(0.5)
|
|
|
|
|
+ if self.appear_then_click(self.I_GI_SURE, interval=1):
|
|
|
|
|
+ continue
|
|
|
|
|
+ if self.appear_then_click(self.I_STONE_SURE, interval=1):
|
|
|
|
|
+ continue
|
|
|
|
|
|
|
|
- def run_search(self, bondling_config: BondlingConfig):
|
|
|
|
|
|
|
+ def run_search(self, bondling_config: BondlingConfig, limit_cnt: int = None):
|
|
|
"""
|
|
"""
|
|
|
运行探查
|
|
运行探查
|
|
|
:return:
|
|
:return:
|
|
|
(1) 超出战斗的次数的了,(探查页面)返回False
|
|
(1) 超出战斗的次数的了,(探查页面)返回False
|
|
|
(2) 超过时间限制了,(探查页面)返回False
|
|
(2) 超过时间限制了,(探查页面)返回False
|
|
|
(3) 打满五只球了,(探查界面)返回True
|
|
(3) 打满五只球了,(探查界面)返回True
|
|
|
|
|
+ (4) 打满对应limit_cnt次, (探查界面)返回True
|
|
|
"""
|
|
"""
|
|
|
self.lock_team()
|
|
self.lock_team()
|
|
|
while 1:
|
|
while 1:
|
|
|
# 检查是不是在探查界面,
|
|
# 检查是不是在探查界面,
|
|
|
if not self.in_search_ui(screenshot=True):
|
|
if not self.in_search_ui(screenshot=True):
|
|
|
continue
|
|
continue
|
|
|
|
|
+ # 检查是否打满limit_cnt次
|
|
|
|
|
+ if limit_cnt is not None and limit_cnt <= 0:
|
|
|
|
|
+ return True
|
|
|
# 检查是否有挑战次数
|
|
# 检查是否有挑战次数
|
|
|
if self.current_count >= bondling_config.limit_count:
|
|
if self.current_count >= bondling_config.limit_count:
|
|
|
logger.warning(f'No challenge count, exit')
|
|
logger.warning(f'No challenge count, exit')
|
|
@@ -388,16 +373,16 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
if datetime.now() - self.start_time >= self.limit_time:
|
|
if datetime.now() - self.start_time >= self.limit_time:
|
|
|
logger.warning(f'No time, exit')
|
|
logger.warning(f'No time, exit')
|
|
|
return False
|
|
return False
|
|
|
-
|
|
|
|
|
if self.click_search():
|
|
if self.click_search():
|
|
|
self.run_general_battle(self.general_battle_config)
|
|
self.run_general_battle(self.general_battle_config)
|
|
|
|
|
+ if limit_cnt is not None:
|
|
|
|
|
+ limit_cnt = limit_cnt - 1
|
|
|
|
|
+ logger.info(f'Remain search battle: {limit_cnt}')
|
|
|
else:
|
|
else:
|
|
|
logger.warning(f'Full five ball')
|
|
logger.warning(f'Full five ball')
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
- def run_catch(self, bondling_config: BondlingConfig,
|
|
|
|
|
- bondling_switch_soul: BondlingSwitchSoul,
|
|
|
|
|
- battle_config: BattleConfig):
|
|
|
|
|
|
|
+ def run_catch(self, bondling_config: BondlingConfig, battle_config: BattleConfig):
|
|
|
"""
|
|
"""
|
|
|
执行捕捉的(确保进入了结契界面)
|
|
执行捕捉的(确保进入了结契界面)
|
|
|
:return:
|
|
:return:
|
|
@@ -415,6 +400,8 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
target_plate = self.O_B_LOW_NUMBER
|
|
target_plate = self.O_B_LOW_NUMBER
|
|
|
case BondlingMode.MODE3:
|
|
case BondlingMode.MODE3:
|
|
|
target_plate = self.O_B_MEDIUM_NUMBER
|
|
target_plate = self.O_B_MEDIUM_NUMBER
|
|
|
|
|
+ case BondlingMode.MODE4:
|
|
|
|
|
+ target_plate = self.O_B_HIGH_NUMBER
|
|
|
case _:
|
|
case _:
|
|
|
logger.error('Invalid bondling mode')
|
|
logger.error('Invalid bondling mode')
|
|
|
return False
|
|
return False
|
|
@@ -446,7 +433,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
while 1:
|
|
while 1:
|
|
|
self.screenshot()
|
|
self.screenshot()
|
|
|
|
|
|
|
|
- if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
|
|
|
|
|
|
|
+ if self.appear(self.I_BALL_AREA):
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
# 如果不在结契界面,就等待
|
|
# 如果不在结契界面,就等待
|
|
@@ -491,10 +478,8 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
:param index:
|
|
:param index:
|
|
|
:return:
|
|
:return:
|
|
|
"""
|
|
"""
|
|
|
-
|
|
|
|
|
def get_click_target(ind: int):
|
|
def get_click_target(ind: int):
|
|
|
- if ind > 5 or ind < 1:
|
|
|
|
|
- raise ValueError('index must be 1-5')
|
|
|
|
|
|
|
+ """获取对应契灵点击位置"""
|
|
|
match = {
|
|
match = {
|
|
|
1: self.C_STONE_1,
|
|
1: self.C_STONE_1,
|
|
|
2: self.C_STONE_2,
|
|
2: self.C_STONE_2,
|
|
@@ -502,7 +487,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
4: self.C_STONE_4,
|
|
4: self.C_STONE_4,
|
|
|
5: self.C_STONE_5,
|
|
5: self.C_STONE_5,
|
|
|
}
|
|
}
|
|
|
- return match[ind]
|
|
|
|
|
|
|
+ return match[(ind - 1) % 4 + 1]
|
|
|
|
|
|
|
|
click_target = get_click_target(index)
|
|
click_target = get_click_target(index)
|
|
|
click_count = 0
|
|
click_count = 0
|
|
@@ -517,6 +502,25 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
if self.click(click_target, interval=1):
|
|
if self.click(click_target, interval=1):
|
|
|
click_count += 1
|
|
click_count += 1
|
|
|
|
|
|
|
|
|
|
+ def goto_ball_area(self, index: int):
|
|
|
|
|
+ """进入契灵对应地域,最终在探查界面"""
|
|
|
|
|
+ def get_click_area(ind: int):
|
|
|
|
|
+ """获取对应契灵地域点击位置"""
|
|
|
|
|
+ if 1 <= ind <= 4: # 平安京
|
|
|
|
|
+ return self.C_AREA_1
|
|
|
|
|
+ if 5 <= ind <= 8: # 逢魔之原
|
|
|
|
|
+ return self.C_AREA_2
|
|
|
|
|
+ return None
|
|
|
|
|
+ # 进入地域页面
|
|
|
|
|
+ while True:
|
|
|
|
|
+ self.screenshot()
|
|
|
|
|
+ if self.appear(self.I_CHECK_AREA, interval=0.6):
|
|
|
|
|
+ break
|
|
|
|
|
+ if self.appear_then_click(self.I_BALL_AREA, interval=1.2):
|
|
|
|
|
+ continue
|
|
|
|
|
+ # 点击对应地域并返回契灵主界面
|
|
|
|
|
+ self.ui_click(get_click_area(index), self.I_BALL_AREA, interval=0.8)
|
|
|
|
|
+
|
|
|
def capture_setting(self, mode: BondlingMode) -> None:
|
|
def capture_setting(self, mode: BondlingMode) -> None:
|
|
|
"""
|
|
"""
|
|
|
第一次进入任务的时候触发这一项方法:为了确保用户的选择默认是正确的
|
|
第一次进入任务的时候触发这一项方法:为了确保用户的选择默认是正确的
|
|
@@ -527,51 +531,36 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
if mode == BondlingMode.MODE1:
|
|
if mode == BondlingMode.MODE1:
|
|
|
return None
|
|
return None
|
|
|
logger.info(f'Capture setting mode: {mode}')
|
|
logger.info(f'Capture setting mode: {mode}')
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if self.appear(self.I_CAPTION_ENSURE):
|
|
|
|
|
- break
|
|
|
|
|
- if self.appear_then_click(self.I_CLICK_CAPTION, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
-
|
|
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if self.appear(self.I_C_AUTO_TRUE):
|
|
|
|
|
- break
|
|
|
|
|
- if self.appear_then_click(self.I_C_AUTO_FALSE, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
|
|
+ self.ui_click(self.I_CLICK_CAPTION, self.I_CAPTION_ENSURE, interval=1) # 打开结契设置
|
|
|
|
|
+ self.ui_click(self.I_C_AUTO_FALSE, self.I_C_AUTO_TRUE, interval=1) # 自动结契
|
|
|
|
|
+ self.ui_click(self.I_C_MINIMAL_MODE_DISABLE, self.I_C_MINIMAL_MODE_ENABLE, interval=0.8) # 极简模式
|
|
|
|
|
|
|
|
target_true = None
|
|
target_true = None
|
|
|
target_false = None
|
|
target_false = None
|
|
|
target_first = None
|
|
target_first = None
|
|
|
|
|
+ target_continuous = None
|
|
|
if mode == BondlingMode.MODE3:
|
|
if mode == BondlingMode.MODE3:
|
|
|
target_true = self.I_C_MIDUM_TRUE
|
|
target_true = self.I_C_MIDUM_TRUE
|
|
|
target_false = self.I_C_MIDUM_FALSE
|
|
target_false = self.I_C_MIDUM_FALSE
|
|
|
target_first = self.I_C_FIRST_ENABLE
|
|
target_first = self.I_C_FIRST_ENABLE
|
|
|
|
|
+ target_continuous = self.I_C_CONTINUOUS_ENABLE
|
|
|
elif mode == BondlingMode.MODE2:
|
|
elif mode == BondlingMode.MODE2:
|
|
|
target_true = self.I_C_LOW_TRUE
|
|
target_true = self.I_C_LOW_TRUE
|
|
|
target_false = self.I_C_LOW_FALSE
|
|
target_false = self.I_C_LOW_FALSE
|
|
|
target_first = self.I_C_FIRST_DISABLE
|
|
target_first = self.I_C_FIRST_DISABLE
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if self.appear(target_true):
|
|
|
|
|
- break
|
|
|
|
|
- if self.appear_then_click(target_false, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if not self.appear(target_first):
|
|
|
|
|
- break
|
|
|
|
|
- if self.appear_then_click(target_first, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
-
|
|
|
|
|
|
|
+ target_continuous = self.I_C_CONTINUOUS_DISABLE
|
|
|
|
|
+ elif mode == BondlingMode.MODE4: # 高级盘子不需要设置连续结契和羁绊式神
|
|
|
|
|
+ target_true = self.I_C_HIGH_TRUE
|
|
|
|
|
+ target_false = self.I_C_HIGH_FALSE
|
|
|
|
|
+ if target_true is not None: # 切换盘子
|
|
|
|
|
+ self.ui_click(target_false, target_true, interval=1)
|
|
|
|
|
+ if target_continuous is not None: # 是否连续结契
|
|
|
|
|
+ self.ui_click_until_disappear(target_continuous, interval=1)
|
|
|
|
|
+ if target_first is not None: # 是否使用羁绊式神
|
|
|
|
|
+ self.ui_click_until_disappear(target_first, interval=1)
|
|
|
# 点击确定退出
|
|
# 点击确定退出
|
|
|
- while 1:
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if not self.appear(self.I_CAPTION_ENSURE):
|
|
|
|
|
- break
|
|
|
|
|
- if self.appear_then_click(self.I_CAPTION_ENSURE, interval=1):
|
|
|
|
|
- continue
|
|
|
|
|
|
|
+ self.ui_click_until_disappear(self.I_CAPTION_ENSURE, interval=1)
|
|
|
|
|
+ return None
|
|
|
|
|
|
|
|
def enter_shikigami_records(self) -> None:
|
|
def enter_shikigami_records(self) -> None:
|
|
|
"""
|
|
"""
|
|
@@ -662,7 +651,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
self.screenshot()
|
|
self.screenshot()
|
|
|
|
|
|
|
|
# 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
|
|
# 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
|
|
|
- if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND) or self.appear(self.I_BALL_HELP):
|
|
|
|
|
|
|
+ if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_BALL_AREA) or self.appear(self.I_BALL_HELP):
|
|
|
logger.warning('Room destroyed')
|
|
logger.warning('Room destroyed')
|
|
|
success = False
|
|
success = False
|
|
|
break
|
|
break
|
|
@@ -790,6 +779,33 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
|
|
|
gbc.random_click_swipt_enable = False
|
|
gbc.random_click_swipt_enable = False
|
|
|
return gbc
|
|
return gbc
|
|
|
|
|
|
|
|
|
|
+ def switch_soul(self):
|
|
|
|
|
+ def do_switch_soul(ts: str, g: str | int, te: str | int):
|
|
|
|
|
+ if ts is None:
|
|
|
|
|
+ raise ValueError(f'Invalid switch soul config on {bondling_config.bondling_stone_class.value}')
|
|
|
|
|
+ if ts == 'int':
|
|
|
|
|
+ self.run_switch_soul((g, te))
|
|
|
|
|
+ if ts == 'str':
|
|
|
|
|
+ self.run_switch_soul_by_name(g, te)
|
|
|
|
|
+ cong = self.config.bondling_fairyland
|
|
|
|
|
+ if not cong.bondling_switch_soul.enable:
|
|
|
|
|
+ return
|
|
|
|
|
+ bondling_config = cong.bondling_config
|
|
|
|
|
+ bondling_switch_soul = cong.bondling_switch_soul
|
|
|
|
|
+ self.ui_goto_page(page_shikigami_records)
|
|
|
|
|
+ # 单刷探查配置
|
|
|
|
|
+ if bondling_config.bondling_mode == BondlingMode.MODE1:
|
|
|
|
|
+ type_str, (group, team) = bondling_switch_soul.get_switch_by_name('search_switch')
|
|
|
|
|
+ do_switch_soul(type_str, group, team)
|
|
|
|
|
+ return
|
|
|
|
|
+ # 刷契灵配置
|
|
|
|
|
+ type_str, (group, team) = bondling_switch_soul.get_switch_by_enum(bondling_config.bondling_stone_class)
|
|
|
|
|
+ do_switch_soul(type_str, group, team)
|
|
|
|
|
+ # 启用了刷契灵时开启探查且是单人模式
|
|
|
|
|
+ if bondling_config.bondling_search_enable and bondling_config.user_status == UserStatus.ALONE:
|
|
|
|
|
+ type_str, (group, team) = bondling_switch_soul.get_switch_by_name('search_switch')
|
|
|
|
|
+ do_switch_soul(type_str, group, team)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
from module.config.config import Config
|
|
from module.config.config import Config
|