曲谱导航改进
All checks were successful
ci/woodpecker/push/check_format Pipeline was successful

This commit is contained in:
Elaina 2025-04-08 13:04:50 +08:00
parent cfd057b920
commit 3169d885ca
9 changed files with 77 additions and 20 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,30 +1,44 @@
import cv2
from mower.utils import config
from mower.utils.image import loadres
from mower.utils.log import logger
from mower.utils.scene import Scene
from mower.utils.solver import BaseSolver
from mower.utils.vector import va, vs
class Score(BaseSolver):
solver_name = "曲谱"
timeline = {
"主题曲": [],
"方舟": [],
"那被祝福的": [],
"山雪与银铁": [],
"七丘的新芽": [],
"霓虹之下": [],
"岁岁今朝": [],
"摘取未来之人": [],
"自海渊的一瞥": [],
"高塔迷影": [],
"薪火重燃": [],
"夏日律动": ["OF"],
"泰拉奇谈": [],
"主题曲": {},
"方舟": {},
"那被祝福的": {},
"山雪与银铁": {},
"七丘的新芽": {},
"霓虹之下": {},
"岁岁今朝": {},
"摘取未来之人": {},
"自海渊的一瞥": {},
"高塔迷影": {},
"薪火重燃": {},
"夏日律动": {
"OF": (0, 0),
"RI": [628, 18],
"DH": [1239, 17],
"IC": [1824, 19],
"SL": [2439, 26],
"AS": [3016, 44],
},
"泰拉奇谈": {},
}
def run(self, target: str):
dash = target.rfind("-")
self.prefix = target[0:dash]
self.suffix = target[dash + 1 :]
self.generates_imgs()
return super().run()
@property
@ -38,15 +52,39 @@ class Score(BaseSolver):
if self.find(f"navigation/score/small/{key}"):
return key
def generates_imgs(self):
self.prefixes = {}
for prefix in self.timeline[self.group]:
self.prefixes[prefix] = loadres(
f"navigation/score/timeline/{self.group}/{prefix}", True
)
def find_prefix(self):
prefix, val, loc = None, 0, None
for n, img in self.prefixes.items():
result = cv2.matchTemplate(config.recog.gray, img, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if max_val > val:
val = max_val
loc = max_loc
prefix = n
logger.debug(f"{loc}找到关卡{prefix}")
target = va(
vs(loc, self.timeline[self.group][prefix]),
self.timeline[self.group][self.prefix],
)
if target[0] > 1920:
self.swipe_ext([(1400, 540), (400, 540), (400, 800)], [200, 300], 0, 0.1)
elif target[0] < 0:
self.swipe_ext([(400, 540), (1400, 540), (1400, 800)], [200, 300], 0, 0.1)
else:
self.ctap(target, 5)
def transition(self):
if (scene := self.scene()) == Scene.TERMINAL_SCORE:
if self.find("navigation/score/circle"):
if self.find(f"navigation/score/large/{self.group}"):
if pos := self.find("navigation/score/timeline/OF"):
self.ctap(pos, 5)
return
# TODO: OF以外的关卡
self.swipe_ext([(300, 580), (1600, 580)], [500], 800)
self.find_prefix()
return
self.ctap("navigation/score/circle", 5)
return

View file

@ -363,7 +363,6 @@ template_matching = {
"navigation/score/small/那被祝福的": ((140, 100), (530, 850)),
"navigation/score/small/霓虹之下": ((140, 100), (530, 850)),
"navigation/score/small/高塔迷影": ((140, 100), (530, 850)),
"navigation/score/timeline/OF": ((0, 600), (1920, 800)),
"next_friend_available": (1687, 886),
"no_user": (45, 948),
"ope_agency_fail": (809, 959),

View file

@ -279,7 +279,12 @@ Res = Literal[
"navigation/score/small/那被祝福的",
"navigation/score/small/霓虹之下",
"navigation/score/small/高塔迷影",
"navigation/score/timeline/OF",
"navigation/score/timeline/夏日律动/AS",
"navigation/score/timeline/夏日律动/DH",
"navigation/score/timeline/夏日律动/IC",
"navigation/score/timeline/夏日律动/OF",
"navigation/score/timeline/夏日律动/RI",
"navigation/score/timeline/夏日律动/SL",
"navigation/tutorial",
"navigation/whole_scene/activity_ex",
"navigation/whole_scene/activity_normal",