Initial public release
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
|
||||
r = lib.load(sys.argv[1])
|
||||
rows = r.state_rows()
|
||||
lib.check(any(opcode == 0x26 for _, opcode, _ in r.c2s_ops()), "没有喝药包 0x26")
|
||||
before = {(item.get("x"), item.get("id")) for item in rows[0].get("items", []) if item.get("mode") == 2} if rows else set()
|
||||
after = {(item.get("x"), item.get("id")) for item in rows[-1].get("items", []) if item.get("mode") == 2} if rows else set()
|
||||
lib.check(before != after, "腰带物品集合没有变化")
|
||||
gone = sorted(x for x, _ in before - after) # 脚本点的是底栏第 3 格 = 腰带第 3 列(格位 x = 2):喝掉的必须是这一列的(第 3、4 列的键写反过,点第 3 格喝了第 4 列) | The script taps bottom bar slot 3 = belt column 3 (slot x = 2): what gets drunk must be from this column (the keys for columns 3 and 4 were once swapped, and tapping slot 3 drank from column 4)
|
||||
lib.check(gone == [2], f"喝掉的不是第 3 列:消失的格位 {gone}")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,2 @@
|
||||
0 down 0 1450,1241
|
||||
0.2 up 0
|
||||
@@ -0,0 +1,11 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
|
||||
r = lib.load(sys.argv[1])
|
||||
seen = [row.get("players") for row in r.state_rows()]
|
||||
lib.check(seen and seen[0] == 1, f"起局人数档应为 1,实际 {seen[:1]}")
|
||||
lib.check(seen and seen[-1] == 8, f"选第 8 格后人数档应为 8,实际 {seen[-1:]}")
|
||||
lib.check(not any(op == 0x30 for _, op, _ in r.c2s_ops()), "点难度格不应打开功能页(0x30)")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,5 @@
|
||||
# 难度(底部 UI v4 第 0 格):点第 0 格展开 1–8 选择条,点第 8 格 → 人数档 8(下一拍走原版 /players 路径)。坐标 = 2868×1320 效果图像素
|
||||
0.5 down 0 1090,1241
|
||||
0.6 up 0
|
||||
1.5 down 0 1810,1051
|
||||
1.6 up 0
|
||||
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
|
||||
r = lib.load(sys.argv[1])
|
||||
rows = [(row.get("tick"), row.get("act"), row.get("arg")) for row in r._uimsg if row.get("cat") == "PanelManager"]
|
||||
note_open = [t for t, act, arg in rows if act == "OpenPanel" and arg == "NotificationPanel"]
|
||||
note_close = [t for t, act, arg in rows if act == "ClosePanel" and arg == "NotificationPanel"]
|
||||
inv_open = [t for t, act, arg in rows if act == "OpenPanel" and arg == "PlayerInventoryExpansionLayout"]
|
||||
lib.check(len(note_open) == 1, f"改难度后系统通知应弹一次,实际 {note_open}")
|
||||
lib.check(len(inv_open) == 1, f"通知开着时点功能键应打开功能页一次,实际 {inv_open}")
|
||||
if note_open and inv_open:
|
||||
lib.check(note_open[0] < inv_open[0], f"功能页应在通知弹出之后打开(通知拍 {note_open[0]},功能页拍 {inv_open[0]})")
|
||||
lib.check(not note_close or note_close[0] > inv_open[0], f"通知不应被这次按键关掉(通知关于拍 {note_close[:1]},功能页开于拍 {inv_open[0]})")
|
||||
# 停留时长是产品覆盖层设的 5 秒(dm/ios/tools/gen_romfs_overlay.py 的 notificationSeconds;原版 10 秒 ≈ 270 拍)。在覆盖层上实测开到关 146 拍
|
||||
# The dwell time is the 5 seconds set by the product overlay (notificationSeconds in dm/ios/tools/gen_romfs_overlay.py; the original game's 10 seconds ≈ 270 ticks). Measured on the overlay: 146 ticks from open to close
|
||||
lib.check(bool(note_close) and 120 <= note_close[0] - note_open[0] <= 175, f"通知应约 5 秒(实测 146 拍)后自己关,实际开 {note_open} 关 {note_close}")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,7 @@
|
||||
# 改难度后游戏弹系统通知「游戏难度设为 N…」(停 10 秒)。通知还开着时点红十字(功能键)必须打开功能页,不被通知吃掉(r28 剪口,真机发现)
|
||||
0.5 down 0 1090,1241
|
||||
0.6 up 0
|
||||
1.5 down 0 1810,1051
|
||||
1.6 up 0
|
||||
4.0 down 0 1690,1241
|
||||
4.1 up 0
|
||||
@@ -0,0 +1 @@
|
||||
1200
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
r = lib.load(sys.argv[1])
|
||||
ticks = sorted(r._state_by_tick)
|
||||
lib.check(any(a == "OpenPanel" and p == "HoradricCubeLayout" for _, a, p in r._panel_events), "双击魔盒后魔盒面板打开(界面消息 OpenPanel HoradricCubeLayout)")
|
||||
lib.check(all(r.cursor_at(t) is None for t in ticks), "双击全程 cursor 为空(没拿起)")
|
||||
lib.check(not any(op == 0x19 for _, op, _ in r.c2s_ops()), "双击不发 0x19 拿起")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,7 @@
|
||||
# 物品区双击 = 按住 A(游戏提示「按住打开 / 使用 / 装备」)。术士存档魔盒占背包 (8,0)–(9,1),心点 1775,832;双击 → 魔盒面板打开,不拿起。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.0 down 0 1775,832
|
||||
2.1 up 0
|
||||
2.3 down 0 1775,832
|
||||
2.4 up 0
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
|
||||
r = lib.load(sys.argv[1])
|
||||
ticks = sorted(r._state_by_tick)
|
||||
first_tick = min(ticks)
|
||||
initial = r.items_at(first_tick)
|
||||
source = [item for item in initial.values() if item.get("x") == 5 and item.get("y") == 3]
|
||||
target = [item for item in initial.values() if item.get("x") == 6 and item.get("y") == 3]
|
||||
lib.check(len(source) == 1, "初始 (5,3) 目标物品唯一")
|
||||
lib.check(not target, "初始 (6,3) 目标格为空")
|
||||
if source:
|
||||
item_id = source[0]["id"]
|
||||
picked = [t for t in ticks if r.items_at(t).get(item_id, {}).get("mode") == 4 and r.cursor_at(t) == item_id]
|
||||
placed = [t for t in ticks if r.items_at(t).get(item_id, {}).get("x") == 6 and r.items_at(t).get(item_id, {}).get("y") == 3 and r.items_at(t).get(item_id, {}).get("mode") == 0 and r.cursor_at(t) is None]
|
||||
lib.check(bool(picked), "某拍 cursor 指向目标物品且 mode=4")
|
||||
lib.check(bool(placed), "最终目标物品在 (6,3)、mode=0 且 cursor 清空")
|
||||
lib.check(all(item_id == r.cursor_at(t) for t in ticks if r.cursor_at(t) is not None), "全程没有拿起第二件物品")
|
||||
lib.check(all(item.get("id") == item_id or item.get("mode") != 4 for t in ticks for item in r.items_at(t).values()), "全程没有误触发第二件物品 mode=4")
|
||||
ops = r.c2s_ops()
|
||||
lib.check(any(op == 0x19 for _, op, _ in ops), "c2s 含 0x19 拿起")
|
||||
lib.check(any(op == 0x18 for _, op, _ in ops), "c2s 含 0x18 放下")
|
||||
lib.check(next((t for t, op, _ in ops if op == 0x19), 1 << 60) < next((t for t, op, _ in ops if op == 0x18), 0), "0x19 先于 0x18")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,8 @@
|
||||
# 先点屏幕功能键开背包;物品格 (5,3) 心点 1478,1003,右邻 (6,3) 心点 1563,1003。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.0 down 0 1478,1003
|
||||
2.2 move 0 1500,1003
|
||||
2.5 move 0 1535,1003
|
||||
2.8 move 0 1563,1043
|
||||
3.2 up 0
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
|
||||
r = lib.load(sys.argv[1])
|
||||
ticks = sorted(r._state_by_tick)
|
||||
initial = r.items_at(min(ticks))
|
||||
source = [item for item in initial.values() if item.get("x") == 5 and item.get("y") == 3]
|
||||
lib.check(len(source) == 1, "初始 (5,3) 目标物品唯一")
|
||||
if source:
|
||||
item_id = source[0]["id"]
|
||||
final = r.items_at(ticks[-1]).get(item_id, {})
|
||||
lib.check(final.get("x") == 5 and final.get("y") == 3 and final.get("mode") == 0, "拖回后物品仍在 (5,3)、mode=0")
|
||||
lib.check(r.cursor_at(ticks[-1]) is None, "拖回最终 cursor 为空")
|
||||
lib.check(all(item_id == r.cursor_at(t) for t in ticks if r.cursor_at(t) is not None), "拖回全程没有拿起第二件物品")
|
||||
ops = r.c2s_ops()
|
||||
lib.check(any(op == 0x19 for _, op, _ in ops), "c2s 含 0x19 拿起")
|
||||
lib.check(any(op == 0x18 for _, op, _ in ops), "c2s 含 0x18 放下")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,7 @@
|
||||
# 先点屏幕功能键开背包;物品格 (5,3) 心点 1478,1003,回放时松手点下移 40pt。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.0 down 0 1478,1003
|
||||
2.2 move 0 1510,1003
|
||||
2.5 move 0 1478,1043
|
||||
3.2 up 0
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
r = lib.load(sys.argv[1])
|
||||
ops = [op for _, op, _ in r.c2s_ops()]
|
||||
lib.check(0x19 in ops, "c2s 含 0x19 拿起")
|
||||
lib.check(0x17 in ops, "c2s 含 0x17 丢到地上")
|
||||
lib.check(0x19 in ops and 0x17 in ops and ops.index(0x19) < ops.index(0x17), "0x19 先于 0x17")
|
||||
lib.check(0x18 not in ops, "没有放回格子(0x18)")
|
||||
rows = r.state_rows() if callable(getattr(r, "state_rows", None)) else []
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,8 @@
|
||||
# 拖到面板外松手 = 丢弃:从物品格 (5,3) 拖到屏幕左缘(面板外),指针回原处后按 Y(拿着物品时游戏提示「Y 丢弃」)。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.0 down 0 1478,1003
|
||||
2.3 move 0 1300,1003
|
||||
2.6 move 0 600,800
|
||||
3.0 move 0 80,660
|
||||
3.4 up 0
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
r = lib.load(sys.argv[1])
|
||||
first_tick = min(r._state_by_tick)
|
||||
initial = r.items_at(first_tick)
|
||||
targets = [item for item in initial.values() if item.get("x") == 5 and item.get("y") == 3]
|
||||
lib.check(len(targets) == 1, "初始 (5,3) 目标物品唯一")
|
||||
if targets:
|
||||
item_id = targets[0]["id"]
|
||||
rows = [r.items_at(t).get(item_id) for t in sorted(r._state_by_tick)]
|
||||
lib.check(all(row and row.get("x") == 5 and row.get("y") == 3 for row in rows), "长按期间目标物品始终在 (5,3)")
|
||||
lib.check(all(r.cursor_at(t) is None for t in sorted(r._state_by_tick)), "长按全程 cursor 为空")
|
||||
lib.check(not any(op == 0x19 for _, op, _ in r.c2s_ops()), "长按不发 0x19")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,5 @@
|
||||
# 术士存档目标:DM_STATE 初始背包物品格 (5,3),脚本断言按格位取 id,不硬编码数字。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.0 down 0 1478,1003
|
||||
2.8 up 0
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
# 物品区单击 = 只移光标(游戏出物品说明),不拿起(单击选中并展示详情;拿起只在拖动时)
|
||||
# Single tap in the item area = only moves the cursor (the game shows the item description), no pick-up (a single tap selects and shows details; pick-up happens only on drag)
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
r = lib.load(sys.argv[1])
|
||||
first_tick = min(r._state_by_tick)
|
||||
initial = r.items_at(first_tick)
|
||||
targets = [item for item in initial.values() if item.get("x") == 5 and item.get("y") == 3]
|
||||
lib.check(len(targets) == 1, "初始 (5,3) 目标物品唯一")
|
||||
if targets:
|
||||
item_id = targets[0]["id"]
|
||||
rows = [r.items_at(t).get(item_id) for t in sorted(r._state_by_tick)]
|
||||
lib.check(all(row and row.get("x") == 5 and row.get("y") == 3 and row.get("mode") == 0 for row in rows), "单击后目标物品始终在 (5,3)")
|
||||
lib.check(all(r.cursor_at(t) is None for t in sorted(r._state_by_tick)), "单击全程 cursor 为空")
|
||||
lib.check(not any(op == 0x19 for _, op, _ in r.c2s_ops()), "单击不发 0x19 拿起")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,7 @@
|
||||
# 术士存档:背包物品格 (5,3)。物品区单击只移光标不拿起;再点右邻空格也只是移光标。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.0 down 0 1478,1003
|
||||
2.1 up 0
|
||||
3.0 down 0 1563,1003
|
||||
3.1 up 0
|
||||
@@ -0,0 +1,184 @@
|
||||
"""触屏全链用例断言公共库。
|
||||
|
||||
面板开关按 uimsg.jsonl 每行的 ``tick``(宿主 DM_UIMSG 在局内写服务端当前拍号)对齐;
|
||||
局外(无 tick)的消息归入此前最近的拍号,首个拍号之前归入拍 0。
|
||||
Shared assertion library for touch full-chain cases.
|
||||
Panel open/close is aligned by the ``tick`` of each line in uimsg.jsonl (in-run, the host's DM_UIMSG writes the server's current tick number);
|
||||
out-of-run messages (no tick) are attributed to the most recent preceding tick number, and those before the first tick number to tick 0.
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class AssertFail(AssertionError):
|
||||
pass
|
||||
|
||||
|
||||
_FAILURES = []
|
||||
_CHECKS = 0
|
||||
_TICK_RE = re.compile(r"^(?:DM:Tick:)?(\d+)(?:#)?$")
|
||||
|
||||
|
||||
def check(cond, msg):
|
||||
global _CHECKS
|
||||
_CHECKS += 1
|
||||
if not cond:
|
||||
_FAILURES.append(str(msg))
|
||||
return bool(cond)
|
||||
|
||||
|
||||
def _read_jsonl(path):
|
||||
try:
|
||||
with path.open(encoding="utf-8") as stream:
|
||||
return [json.loads(line) for line in stream if line.strip()]
|
||||
except (OSError, ValueError) as exc:
|
||||
raise AssertFail(f"无法读取 {path}: {exc}") from exc
|
||||
|
||||
|
||||
def _required(directory, name):
|
||||
path = directory / name
|
||||
if not path.is_file():
|
||||
raise AssertFail(f"缺少必需文件:{path}")
|
||||
return path
|
||||
|
||||
|
||||
def _tick_from_message(row):
|
||||
if isinstance(row.get("tick"), int):
|
||||
return row["tick"]
|
||||
if row.get("cat") == "DM" and row.get("act") == "Tick":
|
||||
match = _TICK_RE.match(str(row.get("arg", "")))
|
||||
if match:
|
||||
return int(match.group(1))
|
||||
if row.get("act") == "DM:Tick":
|
||||
match = _TICK_RE.match(str(row.get("arg", "")))
|
||||
if match:
|
||||
return int(match.group(1))
|
||||
return None
|
||||
|
||||
|
||||
class Result:
|
||||
def __init__(self, directory, c2s, ticks, uimsg, state):
|
||||
self.directory = directory
|
||||
self._c2s = c2s
|
||||
self._ticks = ticks
|
||||
self._uimsg = uimsg
|
||||
self._state = state
|
||||
self._state_by_tick = {}
|
||||
for row in state:
|
||||
tick = row.get("tick")
|
||||
if isinstance(tick, int):
|
||||
self._state_by_tick[tick] = row
|
||||
self._panel_events = self._build_panel_events(uimsg)
|
||||
|
||||
@staticmethod
|
||||
def _build_panel_events(rows):
|
||||
current_tick = 0
|
||||
events = []
|
||||
for row in rows:
|
||||
if isinstance(row.get("tick"), int): # 宿主 DM_UIMSG 局内每行带服务端拍号 | In-run, each line of the host's DM_UIMSG carries the server tick number
|
||||
current_tick = row["tick"]
|
||||
else:
|
||||
marker_tick = _tick_from_message(row)
|
||||
if marker_tick is not None:
|
||||
current_tick = marker_tick
|
||||
continue
|
||||
action = row.get("act")
|
||||
panel = row.get("arg")
|
||||
if not panel or action not in {
|
||||
"OpenPanel", "OpenExclusivePanel", "UnloadPanel", "ClosePanel"
|
||||
}:
|
||||
continue
|
||||
events.append((current_tick, action, panel))
|
||||
return events
|
||||
|
||||
def _state_at(self, tick):
|
||||
rows = [item for item in self._state_by_tick if item <= tick]
|
||||
if not rows:
|
||||
return None
|
||||
return self._state_by_tick[max(rows)]
|
||||
|
||||
def items_at(self, tick):
|
||||
row = self._state_at(tick)
|
||||
if row is None:
|
||||
return {}
|
||||
return {item["id"]: dict(item) for item in row.get("items", [])}
|
||||
|
||||
def cursor_at(self, tick):
|
||||
row = self._state_at(tick)
|
||||
return None if row is None else row.get("cursor")
|
||||
|
||||
def players_at(self, tick):
|
||||
row = self._state_at(tick)
|
||||
return None if row is None else row.get("players")
|
||||
|
||||
def panels_at(self, tick):
|
||||
panels = set()
|
||||
for event_tick, action, panel in self._panel_events:
|
||||
if event_tick > tick:
|
||||
break
|
||||
if action == "OpenExclusivePanel":
|
||||
panels.clear()
|
||||
panels.add(panel)
|
||||
elif action == "OpenPanel":
|
||||
panels.add(panel)
|
||||
else:
|
||||
panels.discard(panel)
|
||||
return panels
|
||||
|
||||
def c2s_ops(self, t0=None, t1=None):
|
||||
result = []
|
||||
for row in self._c2s:
|
||||
if row.get("q") == "sys":
|
||||
continue
|
||||
tick = row.get("tick")
|
||||
if not isinstance(tick, int) or (t0 is not None and tick < t0) or (
|
||||
t1 is not None and tick > t1
|
||||
):
|
||||
continue
|
||||
packet = str(row.get("pkt", ""))
|
||||
if len(packet) < 2:
|
||||
raise AssertFail(f"命令包缺少 opcode:tick={tick} pkt={packet!r}")
|
||||
try:
|
||||
opcode = int(packet[:2], 16)
|
||||
except ValueError as exc:
|
||||
raise AssertFail(f"命令包不是十六进制:tick={tick} pkt={packet!r}") from exc
|
||||
result.append((tick, opcode, packet))
|
||||
return result
|
||||
|
||||
def state_rows(self):
|
||||
return list(self._state)
|
||||
|
||||
def tick_units(self):
|
||||
return [row["u"] for row in self._ticks if isinstance(row.get("u"), dict)]
|
||||
|
||||
|
||||
def load(directory):
|
||||
directory = Path(directory)
|
||||
paths = {name: _required(directory, name) for name in (
|
||||
"c2s.jsonl", "ticks.jsonl", "uimsg.jsonl", "state.jsonl"
|
||||
)}
|
||||
return Result(
|
||||
directory,
|
||||
_read_jsonl(paths["c2s.jsonl"]),
|
||||
_read_jsonl(paths["ticks.jsonl"]),
|
||||
_read_jsonl(paths["uimsg.jsonl"]),
|
||||
_read_jsonl(paths["state.jsonl"]),
|
||||
)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
del argv
|
||||
if _FAILURES:
|
||||
print(f"红 {len(_FAILURES)} 条")
|
||||
for failure in _FAILURES:
|
||||
print(f"- {failure}")
|
||||
return 1
|
||||
print(f"绿 {_CHECKS} 条")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
run = Path(sys.argv[1])
|
||||
|
||||
def fail(message):
|
||||
print(f"断言失败:{message}", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
c2s = [json.loads(line) for line in (run / "c2s.jsonl").open() if line.strip()]
|
||||
if not any(row.get("q") != "sys" and row.get("pkt", "").startswith("42") for row in c2s):
|
||||
fail("没有移动包")
|
||||
|
||||
xs = []
|
||||
for line in (run / "ticks.jsonl").open():
|
||||
row = json.loads(line)
|
||||
unit = row.get("u")
|
||||
if unit and unit.get("type") == 0 and unit.get("id") == 1:
|
||||
xs.append((row["t"], unit["x"]))
|
||||
if len(xs) < 2 or xs[-1][1] <= xs[0][1]:
|
||||
fail("x 没增大")
|
||||
print(f"触屏移动断言通过:移动包存在,x {xs[0][1]}→{xs[-1][1]};DM_TICKS 射程={len(xs)} 条单位收样")
|
||||
@@ -0,0 +1,3 @@
|
||||
0 down 0 90,1220
|
||||
3.1 move 0 150,1220
|
||||
5.1 up 0
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
r = lib.load(sys.argv[1])
|
||||
rows = [(t, op) for t, op, _ in r.c2s_ops()]
|
||||
ops = [op for _, op in rows]
|
||||
# 点到目标(NPC / 物件 / 物品,dm_world.c 带约 7 毫米余量)会走过去交互,那是允许的:带单位的包 0x02 / 0x04 / 0x13 / 0x16 / 0x2f / 0x40 / 0x41。
|
||||
# 不许的是「没有目标的点地移动」:0x01 / 0x03 前后 40 拍内必须有带单位的包,否则就是点空地走开了。
|
||||
# Tapping a target (NPC / object / item; dm_world.c has a margin of about 7 mm) walks over and interacts, which is allowed: packets with a unit 0x02 / 0x04 / 0x13 / 0x16 / 0x2f / 0x40 / 0x41.
|
||||
# What is not allowed is "tap-ground movement without a target": within 40 ticks before or after 0x01 / 0x03 there must be a packet with a unit, otherwise it was a tap on empty ground that walked away.
|
||||
TARGET = {0x02, 0x04, 0x13, 0x16, 0x2f, 0x40, 0x41}
|
||||
stray = [(t, op) for t, op in rows if op in (0x01, 0x03) and not any(o in TARGET and abs(t2 - t) <= 40 for t2, o in rows)]
|
||||
lib.check(not stray, "没有无目标的点地移动包(0x01 / 0x03 都伴随带单位的交互包):%s" % stray[:3])
|
||||
lib.check(0x42 not in ops, "没有摇杆移动包(0x42)")
|
||||
ev = r._panel_events
|
||||
opened = [t for t, a, p in ev if a == "OpenPanel" and p == "PlayerInventoryExpansionLayout"]
|
||||
closed = [t for t, a, p in ev if a == "ClosePanel" and p == "PlayerInventoryExpansionLayout" and opened and t > opened[0]]
|
||||
lib.check(bool(opened), "功能键开物品栏")
|
||||
lib.check(bool(closed), "点面板外后物品栏关闭")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,68 @@
|
||||
# 除摇杆外任何触点不许触发移动。局内不碰摇杆区(左 43% 且上 25% 以下)点 30 下:空地、技能钮之间、屏幕上沿;
|
||||
# 再开物品栏点面板外 2 下(= 关面板,不走路)。判据:没有 0x42(摇杆移动);0x01 / 0x03 只许伴随「点到目标走过去交互」出现(点世界目标 = 交互)。
|
||||
# 进局落在小站上(dm_townwp.c):原来落在小站选择框里的 8 下右移 600(仍是空地),否则点开小站面板、后面的点按在面板里选了目的地
|
||||
# 进局落在小站旁 10 格(小站在人右下方):落进小站选择框的 8 下上移 450(仍是空地),理由同上
|
||||
1.00 down 0 1963,348
|
||||
1.08 up 0
|
||||
1.25 down 0 2108,138
|
||||
1.33 up 0
|
||||
1.50 down 0 1448,1137
|
||||
1.58 up 0
|
||||
1.75 down 0 2092,338
|
||||
1.83 up 0
|
||||
2.00 down 0 2493,158
|
||||
2.08 up 0
|
||||
2.25 down 0 2339,479
|
||||
2.33 up 0
|
||||
2.50 down 0 1376,216
|
||||
2.58 up 0
|
||||
2.75 down 0 2188,446
|
||||
2.83 up 0
|
||||
3.00 down 0 2043,532
|
||||
3.08 up 0
|
||||
3.25 down 0 2085,459
|
||||
3.33 up 0
|
||||
3.50 down 0 2021,293
|
||||
3.58 up 0
|
||||
3.75 down 0 1757,166
|
||||
3.83 up 0
|
||||
4.00 down 0 2481,852
|
||||
4.08 up 0
|
||||
4.25 down 0 2001,492
|
||||
4.33 up 0
|
||||
4.50 down 0 1995,312
|
||||
4.58 up 0
|
||||
4.75 down 0 1893,448
|
||||
4.83 up 0
|
||||
5.00 down 0 1595,1147
|
||||
5.08 up 0
|
||||
5.25 down 0 2141,221
|
||||
5.33 up 0
|
||||
5.50 down 0 2447,410
|
||||
5.58 up 0
|
||||
5.75 down 0 2111,424
|
||||
5.83 up 0
|
||||
6.00 down 0 2062,239
|
||||
6.08 up 0
|
||||
6.25 down 0 2421,168
|
||||
6.33 up 0
|
||||
6.50 down 0 2455,162
|
||||
6.58 up 0
|
||||
6.75 down 0 2567,461
|
||||
6.83 up 0
|
||||
7.00 down 0 2316,1128
|
||||
7.08 up 0
|
||||
7.25 down 0 2175,233
|
||||
7.33 up 0
|
||||
7.50 down 0 2253,518
|
||||
7.58 up 0
|
||||
7.75 down 0 2040,203
|
||||
7.83 up 0
|
||||
8.00 down 0 1808,408
|
||||
8.08 up 0
|
||||
8.25 down 0 2731,642
|
||||
8.33 up 0
|
||||
9.00 down 0 1690,1241
|
||||
9.10 up 0
|
||||
10.50 down 0 2840,600
|
||||
10.60 up 0
|
||||
@@ -0,0 +1,15 @@
|
||||
import os, json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
|
||||
# 主技能 = 原版施放包:对地点 0x05、对单位 0x06(真机 e2e/s6:05 ×16、06 ×6,有怪在射程内才出 06)。
|
||||
# 只看前缀回放结束之后(前缀里的包是回放注入的,不算触屏产生);末拍取本用例 prefix 文件声明的前缀
|
||||
# Main skill = the original game's cast packets: 0x05 on a location, 0x06 on a unit (real device e2e/s6: 05 ×16, 06 ×6; 06 only appears when a monster is in range).
|
||||
# Only look after the prefix replay ends (packets in the prefix are injected by the replay and do not count as touch-generated); the end tick is taken from the prefix declared in this case's prefix file
|
||||
prefix = Path(os.environ["DM_TOUCH_PREFIX"]) # touchchain.sh 已把 prefix 文件里相对工作区根的路径拼成绝对路径 | touchchain.sh has already joined the workspace-root-relative path from the prefix file into an absolute path
|
||||
last = max(json.loads(l)["tick"] for l in open(prefix / "c2s.jsonl") if l.strip())
|
||||
r = lib.load(sys.argv[1])
|
||||
lib.check(any(op in (0x05, 0x06) for _, op, _ in r.c2s_ops(t0=last + 1)), f"前缀末拍 {last} 之后没有主技能施放包 0x05 / 0x06")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1 @@
|
||||
run/verify/dm/run_sta_contract_1002_090004/wild_prefix_original_warlock
|
||||
@@ -0,0 +1,3 @@
|
||||
# 起局(前缀回放结束且读取画面已撤)后 1 s 再按:撤屏当拍按下并一直按住的 A 不算一次按下(实测 0 s 不施放、1 s / 3 s 施放)
|
||||
1.0 down 0 2812,1238
|
||||
2.5 up 0
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]))
|
||||
import lib
|
||||
r = lib.load(sys.argv[1])
|
||||
opens = [(t, p) for t, a, p in r._panel_events if a in ("OpenPanel", "OpenExclusivePanel")]
|
||||
inv = [t for t, p in opens if p == "PlayerInventoryExpansionLayout"]
|
||||
skill = [t for t, p in opens if p == "SkillsTreePanel"]
|
||||
quest = [t for t, p in opens if p == "QuestLogPanelExpansion"]
|
||||
lib.check(bool(inv), "功能键开物品栏")
|
||||
lib.check(bool(skill) and bool(inv) and skill[0] > inv[0], "点「技能树」页签后技能树打开")
|
||||
lib.check(bool(quest) and bool(skill) and quest[-1] > skill[0], "再点「任务日志」页签后任务日志打开")
|
||||
lib.check(not any(op == 0x19 for _, op, _ in r.c2s_ops()), "全程不拿起物品")
|
||||
sys.exit(lib.main())
|
||||
@@ -0,0 +1,7 @@
|
||||
# 点页签切页:鼠标左键点不动页签,宿主按够次数的 L / R。开背包(物品栏页)→ 点「技能树」页签(心点 1904,59)→ 点「任务日志」页签(心点 490,59)。
|
||||
1.0 down 0 1690,1241
|
||||
1.1 up 0
|
||||
2.5 down 0 1904,59
|
||||
2.6 up 0
|
||||
4.5 down 0 490,59
|
||||
4.6 up 0
|
||||
@@ -0,0 +1,58 @@
|
||||
import json
|
||||
import contextlib
|
||||
import io
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent))
|
||||
|
||||
from lib import AssertFail, check, load, main
|
||||
|
||||
|
||||
def write_jsonl(directory, name, rows):
|
||||
(directory / name).write_text(
|
||||
"".join(json.dumps(row, ensure_ascii=False) + "\n" for row in rows),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
FIXTURE_DIR = pathlib.Path(__file__).parent / "tests" / "fixture"
|
||||
|
||||
|
||||
class TestTouchcaseLib(unittest.TestCase):
|
||||
def test_all_interfaces(self):
|
||||
with tempfile.TemporaryDirectory() as path:
|
||||
directory = pathlib.Path(path)
|
||||
shutil.copytree(FIXTURE_DIR, directory, dirs_exist_ok=True)
|
||||
result = load(directory)
|
||||
self.assertEqual(result.items_at(2), {8: {"id": 8, "cls": 2}})
|
||||
self.assertIsNone(result.cursor_at(3))
|
||||
self.assertEqual(result.players_at(3), 2)
|
||||
self.assertEqual(result.panels_at(3), {"Inventory"})
|
||||
self.assertEqual(result.panels_at(4), set())
|
||||
self.assertEqual(result.panels_at(5), {"Inventory"})
|
||||
self.assertEqual(result.c2s_ops(), [(2, 0x19, "1900"), (5, 0x18, "18ff")])
|
||||
self.assertEqual(result.c2s_ops(3, 5), [(5, 0x18, "18ff")])
|
||||
|
||||
def test_missing_state_is_red(self):
|
||||
with tempfile.TemporaryDirectory() as path:
|
||||
directory = pathlib.Path(path)
|
||||
shutil.copytree(FIXTURE_DIR, directory, dirs_exist_ok=True)
|
||||
(directory / "state.jsonl").unlink()
|
||||
with self.assertRaises(AssertFail):
|
||||
load(directory)
|
||||
|
||||
def test_check_records_failures_and_main_exits_red(self):
|
||||
check(False, "反例失败")
|
||||
output = io.StringIO()
|
||||
with contextlib.redirect_stdout(output):
|
||||
result = main([])
|
||||
self.assertEqual(result, 1)
|
||||
self.assertIn("红", output.getvalue())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,3 @@
|
||||
{"tick":2,"unit":7,"len":2,"pkt":"1900"}
|
||||
{"tick":2,"q":"sys","unit":null,"len":2,"pkt":"6f00"}
|
||||
{"tick":5,"unit":7,"len":2,"pkt":"18ff"}
|
||||
@@ -0,0 +1,3 @@
|
||||
{"tick":2,"items":[{"id":7,"cls":1}],"cursor":7,"players":1}
|
||||
{"tick":2,"items":[{"id":8,"cls":2}],"cursor":null,"players":2}
|
||||
{"tick":5,"items":[],"cursor":8,"players":null}
|
||||
@@ -0,0 +1 @@
|
||||
{"tick":0,"n":[],"h":[],"bad":0}
|
||||
@@ -0,0 +1,6 @@
|
||||
{"seq":0,"cat":"DM","act":"Tick","arg":"3#"}
|
||||
{"seq":1,"cat":"PanelManager","act":"OpenPanel","arg":"Inventory"}
|
||||
{"seq":2,"cat":"DM","act":"Tick","arg":"4#"}
|
||||
{"seq":3,"cat":"PanelManager","act":"UnloadPanel","arg":"Inventory"}
|
||||
{"seq":4,"cat":"DM","act":"Tick","arg":"5#"}
|
||||
{"seq":5,"cat":"PanelManager","act":"OpenPanel","arg":"Inventory"}
|
||||
Reference in New Issue
Block a user