feat(match): 添加画面上下镜像、跳过准备和装甲板整局复位

This commit is contained in:
sloray committed 2026-10-31 09:27:26 +08:00
1 parent 235fb1c73b
commit 338efa5c2e
39 files changed
+1094 -54

No files matched your search

+35 -2
View File
@@ -19,12 +19,13 @@ function load(path, overrides) {
}
const format = { teamColor: team => team === 0 ? "red" : "blue", teamName: team => `队伍${team}`, idText: String, firmwareLabel: () => "测试固件" };
const icon = { Icon: () => null };
const healthModule = load("../src/components/HealthBar.tsx", { "../lib/format": format });
const videoModule = load("../src/components/VideoSurface.tsx", { "../lib/store": {}, "../lib/reticle": {} });
const videoModule = load("../src/components/VideoSurface.tsx", { "../lib/store": {}, "../lib/reticle": {}, "./Icon": icon });
let connected = true;
const matchTime = load("../src/lib/match-time.ts", {});
const matchModule = load("../src/components/MatchClock.tsx", {
"./Dialog": {}, "../lib/ipc": {},
"./Dialog": {}, "./Icon": icon, "../lib/ipc": {},
"../lib/store": { useAppStore: () => ({ connected }) },
"../lib/match-time": matchTime,
});
@@ -141,3 +142,35 @@ test("an armor outage alone does not gray the live video", () => {
value.armorBoards[0].online = false;
assert.doesNotMatch(renderTeam(value), /vsurface--signal-lost|vsurface__signal-mask/);
});
const renderControl = (phase, health = []) => renderToStaticMarkup(createElement(matchModule.RefereeMatchControl, {
snapshot: { ...snapshot(), config: { teamNames: ["红队", "蓝队"] }, matchClock: { ...snapshot().matchClock, phase }, health },
onError() {},
}));
test("skip preparation is available only while preparing and ready still requires confirmation", () => {
assert.match(renderControl("preparation"), /跳过准备倒计时/);
for (const phase of ["idle", "ready", "countdown", "running", "paused", "finished"]) {
assert.doesNotMatch(renderControl(phase), /跳过准备倒计时/);
}
assert.match(renderControl("ready"), /确认开赛/);
});
test("a verdict exposes one-click reset even before the clock finishes, while ongoing play cannot reset", () => {
assert.doesNotMatch(renderControl("running"), /重置到未开始/);
assert.match(renderControl("finished"), /重置到未开始/);
const verdict = renderControl("running", [{ outcome: "defeat" }, { outcome: "victory" }]);
assert.match(verdict, /重置到未开始/);
assert.doesNotMatch(verdict, /开始 3 分钟准备|结束本局/);
});
test("the operator feed reports horizontal and vertical mirroring independently", () => {
const value = snapshot();
value.mirrored = true;
assert.match(renderTeam(value), /左右镜像/);
assert.doesNotMatch(renderTeam(value), /上下镜像/);
value.mirrored = false;
value.mirroredVertical = true;
assert.match(renderTeam(value), /上下镜像/);
assert.doesNotMatch(renderTeam(value), /左右镜像/);
});