Skip to content
18 changes: 16 additions & 2 deletions assets/game_data/screen_info/sim_uni.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ area_list:
pc_rect:
- 0
- 0
- 75
- 115
- 115
text: ''
lcs_percent: 0.5
Expand All @@ -100,6 +100,20 @@ area_list:
template_match_threshold: 0.7
color_range: null
goto_list: []
- area_name: 差分宇宙-暂离
id_mark: false
pc_rect:
- 1312
- 876
- 1391
- 924
text: 暂离
lcs_percent: 0.5
template_sub_dir: ''
template_id: ''
template_match_threshold: 0.7
color_range: null
goto_list: []
- area_name: 菜单-结束并结算
id_mark: false
pc_rect:
Expand Down Expand Up @@ -147,7 +161,7 @@ area_list:
pc_rect:
- 50
- 0
- 270
- 330
- 60
text: ''
lcs_percent: 0.5
Expand Down
4 changes: 4 additions & 0 deletions src/sr_od/app/sim_uni/operations/sim_uni_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def open_menu(self) -> OperationRoundResult:
def click_exit(self) -> OperationRoundResult:
screen = self.last_screenshot

result = self.round_by_find_and_click_area(screen, '模拟宇宙', '差分宇宙-暂离')
if result.is_success:
return self.round_success(result.status)

area_list = [
('模拟宇宙', '菜单-结束并结算'),
('模拟宇宙', '终止战斗并结算'),
Expand Down
3 changes: 3 additions & 0 deletions src/sr_od/app/sim_uni/sim_uni_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class SimUniLevelTypeEnum(Enum):
TRANSACTION = SimUniLevelType('transaction', '区域-交易', route_id='event')
RESPITE = SimUniLevelType('respite', '区域-休整')

# 在差分宇宙4.0中的识别标志
ANY = SimUniLevelType('any', '位面')


def level_type_from_id(level_type_id: str) -> Optional[SimUniLevelType]:
for enum in SimUniLevelTypeEnum:
Expand Down
22 changes: 19 additions & 3 deletions src/sr_od/app/sim_uni/sim_uni_screen_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class ScreenState(Enum):
SIM_UNI_REGION: str = '模拟宇宙-区域'
SIM_PATH: str = '命途'
GUIDE: str = '星际和平指南'
# 差分宇宙4.0
SELECT_STATION: str = '选择站点卡'
SELECT_NEXT_STATION: str = '选择下一站'
CHOOSE_WILL_POWER: str = '愿力满盈'
AHA_MASK: str = '欢愉假面'


def get_level_type(ctx: SrContext, screen: MatLike) -> Optional[SimUniLevelType]:
Expand All @@ -44,12 +49,12 @@ def get_level_type(ctx: SrContext, screen: MatLike) -> Optional[SimUniLevelType]
region_name = ctx.ocr.run_ocr_single_line(part)
level_type_list: List[SimUniLevelType] = [enum.value for enum in SimUniLevelTypeEnum]
target_list = [gt(level_type.type_name, 'game') for level_type in level_type_list]
target_idx = str_utils.find_best_match_by_difflib(region_name, target_list)
targets = [i for i, w in enumerate(target_list) if w in region_name]

if target_idx is None or target_idx < 0:
if len(targets) == 0:
return None
else:
return level_type_list[target_idx]
return level_type_list[targets[0]]


def get_sim_uni_screen_state(
Expand Down Expand Up @@ -116,6 +121,17 @@ def get_sim_uni_screen_state(
return battle_screen_state.ScreenState.BATTLE.value
return None

# region 差分宇宙4.0
if str_utils.find_best_match_by_lcs(ScreenState.SELECT_STATION.value, titles, lcs_percent_threshold=1):
return ScreenState.SELECT_STATION.value
if str_utils.find_best_match_by_lcs(ScreenState.SELECT_NEXT_STATION.value, titles, lcs_percent_threshold=1):
return ScreenState.SELECT_NEXT_STATION.value
if str_utils.find_best_match_by_lcs(ScreenState.CHOOSE_WILL_POWER.value, titles, lcs_percent_threshold=0.7):
return ScreenState.CHOOSE_WILL_POWER.value
if str_utils.find_best_match_by_lcs(ScreenState.AHA_MASK.value, titles, lcs_percent_threshold=0.7):
return ScreenState.AHA_MASK.value
# endregion

if sim_uni and str_utils.find_best_match_by_lcs(ScreenState.SIM_TYPE_NORMAL.value, titles, lcs_percent_threshold=0.51) is not None:
return ScreenState.SIM_TYPE_NORMAL.value

Expand Down
72 changes: 57 additions & 15 deletions src/sr_od/operations/back_to_normal_world_plus.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time
from one_dragon.base.geometry.point import Point
from one_dragon.base.operation.operation_node import operation_node
from one_dragon.base.operation.operation_round_result import OperationRoundResult
from one_dragon.utils.i18_utils import gt
Expand Down Expand Up @@ -67,21 +69,46 @@ def check_screen(self) -> OperationRoundResult:
curio=True,
drop_curio=True
)

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_BLESS.value:
return self.sim_uni_choose_bless()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_DROP_BLESS.value:
return self.sim_uni_drop_bless()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_CURIOS.value:
return self.sim_uni_choose_curio()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_DROP_CURIOS.value:
return self.sim_uni_drop_curio()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_EVENT.value:
return self.sim_uni_event()
if sim_uni_state is not None:
# region 差分宇宙4.0
if sim_uni_state == sim_uni_screen_state.ScreenState.SELECT_STATION.value: # 选择站点卡
self.ctx.controller.click(Point(160, 343)) # 第一个
time.sleep(0.2)
self.ctx.controller.click(Point(1626, 939)) # 确认
return self.round_wait(sim_uni_state, wait=2)
if sim_uni_state == sim_uni_screen_state.ScreenState.SELECT_NEXT_STATION.value: # 选择下一站
self.ctx.controller.click(Point(867, 589)) # 中间偏左
time.sleep(0.2)
self.ctx.controller.click(Point(701, 589)) # 第一个
time.sleep(0.2)
self.ctx.controller.click(Point(1152, 969)) # 确认
return self.round_wait(sim_uni_state, wait=3)
if sim_uni_state == sim_uni_screen_state.ScreenState.CHOOSE_WILL_POWER.value: # 选择奇迹
self.ctx.controller.click(Point(475, 483)) # 第一个
time.sleep(0.2)
self.ctx.controller.click(Point(953, 969)) # 确认
return self.round_wait(sim_uni_state, wait=1)
if sim_uni_state == sim_uni_screen_state.ScreenState.AHA_MASK.value: # 选择面具
self.ctx.controller.click(Point(343, 567)) # 第一个
time.sleep(1)
self.ctx.controller.click(Point(1576, 982)) # 确认
return self.round_wait(sim_uni_state, wait=1)
# endregion

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_BLESS.value:
return self.sim_uni_choose_bless()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_DROP_BLESS.value:
return self.sim_uni_drop_bless()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_CURIOS.value:
return self.sim_uni_choose_curio()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_DROP_CURIOS.value:
return self.sim_uni_drop_curio()

if sim_uni_state == sim_uni_screen_state.ScreenState.SIM_EVENT.value:
return self.sim_uni_event()

# 对话框 - 逐光捡金 退出确认
result = self.round_by_find_and_click_area(screen, '逐光捡金', '退出对话框确认')
Expand Down Expand Up @@ -158,3 +185,18 @@ def sim_uni_drop_curio(self) -> OperationRoundResult:
return self.round_wait(wait=1)
else:
return self.round_retry(wait=1)


def __debug():
ctx = SrContext()
ctx.init_ocr()
ctx.init_by_config()

ctx.start_running()
op = BackToNormalWorldPlus(ctx)
op.execute()
ctx.stop_running()


if __name__ == '__main__':
__debug()