diff --git a/CHANGELOG.md b/CHANGELOG.md index 88ceb376..4050eb5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,7 +69,7 @@ Since the `1.0.0-beta` release, the version in `package.json` has stayed at `1.0 - Click on a piece and then its final destination to move it there - "Chains" work - Moves which are necessary to make your input legal are inferred - - When a triangle appears in the corner of a trap square, click it when it's hollow to try to not capture the piece you're moving there, click it when it's filled to try to capture the piece you're moving there + - The capture triangle stays in the upper-right corner of the trap square as the board rotates. Click a hollow triangle to try to spare the piece and a filled triangle to try to capture it. - Clicking on an empty square you can move a piece to without selecting a piece first (called a "target" click/move internally) moves a piece there if it can narrow your intention down to one possibility (see wiki for exact hierarchy) ### Fixed diff --git a/playground/playground.js b/playground/playground.js index 0e480195..45d0aca1 100644 --- a/playground/playground.js +++ b/playground/playground.js @@ -3208,7 +3208,7 @@ function readPlaygroundInputModeSelection() { return active; } -function restorePlaygroundInputModeSelection(groups, ungrouped, defs) { +function restorePlaygroundInputModeSelection(groups, defs) { let saved = readStoredPlaygroundInputModeUids(); if (!Array.isArray(saved) || saved.length === 0) { saved = APGames.sanitizeInputModeSelection(defs, []); @@ -3369,8 +3369,11 @@ function updatePlaygroundInputModeOptions(gameEngine) { const { groups, ungrouped } = partitionInputModes(rootModes); - const singleGroupOnly = groups.size === 1 && ungrouped.length === 0; - for (const [groupName, members] of groups) { + // Match the site picker: an entirely ungrouped list selects one input mode. + const flat = groups.size === 0; + const radioGroups = flat ? [["", ungrouped]] : groups; + const singleGroupOnly = flat || (groups.size === 1 && ungrouped.length === 0); + for (const [groupName, members] of radioGroups) { const radioName = singleGroupOnly ? "inputModeOption" : `inputModeOption_${groupName}`; for (const mode of members) { const value = inputModeOptionRadioValue(mode); @@ -3386,7 +3389,7 @@ function updatePlaygroundInputModeOptions(gameEngine) { } } - for (const mode of ungrouped) { + for (const mode of flat ? [] : ungrouped) { const checkbox = document.createElement("input"); checkbox.type = "checkbox"; checkbox.value = mode.uid; @@ -3396,7 +3399,7 @@ function updatePlaygroundInputModeOptions(gameEngine) { } container.appendChild(fieldset); - restorePlaygroundInputModeSelection(groups, ungrouped, defs); + restorePlaygroundInputModeSelection(groups, defs); writeStoredPlaygroundInputModeUids(readPlaygroundInputModeSelection()); container.style.display = "block"; } diff --git a/src/games/arimaa.ts b/src/games/arimaa.ts index 44af7a5e..78d549ed 100644 --- a/src/games/arimaa.ts +++ b/src/games/arimaa.ts @@ -227,8 +227,8 @@ export class ArimaaGame extends GameBase { }, ], inputModes: [ - {uid: "basic", group: "entry"}, - {uid: "advanced", group: "entry"}, + {uid: "basic"}, // The first mode is the fallback. + {uid: "advanced"}, ], categories: ["goal>breakthrough", "goal>cripple", "goal>immobilize", "mechanic>capture", "mechanic>move", "mechanic>coopt", "mechanic>random>setup", "board>shape>rect", "board>connect>rect", "components>chess"], flags: ["perspective", "no-moves", "custom-buttons", "random-start", "custom-colours"] @@ -1190,14 +1190,14 @@ export class ArimaaGame extends GameBase { viewBox: [0, 0, 100, 100], markup: '', }; - legend[ARIMAA_CAPTURE_CHOICE] = {def: "arimaa-trap-choice", scale: 1 / 0.85, paint: {fill: paint}}; + legend[ARIMAA_CAPTURE_CHOICE] = {def: "arimaa-trap-choice", orientation: "vertical", scale: 1 / 0.85, paint: {fill: paint}}; } if ([...choices.values()].includes(false)) { rep.glyphDefs["arimaa-trap-spare"] = { viewBox: [0, 0, 100, 100], markup: '', }; - legend[ARIMAA_SPARE_CHOICE] = {def: "arimaa-trap-spare", scale: 1 / 0.85, paint: {fill: paint}}; + legend[ARIMAA_SPARE_CHOICE] = {def: "arimaa-trap-spare", orientation: "vertical", scale: 1 / 0.85, paint: {fill: paint}}; } // This is a render-only extra layer. The actual game board, // saved moves and the mode-independent pieces stay unchanged. diff --git a/test/games/arimaa-input-modes.test.ts b/test/games/arimaa-input-modes.test.ts index ad0d97ae..21c42ea1 100644 --- a/test/games/arimaa-input-modes.test.ts +++ b/test/games/arimaa-input-modes.test.ts @@ -69,6 +69,7 @@ describe("Arimaa input modes", () => { it("defaults to Basic, with Advanced on request", () => { const g = position("Ed4,Ra1", "ra8,ee8"); + expect(g.inputModes()?.map(({uid}) => uid)).to.deep.equal(["basic", "advanced"]); expect(g.resolveActiveInputMode(undefined)).to.equal("basic"); expect(g.resolveActiveInputMode("advanced")).to.equal("advanced"); }); @@ -916,7 +917,7 @@ describe("Arimaa input modes", () => { const before = g.serialize(); const preview = g.clone().move("g2", {partial: true}); const advanced = preview.render({inputMode: "advanced"}); - expect(advanced.legend?.[ARIMAA_CAPTURE_CHOICE]).not.to.equal(undefined); + expect(advanced.legend?.[ARIMAA_CAPTURE_CHOICE]).to.include({orientation: "vertical"}); const layers = advanced.pieces as string[][][]; expect(layers).to.have.length(8); expect(layers[5][5]).to.deep.equal([ARIMAA_CAPTURE_CHOICE]); // f3 @@ -937,7 +938,7 @@ describe("Arimaa input modes", () => { it("is drawn as the other glyph where clicking it keeps the piece alive", () => { const g = position("Cg2,Rf1,Ra1", "ra8,ee8"); const rep = g.clone().move("g2", {partial: true}).render({inputMode: "advanced"}); - expect(rep.legend?.[ARIMAA_SPARE_CHOICE]).not.to.equal(undefined); + expect(rep.legend?.[ARIMAA_SPARE_CHOICE]).to.include({orientation: "vertical"}); expect(rep.legend?.[ARIMAA_CAPTURE_CHOICE]).to.equal(undefined); expect((rep.pieces as string[][][])[5][5]).to.deep.equal([ARIMAA_SPARE_CHOICE]); // f3 // either key is the triangle's click