From ea45681e03f6845873d8c4358b437289322a2063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Neto?= Date: Fri, 29 May 2026 08:39:06 +0100 Subject: [PATCH] Fix move validation in HalmaClimbers There was the possibility of the player would just click on the first stone and not moving it --- locales/en/apgames.json | 1 + src/games/halmaclimbers.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/locales/en/apgames.json b/locales/en/apgames.json index 5b2b31b1..2fa3e837 100644 --- a/locales/en/apgames.json +++ b/locales/en/apgames.json @@ -5108,6 +5108,7 @@ "INITIAL_INSTRUCTIONS": "Select a friendly piece and use it to jump over another piece, or pass your turn.", "INSTRUCTIONS": "An action is either a backward movement to an adjacent empty cell or a sequence of short-jumps over pieces of either color. The sequence of jumps must start inside the player's home-base. Each player makes two actions or just passes their turn.", "NEXT_ACTION": "After moving the first piece, just click on the second stone to start moving or jumping.", + "INCOMPLETE_ACTION": "The first piece did not move; cannot start moving the second piece yet!", "NONEXISTENT": "Trying to interact with a friendly piece that doesn't exist at {{where}}!", "ILLEGAL_JUMP": "The sequence of jumps must start inside the player's home-base!", "TOO_MANY_ACTIONS": "This number of actions is not allowed; only one action is allowed at first, then two.", diff --git a/src/games/halmaclimbers.ts b/src/games/halmaclimbers.ts index 5b5d9b89..d4f9bd03 100644 --- a/src/games/halmaclimbers.ts +++ b/src/games/halmaclimbers.ts @@ -350,6 +350,13 @@ export class HalmaClimbersGame extends GameBase { return result; } + // player didn't move the first piece, and already started with the second + if ( actions.length === 2 && !actions[0].includes("-") ) { + result.valid = false; + result.message = i18next.t("apgames:validation.halmaclimbers.INCOMPLETE_ACTION"); + return result; + } + // need to move through all the moves, and check if they follow the rules // for that we need a copy of the board, to keep the effects of the previous actions const clone = new Map(this.board);