feat(match): 同步比赛计时与装甲板扣血许可
- 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 页面、倒计时和随包中文字体。 未执行烧录、板上运行、跨电脑广播或硬件稳定性验证。
This commit is contained in:
581 files changed
+6596
-7683
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import {readFileSync} from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import {test} from 'node:test';
|
||||
import ts from 'typescript';
|
||||
const source=readFileSync(new URL('../src/lib/latency-marker.ts',import.meta.url),'utf8');
|
||||
const code=ts.transpileModule(source,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022}}).outputText;
|
||||
const exports={};new Function('exports',code)(exports);
|
||||
const {drawMarker,decodeMarker}=exports;
|
||||
function image(counter,w=320,h=240) {
|
||||
const pixels=new Uint8ClampedArray(w*h*4);
|
||||
const ctx={canvas:{width:w,height:h},fillStyle:'',fillRect(x,y,width,height){
|
||||
const c=this.fillStyle.startsWith('rgb(')?this.fillStyle.slice(4,-1).split(',').map(Number):
|
||||
this.fillStyle==='#fff'?[255,255,255]:this.fillStyle==='#000'?[0,0,0]:[60,60,60];
|
||||
for(let yy=Math.max(0,Math.ceil(y));yy<Math.min(h,y+height);yy++)
|
||||
for(let xx=Math.max(0,Math.ceil(x));xx<Math.min(w,x+width);xx++)pixels.set([...c,255],(yy*w+xx)*4);
|
||||
}};
|
||||
drawMarker(ctx,counter);return pixels;
|
||||
}
|
||||
test('screen IDs decode at Gray-code boundaries and across counter wrap',()=>{
|
||||
for(const id of [0,1,2,3,63,127,1023,2047,2048,4094,4095,4096]) {
|
||||
assert.equal(decodeMarker(image(id),320,240)?.counter,id&4095);
|
||||
}
|
||||
});
|
||||
test('camera rotation and reflection preserve the observed ID',()=>{
|
||||
const original=image(1371),rotated=new Uint8ClampedArray(original.length),flipped=new Uint8ClampedArray(original.length);
|
||||
for(let y=0;y<240;y++)for(let x=0;x<320;x++){
|
||||
rotated.set(original.subarray((y*320+x)*4,(y*320+x)*4+4),(x*240+239-y)*4);
|
||||
flipped.set(original.subarray((y*320+x)*4,(y*320+x)*4+4),(y*320+319-x)*4);
|
||||
}
|
||||
assert.equal(decodeMarker(rotated,240,320)?.counter,1371);
|
||||
assert.equal(decodeMarker(flipped,320,240)?.counter,1371);
|
||||
});
|
||||
test('missing fiducials and ambiguous rolling transitions do not invent latency samples',()=>{
|
||||
assert.equal(decodeMarker(new Uint8ClampedArray(320*240*4),320,240),null);
|
||||
const pixels=image(123);
|
||||
for(let y=90;y<152;y++)for(let x=44;x<276;x++)pixels.set([128,128,128,255],(y*320+x)*4);
|
||||
assert.equal(decodeMarker(pixels,320,240),null);
|
||||
});
|
||||
|
||||
test('washed screen primaries survive without mistaking a blue-tinted background',()=>{
|
||||
const pixels=image(1371);
|
||||
for(let i=0;i<pixels.length;i+=4){
|
||||
const r=pixels[i],g=pixels[i+1],b=pixels[i+2];
|
||||
if(r===32&&g===255&&b===32)pixels.set([190,255,208,255],i);
|
||||
else if(r===32&&g===96&&b===255)pixels.set([78,205,255,255],i);
|
||||
else if(r===255&&g===32&&b===255)pixels.set([255,112,255,255],i);
|
||||
else if(r===60&&g===60&&b===60)pixels.set([165,181,225,255],i);
|
||||
}
|
||||
assert.equal(decodeMarker(pixels,320,240)?.counter,1371);
|
||||
});
|
||||
Reference in new issue
Block a user