Build menu: Shift+Q/E switch tabs, G no longer picks (middle mouse does)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 17:12:51 -04:00
co-authored by Claude Opus 5.5
parent cab9343b26
commit 7d8df2ef67
10 changed files with 72 additions and 22 deletions
+24
View File
@@ -208,6 +208,30 @@ with sync_playwright() as p:
ok = select('3', "piece().id === 'wall'")
ev('GAME.wallMat = RSTONE; hudDirty = true')
check('build tool starts on wall blocks', ok)
c0 = ev('GAME.buildCat != null ? GAME.buildCat : catOf(piece().id)')
pg.keyboard.press('Shift+E')
check('Shift+E switches build tabs and selects a piece in the tab', ev('GAME.buildCat') == (c0 + 1) % ev('BUILD_CATS.length') and ev('BUILD_CATS[GAME.buildCat][1].includes(piece().id)'))
pg.keyboard.press('Shift+Q')
check('Shift+Q returns to the tab and restores its wall piece', ev('GAME.buildCat') == c0 and ev("piece().id === 'wall'"))
ev('selectBuildCat(0)')
pg.keyboard.press('Shift+Q')
check('Shift+Q wraps from the first build tab to the last', ev('GAME.buildCat === BUILD_CATS.length - 1'))
pg.keyboard.press('Shift+E')
check('Shift+E wraps back to the first build tab', ev('GAME.buildCat === 0'))
p0 = ev('piece().id')
pg.keyboard.press('e')
check('plain E cycles pieces without switching tabs', ev('piece().id') != p0 and ev('GAME.buildCat') == 0)
pg.keyboard.press('q')
check('plain Q returns to the piece without switching tabs', ev('piece().id') == p0 and ev('GAME.buildCat') == 0)
pg.mouse.move(*cell_to_screen(bx + 6, gy + 8)); settle(100)
ev('window._pickN = 0; window._pickOrig = pickUnderCursor; pickUnderCursor = function () { _pickN++; }; 0') # 0: evaluate would call a returned function
pg.keyboard.press('g'); settle(60)
g_picks = ev('_pickN')
pg.mouse.click(*cell_to_screen(bx + 6, gy + 8), button='middle'); settle(60)
check('G no longer picks; middle mouse still does', g_picks == 0 and ev('_pickN') == 1, f"G {g_picks}, then {ev('_pickN')}")
ev('pickUnderCursor = _pickOrig')
check('G leaves the build piece unchanged over the world', ev('piece().id') == p0)
ev("GAME.pieceIdx = PIECE_BY_ID.wall.index; GAME.wallMat = RSTONE; hudDirty = true")
bbx, bby = ev('[Math.floor((bot.x + 2) / 4), Math.floor((bot.y + 2) / 4)]')
rb = ev('bag[RSTONE]'); nb0 = ev('blockP.reduce((a, v) => a + (v === BP_WALL), 0)')
drag(lambda: blk(bbx + 3, bby - 4), lambda: blk(bbx + 8, bby - 4))