mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 10:01:10 +00:00
Add: Switch world before entering calyx golden
This commit is contained in:
parent
98efb031bc
commit
e27332c609
BIN
assets/share/dungeon/ui/CALYX_WORLD_1.png
Normal file
BIN
assets/share/dungeon/ui/CALYX_WORLD_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
assets/share/dungeon/ui/CALYX_WORLD_2.png
Normal file
BIN
assets/share/dungeon/ui/CALYX_WORLD_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
assets/share/dungeon/ui/CALYX_WORLD_3.png
Normal file
BIN
assets/share/dungeon/ui/CALYX_WORLD_3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
@ -3,6 +3,36 @@ from module.base.button import Button, ButtonWrapper
|
|||||||
# This file was auto-generated, do not modify it manually. To generate:
|
# This file was auto-generated, do not modify it manually. To generate:
|
||||||
# ``` python -m dev_tools.button_extract ```
|
# ``` python -m dev_tools.button_extract ```
|
||||||
|
|
||||||
|
CALYX_WORLD_1 = ButtonWrapper(
|
||||||
|
name='CALYX_WORLD_1',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/dungeon/ui/CALYX_WORLD_1.png',
|
||||||
|
area=(490, 185, 540, 230),
|
||||||
|
search=(470, 165, 560, 250),
|
||||||
|
color=(197, 196, 196),
|
||||||
|
button=(490, 185, 540, 230),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
CALYX_WORLD_2 = ButtonWrapper(
|
||||||
|
name='CALYX_WORLD_2',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/dungeon/ui/CALYX_WORLD_2.png',
|
||||||
|
area=(590, 185, 640, 230),
|
||||||
|
search=(570, 165, 660, 250),
|
||||||
|
color=(199, 198, 198),
|
||||||
|
button=(590, 185, 640, 230),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
CALYX_WORLD_3 = ButtonWrapper(
|
||||||
|
name='CALYX_WORLD_3',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/dungeon/ui/CALYX_WORLD_3.png',
|
||||||
|
area=(689, 186, 739, 231),
|
||||||
|
search=(669, 166, 759, 251),
|
||||||
|
color=(158, 158, 158),
|
||||||
|
button=(689, 186, 739, 231),
|
||||||
|
),
|
||||||
|
)
|
||||||
DAILY_TRAINING_CHECK = ButtonWrapper(
|
DAILY_TRAINING_CHECK = ButtonWrapper(
|
||||||
name='DAILY_TRAINING_CHECK',
|
name='DAILY_TRAINING_CHECK',
|
||||||
share=Button(
|
share=Button(
|
||||||
|
@ -31,6 +31,17 @@ class DungeonList(Keyword):
|
|||||||
from tasks.map.keywords import MapPlane
|
from tasks.map.keywords import MapPlane
|
||||||
return MapPlane.find_plane_id(self.plane_id)
|
return MapPlane.find_plane_id(self.plane_id)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def world(self):
|
||||||
|
"""
|
||||||
|
Returns:
|
||||||
|
MapWorld: MapWorld object or None
|
||||||
|
"""
|
||||||
|
if self.plane is not None:
|
||||||
|
return self.plane.world
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_Calyx_Golden(self):
|
def is_Calyx_Golden(self):
|
||||||
return 'Calyx_Golden' in self.name
|
return 'Calyx_Golden' in self.name
|
||||||
|
@ -27,6 +27,7 @@ from tasks.dungeon.keywords import (
|
|||||||
)
|
)
|
||||||
from tasks.dungeon.keywords.classes import DungeonEntrance
|
from tasks.dungeon.keywords.classes import DungeonEntrance
|
||||||
from tasks.dungeon.state import DungeonState
|
from tasks.dungeon.state import DungeonState
|
||||||
|
from tasks.map.keywords import KEYWORDS_MAP_WORLD
|
||||||
|
|
||||||
|
|
||||||
class DungeonTabSwitch(Switch):
|
class DungeonTabSwitch(Switch):
|
||||||
@ -76,7 +77,11 @@ class OcrDungeonNav(Ocr):
|
|||||||
|
|
||||||
class OcrDungeonList(Ocr):
|
class OcrDungeonList(Ocr):
|
||||||
def after_process(self, result):
|
def after_process(self, result):
|
||||||
|
# 乙太之蕾•雅利洛-Ⅵ
|
||||||
|
result = result.replace('-VI', '-Ⅵ')
|
||||||
|
|
||||||
result = super().after_process(result)
|
result = super().after_process(result)
|
||||||
|
|
||||||
if self.lang == 'cn':
|
if self.lang == 'cn':
|
||||||
result = result.replace('翼', '巽') # 巽风之形
|
result = result.replace('翼', '巽') # 巽风之形
|
||||||
result = result.replace('皖A0', '50').replace('皖', '')
|
result = result.replace('皖A0', '50').replace('皖', '')
|
||||||
@ -372,6 +377,43 @@ class DungeonUI(DungeonState):
|
|||||||
DUNGEON_NAV_LIST.select_row(dungeon.dungeon_nav, main=self, insight=False)
|
DUNGEON_NAV_LIST.select_row(dungeon.dungeon_nav, main=self, insight=False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _dungeon_world_set(self, dungeon: DungeonList, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Switch worlds in Calyx_Golden
|
||||||
|
"""
|
||||||
|
logger.hr('Dungeon world set', level=2)
|
||||||
|
if not dungeon.is_Calyx_Golden:
|
||||||
|
logger.warning(f'Dungeon {dungeon} is not Calyx Golden, no need to set world')
|
||||||
|
return
|
||||||
|
if dungeon.world is None:
|
||||||
|
logger.error(f'Dungeon {dungeon} does not belongs to any world')
|
||||||
|
return
|
||||||
|
dic_world_button = {
|
||||||
|
KEYWORDS_MAP_WORLD.Jarilo_VI: CALYX_WORLD_1,
|
||||||
|
KEYWORDS_MAP_WORLD.The_Xianzhou_Luofu: CALYX_WORLD_2,
|
||||||
|
KEYWORDS_MAP_WORLD.Penacony: CALYX_WORLD_3,
|
||||||
|
}
|
||||||
|
button = dic_world_button.get(dungeon.world)
|
||||||
|
if button is None:
|
||||||
|
logger.error(f'Dungeon {dungeon} with world {dungeon.world} has no corresponding world button')
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.info(f'Dungeon world set {dungeon.world}')
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if self.image_color_count(button, color=(18, 18, 18), threshold=180, count=50):
|
||||||
|
logger.info(f'Dungeon world at {dungeon.world}')
|
||||||
|
break
|
||||||
|
# Click
|
||||||
|
if self.ui_page_appear(page_guide, interval=2):
|
||||||
|
self.device.click(button)
|
||||||
|
continue
|
||||||
|
|
||||||
def _dungeon_insight(self, dungeon: DungeonList):
|
def _dungeon_insight(self, dungeon: DungeonList):
|
||||||
"""
|
"""
|
||||||
Pages:
|
Pages:
|
||||||
@ -534,8 +576,7 @@ class DungeonUI(DungeonState):
|
|||||||
# Reset search button
|
# Reset search button
|
||||||
DUNGEON_LIST.search_button = OCR_DUNGEON_LIST
|
DUNGEON_LIST.search_button = OCR_DUNGEON_LIST
|
||||||
|
|
||||||
if dungeon.is_Calyx_Golden \
|
if dungeon.is_Calyx_Crimson \
|
||||||
or dungeon.is_Calyx_Crimson \
|
|
||||||
or dungeon.is_Stagnant_Shadow \
|
or dungeon.is_Stagnant_Shadow \
|
||||||
or dungeon.is_Cavern_of_Corrosion \
|
or dungeon.is_Cavern_of_Corrosion \
|
||||||
or dungeon.is_Echo_of_War:
|
or dungeon.is_Echo_of_War:
|
||||||
@ -543,6 +584,12 @@ class DungeonUI(DungeonState):
|
|||||||
self._dungeon_insight(dungeon)
|
self._dungeon_insight(dungeon)
|
||||||
self._dungeon_enter(dungeon)
|
self._dungeon_enter(dungeon)
|
||||||
return True
|
return True
|
||||||
|
if dungeon.is_Calyx_Golden:
|
||||||
|
self._dungeon_nav_goto(dungeon)
|
||||||
|
self._dungeon_world_set(dungeon)
|
||||||
|
self._dungeon_insight(dungeon)
|
||||||
|
self._dungeon_enter(dungeon)
|
||||||
|
return True
|
||||||
|
|
||||||
logger.error(f'Goto dungeon {dungeon} is not supported')
|
logger.error(f'Goto dungeon {dungeon} is not supported')
|
||||||
return False
|
return False
|
||||||
|
@ -37,6 +37,9 @@ class MapPlane(Keyword):
|
|||||||
return instance
|
return instance
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def __hash__(self) -> int:
|
||||||
|
return super().__hash__()
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def world(self) -> "MapWorld":
|
def world(self) -> "MapWorld":
|
||||||
"""
|
"""
|
||||||
@ -154,6 +157,9 @@ class MapWorld(Keyword):
|
|||||||
return instance
|
return instance
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def __hash__(self) -> int:
|
||||||
|
return super().__hash__()
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_Herta(self):
|
def is_Herta(self):
|
||||||
return self.short_name == 'Herta'
|
return self.short_name == 'Herta'
|
||||||
|
Loading…
Reference in New Issue
Block a user