Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions playground/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, []);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -3396,7 +3399,7 @@ function updatePlaygroundInputModeOptions(gameEngine) {
}

container.appendChild(fieldset);
restorePlaygroundInputModeSelection(groups, ungrouped, defs);
restorePlaygroundInputModeSelection(groups, defs);
writeStoredPlaygroundInputModeUids(readPlaygroundInputModeSelection());
container.style.display = "block";
}
Expand Down
8 changes: 4 additions & 4 deletions src/games/arimaa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -1190,14 +1190,14 @@ export class ArimaaGame extends GameBase {
viewBox: [0, 0, 100, 100],
markup: '<polygon points="50,0 100,0 100,50" fill="#ffffff" data-slot-fill="fill"/>',
};
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: '<polygon points="62,5 95,5 95,38" fill="#ffffff" fill-opacity="0" stroke="#ffffff" stroke-width="10" stroke-linejoin="round" data-slot-stroke="fill"/>',
};
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.
Expand Down
5 changes: 3 additions & 2 deletions test/games/arimaa-input-modes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading