Skip to content
8 changes: 7 additions & 1 deletion assets/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@
"emulator_startup_lead_time": "模拟器预热时间",
"emulator_startup_lead_time_help": "在开始运行任务之前提前启动模拟器的时间",
"exit_four_help": "支持打九退四,保证稳定57级,要求设置好战斗主题,即 脚本->全局配置->游戏装饰自定义->战斗主题",
"costume_main_15": "茨心乐园"
"costume_main_15": "茨心乐园",
"check_true_orochi_enable": "是否在结束后检测真蛇",
"check_true_orochi_enable_help": "开启后会在任务结束后检测是否出现真蛇, 若出现则自动拉起真蛇",
"enable_book_auto": "自动选择",
"enable_book_auto_help": "游戏内是否开启自动选择御魂",
"earn_money": "获取樱灯饰",
"earn_money_help": "通过放置借处式神获取500樱灯饰\n开启前确保已放置借出式神"
}
43 changes: 41 additions & 2 deletions tasks/BondlingFairyland/script_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def switch_ball(self):
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')
# 切御魂
self._switch_soul_capture()
continue
else:
break # 时间到了或次数到了直接退出
Expand Down Expand Up @@ -345,19 +347,24 @@ def run_stone(self, bondling_stone_enable: bool):
self.ui_click_until_disappear(self.I_STONE_CLOSE, interval=1.2)
logger.warning(f'已经没有鸣契石召唤契灵了')
return False
cnt = 0
while 1:
self.screenshot()
if not self.appear(self.I_STONE_SURE):
sleep(random.uniform(1.5, 2)) # 等待购买后的动画, 否则已经买了但是下次再点击还会出现该界面
return True
if cnt >= 6:
logger.warning("")
return False
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):
if self.appear_then_click(self.I_STONE_SURE, interval=2):
continue


def run_search(self, bondling_config: BondlingConfig, limit_cnt: int = None):
"""
运行探查
Expand All @@ -368,6 +375,7 @@ def run_search(self, bondling_config: BondlingConfig, limit_cnt: int = None):
(4) 打满对应limit_cnt次, (探查界面)返回True
"""
self.lock_team()
self._switch_soul_search()
while 1:
# 检查是不是在探查界面,
if not self.in_search_ui(screenshot=True):
Expand Down Expand Up @@ -816,6 +824,37 @@ def do_switch_soul(ts: str, g: str | int, te: str | int):
type_str, (group, team) = bondling_switch_soul.get_switch_by_name('search_switch')
do_switch_soul(type_str, group, team)

def _switch_soul_to(self, ts, g, te):
def _do_switch_soul(ts: str, g: str | int, te: str | int):
if ts is None:
raise ValueError(f'Invalid switch soul config on {self.config.bondling_fairyland.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)

if ts is None:
logger.warning('Switch soul preset not configured, skip')
return

self.goto_shikigami_records(self.I_GOTO_SHIKIGAMI_COMMON)
_do_switch_soul(ts, g, te)
self.exit_shikigami_records()


def _switch_soul_search(self):
logger.info("切换御魂-探查")
if not self.config.bondling_fairyland.bondling_switch_soul.enable: return
ts, (g, te) = self.config.bondling_fairyland.bondling_switch_soul.get_switch_by_name('search_switch')
self._switch_soul_to(ts, g, te)

def _switch_soul_capture(self):
logger.info("切换御魂-捕获")
cong = self.config.bondling_fairyland
if not cong.bondling_switch_soul.enable: return
ts, (g, te) = cong.bondling_switch_soul.get_switch_by_enum(cong.bondling_config.bondling_stone_class)
self._switch_soul_to(ts, g, te)


if __name__ == '__main__':
from module.config.config import Config
Expand All @@ -824,7 +863,7 @@ def do_switch_soul(ts: str, g: str | int, te: str | int):
config = Config('oas1')
device = Device(config)
t = ScriptTask(config, device)
# t.run()
t.run()
t.ui_get_current_page()
t.ui_goto(page_bondling_fairyland)
# image = task.screenshot()
Expand Down
4 changes: 2 additions & 2 deletions tasks/Component/Buy/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BuyAssets:
# description
C_BUY_ONE = RuleClick(roi_front=(551,506,174,36), roi_back=(551,506,174,36), name="buy_one")
# description
C_BUY_MORE = RuleClick(roi_front=(551,540,174,40), roi_back=(551,540,174,40), name="buy_more")
C_BUY_MORE = RuleClick(roi_front=(551,563,174,17), roi_back=(551,563,174,17), name="buy_more")
# 取消购买
C_BUY_CANCEL = RuleClick(roi_front=(121,2,100,22), roi_back=(121,2,100,22), name="buy_cancel")

Expand All @@ -34,6 +34,6 @@ class BuyAssets:

# Ocr Rule Assets
# Ocr-description
O_BUY_NUMBER = RuleOcr(roi=(578,416,52,46), area=(578,416,52,46), mode="Digit", method="Default", keyword="", name="buy_number")
O_BUY_NUMBER = RuleOcr(roi=(578,416,52,71), area=(578,416,52,71), mode="Digit", method="Default", keyword="", name="buy_number")


4 changes: 2 additions & 2 deletions tasks/Component/Buy/buy/click.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
{
"itemName": "buy_more",
"roiFront": "551,540,174,40",
"roiBack": "551,540,174,40",
"roiFront": "551,563,174,17",
"roiBack": "551,563,174,17",
"description": "description"
},
{
Expand Down
4 changes: 2 additions & 2 deletions tasks/Component/Buy/buy/ocr.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"itemName": "buy_number",
"roiFront": "578,416,52,46",
"roiBack": "578,416,52,46",
"roiFront": "578,416,52,71",
"roiBack": "578,416,52,71",
"mode": "Digit",
"method": "Default",
"keyword": "",
Expand Down
2 changes: 1 addition & 1 deletion tasks/Component/SwitchAccount/login_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def switch_character(self, characterName: str):
"""
logger.info("start switch_character")
# 改成对比是否出现 已有角色
self.ui_click(self.C_SA_LOGIN_FORM_SWITCH_SVR_BTN, self.O_SA_CHECK_SELCET_SVR)
self.ui_click(self.C_SA_LOGIN_FORM_SWITCH_SVR_BTN, self.O_SA_CHECK_SELECT_SVR)
# 展开底部角色列表,显示角色所属服务器
self.screenshot()
while (not self.appear(self.I_SA_CHECK_SELECT_SVR_2)) and self.appear(self.I_SA_CHECK_SELECT_SVR_1):
Expand Down
2 changes: 2 additions & 0 deletions tasks/Component/SwitchSoul/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class SwitchSoulAssets:
I_SOU_CLICK_PRESENT = RuleImage(roi_front=(978,304,25,26), roi_back=(965,142,48,480), threshold=0.9, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_click_present.png")
# 误触点到式神检查
I_CHECK_BLOCK = RuleImage(roi_front=(572,408,137,49), roi_back=(572,408,137,49), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_check_block.png")
# 通用进入式神录
I_GOTO_SHIKIGAMI_COMMON = RuleImage(roi_front=(1037,567,36,36), roi_back=(617,503,487,134), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_goto_shikigami_common.png")


# Ocr Rule Assets
Expand Down
9 changes: 9 additions & 0 deletions tasks/Component/SwitchSoul/ss/image.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,14 @@
"method": "Template matching",
"threshold": 0.8,
"description": "误触点到式神检查"
},
{
"itemName": "goto_shikigami_common",
"imageName": "ss_goto_shikigami_common.png",
"roiFront": "1037,567,36,36",
"roiBack": "617,503,487,134",
"method": "Template matching",
"threshold": 0.8,
"description": "通用进入式神录"
}
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 30 additions & 14 deletions tasks/Component/SwitchSoul/switch_soul.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
from module.atom.long_click import RuleLongClick
from module.atom.ocr import RuleOcr
from module.base.timer import Timer
from module.logger import logger

from tasks.base_task import BaseTask
from tasks.GameUi.assets import GameUiAssets
from tasks.Component.GeneralInvite.assets import GeneralInviteAssets
from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
from tasks.Component.SwitchSoul.assets import SwitchSoulAssets
from module.logger import logger



def switch_parser(switch_str: str) -> tuple:
Expand All @@ -24,6 +27,32 @@ def switch_parser(switch_str: str) -> tuple:

class SwitchSoul(BaseTask, SwitchSoulAssets):

def goto_shikigami_records(self, button):
"""
进入式神录
"""
while 1:
self.screenshot()
if self.appear(GameUiAssets.I_CHECK_RECORDS):
break
if self.appear_then_click(button, interval=1.5):
continue
logger.info('Entry shikigami records')

def exit_shikigami_records(self) -> None:
"""
退出式神录的界面
:return:
"""
while 1:
self.screenshot()
if not self.appear(self.I_SOU_CHECK_IN):
break
if self.appear_then_click(self.I_RECORD_SOUL_BACK, interval=3.5):
continue
logger.info('Exit shikigami records')


def run_switch_soul(self, target: tuple | list[tuple] | str):
"""
保证在式神录的界面
Expand Down Expand Up @@ -153,19 +182,6 @@ def switch_souls(self, target: tuple or list[tuple]) -> None:
team = int(team)
self.switch_soul_one(group, team)

def exit_shikigami_records(self) -> None:
"""
退出式神录的界面
:return:
"""
while 1:
self.screenshot()
if not self.appear(self.I_SOU_CHECK_IN):
break
if self.appear_then_click(self.I_RECORD_SOUL_BACK, interval=3.5):
continue
logger.info('Exit shikigami records')

def run_switch_soul_by_name(self, groupName, teamName):
"""
保证在式神录的界面
Expand Down
7 changes: 7 additions & 0 deletions tasks/HeroTest/script_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,15 @@ def hero2_skill_wait(self):
SkillMode.PVP: pvp_skill,
}
target_skills = target_skill_dict[self.conf.herotest.skill_mode]
timer = Timer(10).start()
while True:
self.screenshot()
if timer.reached_and_reset():
if self.appear(self.I_BCMJ_SKILL_ADD_CONFIRM):
logger.warning('No skill selected for 10s, panel still open, retrying')
continue
logger.warning('Skill selection panel closed unexpectedly, exit')
break
if any(self.appear_then_click(ts, interval=1) for ts in target_skills):
break
self.ui_click_until_disappear(self.I_BCMJ_SKILL_ADD_CONFIRM, interval=1.5)
Expand Down
2 changes: 2 additions & 0 deletions tasks/Orochi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class OrochiConfig(ConfigBase):
limit_count: int = Field(default=30, description='limit_count_help')
# 是否开启御魂加成
soul_buff_enable: bool = Field(default=False, description='soul_buff_enable_help')
# 是否御魂结束检测是否出现真蛇
check_true_orochi_enable: bool = Field(default=False, description='check_true_orochi_enable_help')

class SwitchSoulConfig(BaseSwitchSoulConfig):
enable: bool = Field(default=False)
Expand Down
13 changes: 12 additions & 1 deletion tasks/Orochi/script_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
from tasks.Orochi.assets import OrochiAssets
from tasks.Orochi.config import Orochi, UserStatus, Layer
from tasks.TrueOrochi.assets import TrueOrochiAssets
from module.logger import logger
from module.exception import TaskEnd


class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, OrochiAssets):
class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, OrochiAssets, TrueOrochiAssets):

def run(self) -> bool:
# 御魂切换方式一
Expand Down Expand Up @@ -59,6 +60,16 @@ def run(self) -> bool:
case UserStatus.WILD: success = self.run_wild()
case _: logger.error('Unknown user status')

# 御魂结束后检测是否出现真蛇
if config.orochi_config.check_true_orochi_enable:
self.ui_get_current_page()
self.ui_goto(page_soul_zones)
self.orochi_enter()
self.screenshot()
if self.appear(self.I_FIND_TS):
logger.info('Find true orochi after orochi battle, set TrueOrochi task to run now')
self.set_next_run(task='TrueOrochi', success=False, finish=False, server=False, target=datetime.now())
self.ui_goto(page_main)
# 记得关掉
if config.orochi_config.soul_buff_enable:
self.open_buff()
Expand Down
18 changes: 15 additions & 3 deletions tasks/RichMan/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class RichManAssets:
# description
I_SCA_SELECT_3 = RuleImage(roi_front=(972,517,123,50), roi_back=(972,517,123,50), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_select_3.png")
# 获得的六星
I_SCA_SIX_STAR = RuleImage(roi_front=(120,216,97,22), roi_back=(113,102,1057,157), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_six_star.png")
I_SCA_SIX_STAR = RuleImage(roi_front=(120,216,97,22), roi_back=(113,102,1056,257), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_six_star.png")
# 点击屏幕继续
I_SCA_REWARD = RuleImage(roi_front=(584,503,100,100), roi_back=(584,503,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_reward.png")
# 点击兑换
Expand All @@ -297,15 +297,15 @@ class RichManAssets:
# 首领御魂剩余可买的
O_SCA_NUMBER_DEMON = RuleOcr(roi=(627,319,30,25), area=(627,319,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_demon")
# 永生之海
O_SCA_NUMBER_SEA = RuleOcr(roi=(926,321,30,23), area=(926,321,30,23), mode="Quantity", method="Default", keyword="", name="sca_number_sea")
O_SCA_NUMBER_SEA = RuleOcr(roi=(920,320,36,22), area=(920,320,36,22), mode="Quantity", method="Default", keyword="", name="sca_number_sea")
# 多少号位
O_SCA_DEMON_POSTION = RuleOcr(roi=(960,244,88,41), area=(960,244,88,41), mode="Single", method="Default", keyword="", name="sca_demon_postion")
# 朴素的御魂
O_SCA_RES_OROCHI = RuleOcr(roi=(610,9,127,37), area=(610,9,127,37), mode="DigitCounter", method="Default", keyword="", name="sca_res_orochi")
# 首领御魂数量
O_SCA_RES_DEMON = RuleOcr(roi=(968,11,102,35), area=(968,11,102,35), mode="Digit", method="Default", keyword="", name="sca_res_demon")
# 永生之海
O_SCA_RES_SEA = RuleOcr(roi=(1136,11,88,38), area=(1136,11,88,38), mode="Digit", method="Default", keyword="", name="sca_res_sea")
O_SCA_RES_SEA = RuleOcr(roi=(1134,11,100,38), area=(1134,11,100,38), mode="Digit", method="Default", keyword="", name="sca_res_sea")


# Image Rule Assets
Expand Down Expand Up @@ -397,6 +397,18 @@ class RichManAssets:
I_TT_BUY_UP = RuleImage(roi_front=(755,427,59,57), roi_back=(740,386,80,146), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_buy_up.png")
# description
I_TT_BUY_CONFIRM = RuleImage(roi_front=(584,512,53,53), roi_back=(553,487,169,115), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_buy_confirm.png")
# 唤妖借处
I_TT_BORROW = RuleImage(roi_front=(1043,262,39,149), roi_back=(960,169,208,309), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_borrow.png")
# 配置式神
I_TT_CONFIGURE = RuleImage(roi_front=(1129,608,42,44), roi_back=(1036,523,240,197), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_configure.png")
# 确认配置
I_TT_CONFIRM = RuleImage(roi_front=(1129,608,42,44), roi_back=(1036,523,240,197), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_confirm.png")
# 选择式神(第四个)
I_TT_SHIKIGAMI = RuleImage(roi_front=(682,257,15,14), roi_back=(652,221,151,148), threshold=0.7, method="Template matching", file="./tasks/RichMan/tt/tt_tt_shikigami.png")
# 替换式神
I_TT_SHIKIGAMI_REPLACE = RuleImage(roi_front=(755,641,57,19), roi_back=(703,580,148,134), threshold=0.7, method="Template matching", file="./tasks/RichMan/tt/tt_tt_shikigami_replace.png")
# 借出确认
I_TT_BORROW_CONFIRM = RuleImage(roi_front=(960,508,50,53), roi_back=(886,444,222,194), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_borrow_confirm.png")


# Ocr Rule Assets
Expand Down
2 changes: 2 additions & 0 deletions tasks/RichMan/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class ThousandThings(BaseModel):
# 千物宝箱
enable: bool = Field(title='Enable', default=False)
earn_money: bool = Field(title='Earn Money', default=False, description='earn_money_help')
mystery_amulet: bool = Field(title='Mystery Amulet', default=False)
black_daruma_fragment: bool = Field(title='Black Daruma Fragment', default=False)
ap: bool = Field(title='AP', default=False, description='ap_help')
Expand All @@ -29,6 +30,7 @@ class Scales(BaseModel):
demon_class: DemonClass = Field(title='DemonClass', default=DemonClass.TSUCHIGUMO, description='demon_class_help')
demon_position: int = Field(title='Demon Position', default=1, description='demon_position_help')
picture_book_scrap: int = Field(title='Picture Book Scrap', default=30, description='picture_book_scrap_help')
enable_book_auto: bool = Field(title='Enable Book Auto', default=False, description='enable_book_auto_help')
picture_book_rule: str = Field(title='Picture Book Rule', default='auto', description='picture_book_rule_help')


Expand Down
10 changes: 8 additions & 2 deletions tasks/RichMan/mall/scales.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,16 @@ def _scales_sea(self, buy_number: int, buy_rule: str='auto'):
buy_res_number = buy_number
if buy_cycles_number:
for i in range(buy_cycles_number):
self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK)
if self.config.rich_man.scales.enable_book_auto:
self._scales_buy_more(self.I_SCA_PICTURE_BOOK)
else:
self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK)
time.sleep(0.5)
if buy_res_number and buy_res_number >= 2:
self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK, buy_res_number)
if self.config.rich_man.scales.enable_book_auto:
self._scales_buy_more(self.I_SCA_PICTURE_BOOK, buy_res_number)
else:
self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK, buy_res_number)
time.sleep(0.5)


Expand Down
2 changes: 1 addition & 1 deletion tasks/RichMan/mall/scales/image.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"itemName": "sca_six_star",
"imageName": "scales_sca_six_star.png",
"roiFront": "120,216,97,22",
"roiBack": "113,102,1057,157",
"roiBack": "113,102,1056,257",
"method": "Template matching",
"threshold": 0.8,
"description": "获得的六星"
Expand Down
Loading