Skip to content

Commit 9715e8d

Browse files
committed
Merge branch 'develop'
2 parents 2c0a653 + 91c3174 commit 9715e8d

File tree

6 files changed

+626
-179
lines changed

6 files changed

+626
-179
lines changed

locales/en/apgames.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,20 @@
282282
},
283283
"variants": {
284284
"abande": {
285+
"#board": {
286+
"description": "7x7 square board"
287+
},
285288
"hex": {
286289
"description": "A 37-space hexagonal board.",
287290
"name": "Board: Hexagonal"
288291
},
289292
"snub": {
290293
"description": "A hybrid orthogonal/hexagonal board shape with unique connection characteristics.",
291294
"name": "Board: Snub Square"
295+
},
296+
"libre": {
297+
"name": "Abande Libre",
298+
"description": "No board. Pieces are instead placed next to each other to form a hexagonal grid as you play."
292299
}
293300
},
294301
"accasta": {
@@ -3394,6 +3401,7 @@
33943401
"MOVE2EMPTY": "You cannot move to empty spaces.",
33953402
"PARTIAL": "It's possible you're trying to move a stack. Provide the destination.",
33963403
"TOOEARLY": "You cannot move until the first player has placed two pieces.",
3404+
"TOOEARLY_libre": "You cannot move until four stones have been placed on the board.",
33973405
"TOOFAR": "You can only move to an adjacent cell. {{to}} is not adjacent to {{from}}.",
33983406
"TOOHIGH": "Moving from {{from}} to {{to}} would result in a stack taller than three pieces high.",
33993407
"TRIPLESTACK": "You cannot move triple stacks."

src/common/modular/board.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,16 @@ export class ModularBoard {
265265
}
266266
return blocked;
267267
}
268+
269+
public neighbours(hex: ModularHex): ModularHex[] {
270+
const g = this.grid;
271+
const ns: ModularHex[] = [];
272+
for (const dir of hex.directions) {
273+
const n = g.neighborOf(hex, dir, {allowOutside: true});
274+
if (this.getHexAtAxial(n.q, n.r) !== undefined) {
275+
ns.push(n);
276+
}
277+
}
278+
return ns;
279+
}
268280
}

src/common/modular/hex.test.ts

Whitespace-only changes.

src/common/modular/hex.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { defineHex, Orientation, Hex, type HexOffset } from "honeycomb-grid";
1+
import { defineHex, Direction, Orientation, Hex, type HexOffset } from "honeycomb-grid";
22

33
export type HexArgs = {q: number; r: number};
44

55
export interface ModularHex extends Hex {
66
uid: string;
77
col: number;
88
row: number;
9+
directions: Direction[];
910
dupe(): ModularHex;
1011
}
1112

@@ -29,6 +30,14 @@ export const createModularHex = (orientation: Orientation = Orientation.FLAT, of
2930
return this.r + (this.q + offset * (this.q & 1)) / 2;
3031
}
3132

33+
public get directions(): Direction[] {
34+
if (this.orientation === Orientation.POINTY) {
35+
return [Direction.NE, Direction.E, Direction.SE, Direction.SW, Direction.W, Direction.NW];
36+
} else {
37+
return [Direction.N, Direction.NE, Direction.SE, Direction.S, Direction.SW, Direction.NW];
38+
}
39+
}
40+
3241
static create(args: HexArgs): ModularHex {
3342
return new ModularHexImpl({q: args.q, r: args.r});
3443
}

0 commit comments

Comments
 (0)