Skip to content

Commit

Permalink
✨ 新增觉醒副本
Browse files Browse the repository at this point in the history
  • Loading branch information
AquamarineCyan committed Dec 9, 2023
1 parent 08b68e5 commit 5889768
Show file tree
Hide file tree
Showing 18 changed files with 434 additions and 357 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 最近更新

### 新功能

- 新增觉醒副本

### 优化

- 移除更新升级过程中的`任意键`
Expand Down
76 changes: 61 additions & 15 deletions src/package/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,61 @@
from . import (
yuhun, # 1
yongshengzhihai, # 2
yeyuanhuo, # 3
yuling, # 4
jiejietupo, # 5&6
daoguantupo, # 7
zhaohuan, # 8
baiguiyexing, # 9
huodong, # 10
rilun, # 11
tansuo, # 12
qiling, #13
xuanshangfengyin
)
from .baiguiyexing import BaiGuiYeXing
from .daoguantupo import DaoGuanTuPo
from .huodong import HuoDong
from .jiejietupo import JieJieTuPo, JieJieTuPoGeRen, JieJieTuPoYinYangLiao
from .juexing import JueXing
from .qiling import QiLing
from .rilun import RiLun
from .tansuo import TanSuo
from .xuanshangfengyin import XuanShangFengYin, task_xuanshangfengyin
from .yeyuanhuo import YeYuanHuo
from .yongshengzhihai import YongShengZhiHai, YongShengZhiHaiTeam
from .yuhun import YuHun, YuHunSingle, YuHunTeam
from .yuling import YuLing
from .zhaohuan import ZhaoHuan
from .utils import FightResource

__all__ = [
"FightResource",
"BaiGuiYeXing",
"DaoGuanTuPo",
"HuoDong",
# "JieJieTuPo",
"JieJieTuPoGeRen",
"JieJieTuPoYinYangLiao",
"JueXing",
"QiLing",
"RiLun",
"TanSuo",
# "XuanShangFengYin",
"task_xuanshangfengyin",
"YeYuanHuo",
"YuLing",
"YongShengZhiHai",
"YongShengZhiHaiTeam",
"YuHun",
"YuHunSingle",
"YuHunTeam",
"ZhaoHuan",
"get_package_resource_list",
]


def get_package_resource_list():
print("get_package_resource_list")
return [
FightResource,
BaiGuiYeXing,
DaoGuanTuPo,
HuoDong,
JieJieTuPo,
JueXing,
QiLing,
RiLun,
TanSuo,
XuanShangFengYin,
YeYuanHuo,
YongShengZhiHai,
YuHun,
YuLing,
ZhaoHuan
]
1 change: 1 addition & 0 deletions src/package/baiguiyexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BaiGuiYeXing(Package):
"kaishi", # 开始
"baiguiqiyueshu", # 百鬼契约书
]
description = "仅适用于清票,无法指定鬼王"

@log_function_call
def __init__(self, n: int = 0) -> None:
Expand Down
10 changes: 6 additions & 4 deletions src/package/daoguantupo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DaoGuanTuPo(Package):
"title", # 标题
"zhanbao", # 战报
]
description = "目前仅支持正在进行中的道馆突破,无法实现跳转道馆场景"

@log_function_call
def __init__(self, flag_guanzhan: bool = False) -> None:
Expand Down Expand Up @@ -180,7 +181,7 @@ def run(self):
f"{RESOURCE_FIGHT_PATH}/ready_new",
f"{RESOURCE_FIGHT_PATH}/victory",
f"{RESOURCE_FIGHT_PATH}/fail",
f"{RESOURCE_FIGHT_PATH}/finish"
f"{RESOURCE_FIGHT_PATH}/finish",
]
scene, coor = self.check_scene_multiple_once()
if scene is None:
Expand All @@ -194,11 +195,12 @@ def run(self):
click(coor)
self.n += 1
logger.num(str(self.n))
random_sleep(1, 2)
random_sleep()
case "victory":
random_sleep(1, 2)
random_sleep()
case "finish":
self.ensure_finish()
finish_random_left_right()
break
case "fail":
logger.ui("失败,需要手动处理", "warn")
break
Expand Down
4 changes: 2 additions & 2 deletions src/package/huodong.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class HuoDong(Package):
"title",
"start",
]
description = """适配活动「演武练习」
可替换 resource/huodong 下的素材"""
description = "未适配活动「超鬼王」\
可自行替换 resource/huodong 下的素材"

@log_function_call
def __init__(self, n: int = 0) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/package/jiejietupo.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class JieJieTuPoGeRen(JieJieTuPo):
间隔高30
"""
scene_name = "个人突破"
description = "默认3胜刷新,上限30"
tupo_geren_x = {
1: 215,
2: 515,
Expand Down
77 changes: 77 additions & 0 deletions src/package/juexing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# juexing.py
"""觉醒副本"""

from ..utils.decorator import log_function_call
from ..utils.event import event_thread
from ..utils.function import (
RESOURCE_FIGHT_PATH,
check_click,
check_scene_multiple_once,
click,
finish_random_left_right,
random_sleep
)
from ..utils.log import logger
from .utils import Package


class JueXing(Package):
"""觉醒副本"""
scene_name = "觉醒副本"
resource_path = "juexing"
resource_list = [
"title", # 标题
]
description = "单人觉醒副本"

@log_function_call
def __init__(self, n: int = 0) -> None:
super().__init__(n)

@log_function_call
def start(self):
"""挑战开始"""
check_click(f"{RESOURCE_FIGHT_PATH}/start_single")

def run(self):
self.current_resource_list = [
f"{self.resource_path}/title",
f"{RESOURCE_FIGHT_PATH}/start_single",
f"{RESOURCE_FIGHT_PATH}/finish",
f"{RESOURCE_FIGHT_PATH}/fail",
f"{RESOURCE_FIGHT_PATH}/victory",
]
_flag_title_msg: bool = True
logger.num(f"0/{self.max}")
self.log_current_scene_list()

while self.n < self.max:
if event_thread.is_set():
return
scene, coor = check_scene_multiple_once(self.current_resource_list)
if scene is None:
continue
scene = self.scene_handle(scene)

match scene:
case "title":
logger.scene(self.scene_name)
_flag_title_msg = False
self.start()
case "start_single":
click(coor)
case "fail":
logger.ui("失败,需要手动处理", "warn")
break
case "victory":
logger.ui("胜利")
case "finish":
finish_random_left_right()
self.done()
case _:
if _flag_title_msg:
logger.ui("请检查游戏场景", "warn")
_flag_title_msg = False
random_sleep()
30 changes: 11 additions & 19 deletions src/package/tansuo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import pyautogui

from src.utils.event import event_thread
from ..utils.application import RESOURCE_DIR_PATH
from ..utils.coordinate import Coor
from ..utils.decorator import log_function_call, run_in_thread, time_count
from ..utils.decorator import log_function_call
from ..utils.event import event_thread
from ..utils.function import (
check_click,
check_finish_once,
Expand All @@ -27,10 +27,9 @@

class TanSuo(Package):
"""探索"""

scene_name = "探索"
resource_path = "tansuo"
resource_list: list = [
resource_list = [
# "boss_finish",
"chuzhanxiaohao",
"fighting",
Expand All @@ -49,10 +48,10 @@ class TanSuo(Package):
"treasure_box",
# "zidonglunhuan",
]
description = "提前准备好自动轮换和加成,仅单人探索"

def __init__(self, n: int = 0) -> None:
self.n = 0 # 当前次数
self.max = n # 总次数
super().__init__(n)
self.flag_boss_done: bool = False # boss战结束

def get_all_coor_info_tansuo_center(self, file: str):
Expand Down Expand Up @@ -105,9 +104,7 @@ def title(self) -> bool:
scene, coor = check_scene_multiple_once(scene_list, self.resource_path)
if scene is None:
continue
if "/" in scene:
scene = scene.split("/")[-1]
logger.scene(scene)
scene = self.scene_handle(scene)

match scene:
case "chuzhanxiaohao" | "tansuo_28" | "tansuo_28_0" | "tansuo_28_title":
Expand Down Expand Up @@ -165,9 +162,6 @@ def finish(self):
# 妖气封印
return

@run_in_thread
@time_count
@log_function_call
def run(self):
_scene_list = [
"tansuo_28_0",
Expand All @@ -176,7 +170,6 @@ def run(self):
"tansuo",
"chuzhanxiaohao",
]
logger.ui("单人探索,测试功能", "warn")

while self.n < self.max and self.title():
if event_thread.is_set():
Expand All @@ -191,16 +184,16 @@ def run(self):
case "tansuo_28_0": # 右侧列表按钮
# function.judge_click(f"{self.resource_path}/tansuo")
click(coor)
random_sleep(1, 2)
random_sleep()
# self.n += 1
case "tansuo_28_title":
check_click(f"{self.resource_path}/tansuo")
self.check_click("tansuo")
# self.n += 1
random_sleep(2, 3)
random_sleep(2)
case "chuzhanxiaohao":
random_sleep(0.5, 1)
# 先判断boss面灵气
coor = get_coor_info(f"{self.resource_path}/fighting_boss")
coor = self.get_coor_info("fighting_boss")
if coor.is_effective:
logger.scene("BOSS")
click(coor)
Expand All @@ -212,9 +205,8 @@ def run(self):
self.fighting()
else:
drag_in_window(-400, 0)
random_sleep(1, 2)
random_sleep()
if self.flag_boss_done:
self.flag_boss_done = False
self.finish()
self.done()
logger.ui(f"已完成 {self.scene_name} {self.n}次")
35 changes: 32 additions & 3 deletions src/package/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time

from ..utils.decorator import run_in_thread
from ..utils.decorator import log_function_call, run_in_thread
from ..utils.event import event_thread
from ..utils.function import (
RESOURCE_FIGHT_PATH,
Expand All @@ -18,6 +18,27 @@
from ..utils.toast import toast


class FightResource:
"""通用战斗资源"""
resource_path: str = "fight" # 路径
resource_list: list = [ # 资源列表
"accept_invitation", # 接受邀请
"fail", # 失败
"finish", # 结束
"fighting_friend_default", # 战斗中好友图标-怀旧/简约
"fighting_friend_linshuanghanxue", # 战斗中好友图标-凛霜寒雪
"fighting_friend_chunlvhanqing", # 战斗中好友图标-春缕含青
"passenger_2", # 队员2
"passenger_3", # 队员3
"start_single", # 单人挑战
"start_team", # 组队挑战
"tanchigui", # 贪吃鬼
"victory", # 成功
"ready_old", # 准备-怀旧主题
"ready_new", # 准备-简约主题
]


class Package:

scene_name: str = None
Expand All @@ -28,17 +49,22 @@ class Package:
"""资源列表"""
description: str = None
"""功能描述"""
fast_time: int = 0
"""最快通关速度,用于中途等待"""

@log_function_call
def __init__(self, n: int = 0) -> None:
self.n: int = 0
"""当前次数"""
self.max: int = n
"""总次数"""
self.current_resource_list: list = None
"""当前使用的资源列表"""
self.current_scene: str = None
"""当前场景"""

def get_coor_info(self, file):
return get_coor_info(f"{self.resource_path}/{file}")
def get_coor_info(self, file, *args, **kwargs):
return get_coor_info(f"{self.resource_path}/{file}", *args, **kwargs)

def check_click(self, file, *args, **kwargs):
return check_click(f"{self.resource_path}/{file}", *args, **kwargs)
Expand All @@ -53,9 +79,12 @@ def scene_print(self, scene: str = None) -> None: # FIXME remove
logger.scene(scene)

def scene_handle(self, scene: str = None) -> str:
if scene == None:
scene = self.current_scene
logger.info(f"current scene: {scene}")
if "/" in scene:
scene = scene.split("/")[-1]
self.current_scene = scene
return scene

def log_current_scene_list(self) -> None:
Expand Down
Loading

0 comments on commit 5889768

Please sign in to comment.