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

+34
View File
@@ -0,0 +1,34 @@
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/reticle.ts", import.meta.url), "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
}).outputText)(exports);
const { aimPoint, computeLayout } = exports;
test("calibrated aim follows the same image point through all four mirror combinations", () => {
const geometry = computeLayout({ clientWidth: 800, clientHeight: 600 }, 640, 480, { zoom: 2, x: 40, y: -30 });
const crosshair = { offsetX: 0.1, offsetY: -0.2 };
for (const horizontal of [false, true]) {
for (const vertical of [false, true]) {
const aim = aimPoint(geometry, crosshair, horizontal, 800, 600, vertical);
assert.equal(aim.x, horizontal ? 200 : 600);
assert.equal(aim.y, vertical ? 570 : 30);
// 校准时向右下拖动 16/12 像素,镜像不改变屏幕上的移动方向。
const moved = aimPoint(geometry, {
offsetX: crosshair.offsetX + (horizontal ? -16 : 16) / geometry.drawWidth,
offsetY: crosshair.offsetY + (vertical ? -12 : 12) / geometry.drawHeight,
}, horizontal, 800, 600, vertical);
assert.ok(Math.abs(moved.x - aim.x - 16) < 1e-9);
assert.ok(Math.abs(moved.y - aim.y - 12) < 1e-9);
}
}
});
test("missing frames keep the aim centered regardless of mirror or offsets", () => {
const empty = computeLayout({ clientWidth: 800, clientHeight: 600 }, 0, 0, { zoom: 2, x: 40, y: -30 });
assert.deepEqual(aimPoint(empty, { offsetX: 0.2, offsetY: -0.1 }, true, 800, 600, true), { x: 400, y: 300 });
});