Skip to content

Commit 481a9e5

Browse files
committed
Byte: Add adjacency check to validator
1 parent dcfdb7c commit 481a9e5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

locales/en/apgames.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,6 +3296,7 @@
32963296
"NORMALISE": "The move needs to be normalised. Try '{{normalised}}'."
32973297
},
32983298
"byte": {
3299+
"ADJ_ONLY": "Stacks may only move to adjacent cells.",
32993300
"DIAG_ONLY": "Stacks may only move diagonally.",
33003301
"INITIAL_INSTRUCTIONS": "Select a stack to move. If merging stacks, select the bottom checker you wish to move.",
33013302
"INVALID_INDEX": "There is no checker at position {{index}} in the stack at {{where}}.",

src/games/byte.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@ export class ByteGame extends GameBase {
377377
result.message = i18next.t("apgames:validation._general.SAME_FROM_TO");
378378
return result;
379379
}
380+
// must be adjacent
381+
if (!graph.neighbours(from).includes(to)) {
382+
result.valid = false;
383+
result.message = i18next.t("apgames:validation.byte.ADJ_ONLY");
384+
return result;
385+
}
380386
// can only move diagonally
381387
const [tox, toy] = graph.algebraic2coords(to);
382388
if (tox % 2 === toy % 2) {

0 commit comments

Comments
 (0)