保存强化版提升前的主版本工作区
This commit is contained in:
@@ -32,19 +32,19 @@ const tick=(ms=16)=>{now+=ms;const entry=frames.entries().next().value;if(!entry
|
||||
const tap=(x,y)=>{const e={changedTouches:[{identifier:1,clientX:x,clientY:y}],touches:[{identifier:1,clientX:x,clientY:y}]};handlers.TouchStart(e);handlers.TouchEnd(e);tick();};
|
||||
const button=label=>{const b=api.buttons().find(b=>b.label===label);if(!b||!b.enabled)throw Error('缺少按钮 '+label);tap(b.x+b.w/2,b.y+b.h/2);};
|
||||
const cell=id=>{const s=api.snapshot(),[x,y]=s.centers[id];tap(x+s.boardRect.x,y+s.boardRect.y);};
|
||||
const select=i=>{if(api.snapshot().screen!=='select')button('选关');let n=0;while(!api.buttons().some(b=>b.label===String(i+1)||b.label===`${i+1} ✓`)){button('下一页');if(++n>25)throw Error('分页失败');}button(api.buttons().some(b=>b.label===String(i+1))?String(i+1):`${i+1} ✓`);if(api.buttons().some(b=>b.label==='返回游戏'))button('返回游戏');};
|
||||
const select=i=>{if(api.buttons().some(b=>b.label==='返回游戏'))button('返回游戏');if(api.snapshot().screen!=='select')button('选关');let n=0;while(!api.buttons().some(b=>b.label===String(i+1)||b.label===`${i+1} ✓`)){button(api.snapshot().selection.chapter>Math.floor(i/10)+1?'上一页':'下一页');if(++n>25)throw Error('分页失败');}button(api.buttons().some(b=>b.label===String(i+1))?String(i+1):`${i+1} ✓`);if(api.buttons().some(b=>b.label==='返回游戏'))button('返回游戏');};
|
||||
const capture=()=>{const c=document.createElement('canvas');c.width=375;c.height=812;c.getContext('2d').drawImage(canvases[0],0,0);return c;};
|
||||
const samples=(route)=>{const s=api.snapshot(),ctx=canvases[0].getContext('2d');return route.map(id=>{const p=s.centers[id];return Array.from(ctx.getImageData(Math.round(p[0]-s.unit*.08),Math.round(p[1]+s.boardRect.y+s.unit*.18),5,5).data);});};
|
||||
let checked=0;const result=document.querySelector('#result');
|
||||
try{
|
||||
for(let i=0;i<levels.length;i++){
|
||||
select(i);const route=solve(levels[i])[0],n=Math.min(2,route.length-1);
|
||||
for(const id of route.slice(0,n))cell(id);
|
||||
for(const id of route.slice(0,n))cell(id);tick(1800);
|
||||
const before=samples(route.slice(0,n));const base=capture();
|
||||
button('重开');button('指路');for(const id of route.slice(0,n))cell(id);tick(300);
|
||||
button('重开');button('指路');for(const id of route.slice(0,n))cell(id);tick(1800);
|
||||
const after=samples(route.slice(0,n));
|
||||
if(JSON.stringify(before)!==JSON.stringify(after))throw Error('玩家填色像素变化:第 '+(i+1)+' 关');
|
||||
button('撤销');cell(route[n-1]);tick(300);
|
||||
if(JSON.stringify(before)!==JSON.stringify(after)){document.querySelector('#views').replaceChildren(base,capture());throw Error('玩家填色像素变化:第 '+(i+1)+' 关');}
|
||||
button('撤销');cell(route[n-1]);tick(1800);
|
||||
if(JSON.stringify(before)!==JSON.stringify(samples(route.slice(0,n))))throw Error('撤销后填色变化:'+(i+1));
|
||||
checked++;
|
||||
if(i%4===0){result.textContent=`正在检查 ${checked}/200 关…`;await new Promise(resolve=>requestAnimationFrame(resolve));}
|
||||
|
||||
Reference in New Issue
Block a user