From 5c2b8a680c6b8c82f3d676f9372869811755f8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Neto?= <886455+jpneto@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:54:19 +0100 Subject: [PATCH] Updated move error-checking --- src/games/linage.ts | 8 ++++++++ src/games/narrows.ts | 15 +++++++++++++-- src/games/pippinzip.ts | 11 +++++++++++ src/games/pollux.ts | 6 ++++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/games/linage.ts b/src/games/linage.ts index 43d49522..babb9ef7 100644 --- a/src/games/linage.ts +++ b/src/games/linage.ts @@ -328,6 +328,14 @@ export class LinageGame extends GameBase { return result; } + try { + this.algebraic2coords(m); + } catch { + result.valid = false; + result.message = i18next.t("apgames:validation._general.INVALIDCELL", {cell: m}); + return result; + } + if ( this.board.has(m) ) { result.valid = false; result.message = i18next.t("apgames:validation.linage.OCCUPIED"); diff --git a/src/games/narrows.ts b/src/games/narrows.ts index 16e2aaa4..751c8ee3 100644 --- a/src/games/narrows.ts +++ b/src/games/narrows.ts @@ -25,8 +25,8 @@ export class NarrowsGame extends GameBase { name: "Narrows", uid: "narrows", playercounts: [2], - version: "20260521", - dateAdded: "2026-05-27", + version: "20260604", + dateAdded: "2026-06-04", // i18next.t("apgames:descriptions.narrows") description: "apgames:descriptions.narrows", notes: "apgames:notes.narrows", @@ -244,6 +244,17 @@ export class NarrowsGame extends GameBase { } const moves = m.split('-'); + + try { + for (const cell of moves) { + this.graph.algebraic2coords(cell); + } + } catch { + result.valid = false; + result.message = i18next.t("apgames:validation._general.INVALID_MOVE", {move: m}); + return result; + } + const allMoves = this.moves(); if (moves.length === 1) { diff --git a/src/games/pippinzip.ts b/src/games/pippinzip.ts index 1694667a..2fbe2db3 100644 --- a/src/games/pippinzip.ts +++ b/src/games/pippinzip.ts @@ -262,6 +262,17 @@ export class PippinzipGame extends GameBase { } const moves = m.split(','); + + try { + for (const cell of moves) { + PippinzipGame.algebraic2coords(cell, this.boardSize); + } + } catch { + result.valid = false; + result.message = i18next.t("apgames:validation._general.INVALID_MOVE", {move: m}); + return result; + } + for (const cell of moves) { if ( this.board.has(cell) ) { result.valid = false; diff --git a/src/games/pollux.ts b/src/games/pollux.ts index ad6025fa..42742e22 100644 --- a/src/games/pollux.ts +++ b/src/games/pollux.ts @@ -291,10 +291,12 @@ export class PolluxGame extends GameBase { const allMoves = this.moves(); try { - for (const cell of moves) { this.graph.algebraic2coords(cell); } + for (const cell of moves) { + this.graph.algebraic2coords(cell); + } } catch { result.valid = false; - result.message = i18next.t("apgames:validation._general.INVALIDMOVE", {m}); + result.message = i18next.t("apgames:validation._general.INVALID_MOVE", {move: m}); return result; }