mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-24 17:09:05 +08:00
Fix: ensure project after production
This commit is contained in:
@@ -263,7 +263,7 @@ class Island(IslandUI):
|
|||||||
self.device.drag(p1, p2, segments=2, shake=(0, 25), point_random=(0, 0, 0, 0), shake_random=(0, -5, 0, 5))
|
self.device.drag(p1, p2, segments=2, shake=(0, 25), point_random=(0, 0, 0, 0), shake_random=(0, -5, 0, 5))
|
||||||
self.device.sleep(sleep)
|
self.device.sleep(sleep)
|
||||||
|
|
||||||
def ensure_project(self, project: IslandProject, trial=5, skip_first_screenshot=True):
|
def ensure_project(self, project: IslandProject, trial=7, skip_first_screenshot=True):
|
||||||
for _ in range(trial):
|
for _ in range(trial):
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
skip_first_screenshot = False
|
skip_first_screenshot = False
|
||||||
@@ -271,6 +271,8 @@ class Island(IslandUI):
|
|||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
|
|
||||||
projects = self.project_detect(self.device.image)
|
projects = self.project_detect(self.device.image)
|
||||||
|
if not projects:
|
||||||
|
continue
|
||||||
if project.name in projects.get('name'):
|
if project.name in projects.get('name'):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ from module.island.ui import OCR_PRODUCTION_TIME, OCR_PRODUCTION_TIME_REMAIN
|
|||||||
from module.ocr.ocr import Ocr
|
from module.ocr.ocr import Ocr
|
||||||
|
|
||||||
|
|
||||||
|
class ProjectNameOcr(Ocr):
|
||||||
|
def after_process(self, result):
|
||||||
|
result = super().after_process(result)
|
||||||
|
result = re.sub(r'[^\u4e00-\u9fff]', '', result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class IslandProject:
|
class IslandProject:
|
||||||
valid: bool
|
valid: bool
|
||||||
name: str
|
name: str
|
||||||
@@ -42,7 +49,7 @@ class IslandProject:
|
|||||||
# name
|
# name
|
||||||
area = (self.x1 - 446, self.y1, self.x1 - 326, self.y2)
|
area = (self.x1 - 446, self.y1, self.x1 - 326, self.y2)
|
||||||
button = Button(area=area, color=(), button=area, name='PROJECT_NAME')
|
button = Button(area=area, color=(), button=area, name='PROJECT_NAME')
|
||||||
ocr = Ocr(button, lang='cnocr')
|
ocr = ProjectNameOcr(button, lang='cnocr')
|
||||||
self.name = ocr.ocr(self.image)
|
self.name = ocr.ocr(self.image)
|
||||||
if not self.name:
|
if not self.name:
|
||||||
self.valid = False
|
self.valid = False
|
||||||
|
|||||||
Reference in New Issue
Block a user