- feat(client): 增加裁判比赛计时、技术暂停与选手端局域网同步 - feat(armor): 红蓝共用通用固件,按客户端选队并显示网络连接状态 - feat(armor): 仅在对局进行中允许扣血,其他阶段保留受击闪烁 - feat(client): 将计时置于血条中间并增加开赛前五秒全屏动画 - fix(client): 修复连续血条、对手镜像和图传断连灰度遮罩 - fix(client): 统一界面中文字体并整理各页面文案 - fix(maintenance): 备份迁移装甲板分区,恢复 SDK 构建与固件打包 - refactor(repo): 按 armor、vt 和 client 整理工程与脚本,移除旧参考实现 - test: 补充线路、受击许可、回环 UDP、维护和 HUD 验证 - docs: 同步构建、协议、比赛控制和硬件验证边界 验证:前端构建与 19 项相关测试通过;核心 91 项单元测试与 2 项回环 UDP 集成测试通过;装甲板规则 25 项、线路 26 项、Tauri 51 项测试通过;独立探测器 5 项与目录回归 4 项通过。完成 C3 两组阈值实际编译、导出与 ZIP 校验,检查 900×600 / 1280×720 页面、倒计时和随包中文字体。 未执行烧录、板上运行、跨电脑广播或硬件稳定性验证。
32 lines
2.0 KiB
JavaScript
32 lines
2.0 KiB
JavaScript
import { readFileSync } from "node:fs";
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import ts from "typescript";
|
|
const exports = {};
|
|
new Function("exports", ts.transpileModule(readFileSync(new URL("../src/lib/match-time.ts", import.meta.url), "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
|
}).outputText)(exports);
|
|
const { matchTime, projectMatch } = exports;
|
|
const base = { phase: "running", remainingMs: 10_000, elapsedMs: 170_000, pauseElapsedMs: 0,
|
|
pauseRemainingMs: null, connected: true, freshForMs: 500 };
|
|
test("remaining time rounds up, elapsed time rounds down", () => {
|
|
assert.equal(matchTime(1), "00:01"); assert.equal(matchTime(999, true), "00:00");
|
|
assert.equal(matchTime(180_000), "03:00"); assert.equal(matchTime(-1), "00:00");
|
|
});
|
|
test("interpolation stops at the network lease boundary and backend outage freezes immediately", () => {
|
|
const v = projectMatch(base, 5000, true);
|
|
assert.equal(v.remainingMs, 9500); assert.equal(v.elapsedMs, 170_500); assert.equal(v.connected, false);
|
|
assert.equal(projectMatch(base, 5000, false).remainingMs, 10_000);
|
|
assert.equal(projectMatch({ ...base, connected: false }, 100, true).remainingMs, 10_000);
|
|
});
|
|
test("paused match freezes underlying clocks; player countdown expires without changing phase", () => {
|
|
const v = projectMatch({ ...base, phase: "paused", pauseRemainingMs: 200, pauseElapsedMs: 299_800 }, 500, true);
|
|
assert.equal(v.remainingMs, 10_000); assert.equal(v.elapsedMs, 170_000);
|
|
assert.equal(v.pauseRemainingMs, 0); assert.equal(v.phase, "paused"); assert.equal(v.pauseElapsedMs, 300_300);
|
|
assert.equal(projectMatch({ ...base, phase: "paused" }, 500, true).pauseRemainingMs, null);
|
|
});
|
|
test("the UI never starts a match or resumes a pause by interpolating", () => {
|
|
const v = projectMatch({ ...base, phase: "countdown", remainingMs: 100 }, 500, true);
|
|
assert.equal(v.remainingMs, 0); assert.equal(v.phase, "countdown"); assert.equal(v.elapsedMs, 170_000);
|
|
});
|