Shared drag placement; drags snap one block to join a diagonal (t67 phases 3-4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 15:08:37 -04:00
co-authored by Claude Opus 5.5
parent c3f9387b24
commit 72efe85a1b
8 changed files with 97 additions and 20 deletions
+20
View File
@@ -167,4 +167,24 @@ for(const grade of [-1,1])for(const below of [false,true]) {
})()`);
check(`grade ${grade} belt low end accepts sand from ${below?'below':'same row'} and carries it up`,r[0]&&r[1],r);
}
// Snapping (t67 phase 4): a drag moves one block up or down only to make a seamless join
// involving a diagonal piece, and only when every block there is free.
const snap = (setup, code, v, cells) => { flatWorld(run, 96, 96, 92); return run(`(()=>{${setup};return joinSnap(${code},${v},${JSON.stringify(cells)});})()`); };
check('an uphill belt started beside a flat belt on the same level snaps up one to join seamlessly',
snap('placeBlock(BP_BELT,1,10,10,true)', 'BP_BELT_UP', 1, [[11,10],[12,9],[13,8]]) === -1);
check('the snapped uphill belt then joins the flat belt',
run('(()=>{placeBlocks(BP_BELT_UP,1,[[11,9],[12,8],[13,7]]);return endJoin(10,10,1)===(9*BW+11)*2+0||endJoin(11,9,0)>=0;})()'));
check('an uphill belt already one block up stays put',
snap('placeBlock(BP_BELT,1,10,10,true)', 'BP_BELT_UP', 1, [[11,9],[12,8]]) === 0);
check('no snap when a block above is taken; the same-row drop join stays',
snap('placeBlock(BP_BELT,1,10,10,true);placeBlock(BP_WALL,RSTONE,12,8,true)', 'BP_BELT_UP', 1, [[11,10],[12,9]]) === 0);
check('a flat belt beside another flat belt one row off never jumps',
snap('placeBlock(BP_BELT,1,10,10,true)', 'BP_BELT', 1, [[11,11],[12,11],[13,11]]) === 0);
check('a flat belt started level with a downhill belt low end snaps down one (t58)',
snap('placeBlock(BP_BELT_DOWN,1,10,10,true);placeBlock(BP_BELT_DOWN,1,11,11,true)', 'BP_BELT', 1, [[12,11],[13,11]]) === 1);
check('a downhill screw started one block right and one lower than a screw end snaps up to the same row',
snap('placeBlock(BP_SCREW,1,10,10,true)', 'BP_SCREW', 5, [[11,11],[12,12]]) === -1);
check('a screw that already joins stays put',
snap('placeBlock(BP_SCREW,1,10,10,true)', 'BP_SCREW', 5, [[11,10],[12,11]]) === 0);
check('pieces with no join ends never snap', snap('', 'BP_PIPE', 0, [[11,10]]) === 0);
done();