Skip to content

Commit

Permalink
#58 补充事件
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorReid committed Aug 18, 2024
1 parent 2bce50a commit 68f995b
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 8 deletions.
30 changes: 30 additions & 0 deletions assets/game_data/hollow_zero/entry_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,33 @@
need_step: 0
is_benefit: false
- entry_name: "资源回收小组"
- entry_name: "按压式开关"
is_benefit: false
- entry_name: "弹射-上"
is_benefit: false
move_afterwards: true
- entry_name: "轨道-上"
is_benefit: false
move_afterwards: true
- entry_name: "同伴"
is_benefit: false
- entry_name: "弹射-下"
is_benefit: false
move_afterwards: true
- entry_name: "弹射-左"
is_benefit: false
move_afterwards: true
- entry_name: "弹射-右"
is_benefit: false
move_afterwards: true
- entry_name: "轨道-下"
is_benefit: false
move_afterwards: true
- entry_name: "轨道-左"
is_benefit: false
move_afterwards: true
- entry_name: "轨道-右"
is_benefit: false
move_afterwards: true
- entry_name: "房屋残骸"
is_benefit: false
10 changes: 10 additions & 0 deletions assets/game_data/hollow_zero/normal_event/裂隙.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- entry_name: "裂隙"
event_name: "事件裂隙"
options:
- option_name: "放弃挣扎,拥抱深渊"
- option_name: "物品遗失"
desc: "失去2个随机鸣徽"
- option_name: "直面恐惧"
desc: "压力值变为90"
- option_name: "意外之伤"
desc: "随机一名角色损失50%生命值"
5 changes: 5 additions & 0 deletions src/zzz_od/context/battle_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,11 @@ def _check_battle_end(self, screen: MatLike, screenshot_time: float,
if result == FindAreaResultEnum.TRUE:
self.last_check_end_result = '普通战斗-完成'
return
result = screen_utils.find_area(ctx=self.ctx, screen=screen,
screen_name='战斗画面', area_name='战斗结果-撤退')
if result == FindAreaResultEnum.TRUE:
self.last_check_end_result = '普通战斗-撤退'
return

self.last_check_end_result = None
except Exception:
Expand Down
2 changes: 2 additions & 0 deletions src/zzz_od/context/hollow_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def check_before_move(self, screen: MatLike) -> None:
"""
if self.agent_list is None:
self.check_agent_list(screen)
if self.level_info is None or self.level_info.level is None:
pass

def get_next_to_move(self, current_map: HollowZeroMap) -> Optional[HollowZeroMapNode]:
"""
Expand Down
4 changes: 3 additions & 1 deletion src/zzz_od/hollow_zero/game_data/hollow_zero_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
class HollowZeroEntry:

def __init__(self, entry_name: str, is_benefit: bool = True, need_step: int = 1,
is_base: bool = False, can_go: bool = True, is_tp: bool = False):
is_base: bool = False, can_go: bool = True, is_tp: bool = False,
move_afterwards: bool = False):
# TODO 要将这里改成不可改
self.entry_name: str = entry_name
self.is_benefit: bool = is_benefit
self.need_step: int = need_step
self.is_base: bool = is_base # 是否电视机底座
self.can_go: bool = can_go # 是否可同行
self.is_tp: bool = is_tp # 是否传送点
self.move_afterwards: bool = move_afterwards # 进入后会触发额外移动 轨道、弹射等


class HallowZeroNormalEventOption:
Expand Down
34 changes: 28 additions & 6 deletions src/zzz_od/hollow_zero/hollow_map/hollow_map_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def construct_map_from_yolo_result(detect_result: DetectFrameResult, name_2_entr
else: # 旧的是格子类型 那么把底座的范围赋值上去
to_merge.pos = pos
else:
node = HollowZeroMapNode(pos, entry, check_time=detect_result.run_time)
node = HollowZeroMapNode(pos, entry,
check_time=detect_result.run_time,
confidence=result.score)
nodes.append(node)

for node in nodes:
Expand All @@ -60,18 +62,38 @@ def construct_map_from_nodes(nodes: List[HollowZeroMapNode], check_time: float)
edges: dict[int, List[int]] = {}

for i in range(len(nodes)):
for j in range(i + 1, len(nodes)):
for j in range(len(nodes)):
node_1 = nodes[i]
node_2 = nodes[j]

if _at_left(node_1, node_2): # 1在2左边
_add_edge(edges, i, j)
if node_2.entry.entry_name in ['轨道-左']:
pass
elif node_1.entry.entry_name in ['轨道-上', '轨道-下', '轨道-左']:
pass
else:
_add_directed_edge(edges, i, j)
elif _at_right(node_1, node_2): # 1在2右边
_add_edge(edges, i, j)
if node_2.entry.entry_name in ['轨道-右']:
pass
elif node_1.entry.entry_name in ['轨道-上', '轨道-下', '轨道-右']:
pass
else:
_add_directed_edge(edges, i, j)
elif _above(node_1, node_2): # 1在2上边
_add_edge(edges, i, j)
if node_2.entry.entry_name in ['轨道-上']:
pass
elif node_1.entry.entry_name in ['轨道-左', '轨道-右', '轨道-上']:
pass
else:
_add_directed_edge(edges, i, j)
elif _under(node_1, node_2): # 1在2下边
_add_edge(edges, i, j)
if node_2.entry.entry_name in ['轨道-下']:
pass
elif node_1.entry.entry_name in ['轨道-左', '轨道-右', '轨道-下']:
pass
else:
_add_directed_edge(edges, i, j)

return HollowZeroMap(nodes, current_idx, edges, check_time=check_time)

Expand Down
5 changes: 4 additions & 1 deletion src/zzz_od/hollow_zero/hollow_map/hollow_zero_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

class HollowZeroMapNode:

def __init__(self, pos: Rect, entry: HollowZeroEntry, check_time: Optional[float] = None):
def __init__(self, pos: Rect, entry: HollowZeroEntry,
check_time: Optional[float] = None,
confidence: float = 0):
self.pos: Rect = pos
self.entry: HollowZeroEntry = entry
self.check_time: float = time.time() if check_time is None else check_time # 识别时间
self.confidence: float = confidence


class HollowZeroMapEdge:
Expand Down
7 changes: 7 additions & 0 deletions src/zzz_od/operation/hollow_zero/hollow_battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ def update_level_info(self) -> OperationRoundResult:
self.ctx.hollow.update_to_next_level()
return self.round_success()

@node_from(from_name='自动战斗', status='普通战斗-撤退')
@operation_node(name='战斗撤退')
def battle_fail(self) -> OperationRoundResult:
screen = self.screenshot()
return self.round_by_find_and_click_area(screen, '战斗画面', '战斗结果-撤退',
success_wait=1, retry_wait=1)

def _check_distance(self, screen: MatLike) -> None:
mr = self.ctx.battle.check_battle_distance(screen)

Expand Down

0 comments on commit 68f995b

Please sign in to comment.