Skip to content

Commit 0e3cf62

Browse files
committed
Pigs2: Fix firing against the edge of the board
1 parent 8c6e091 commit 0e3cf62

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/games/pigs2.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -771,17 +771,19 @@ export class Pigs2Game extends GameBaseSimultaneous {
771771
});
772772
}
773773
} else if ( (result.type === "fire") && (result.which === "F") ) {
774-
const [fx, fy] = Pigs2Game.algebraic2coords(result.from!);
775-
const [tx, ty] = Pigs2Game.algebraic2coords(result.to!);
776-
rep.annotations.push({
777-
type: "move",
778-
arrow: true,
779-
style: "dashed",
780-
targets: [
781-
{col: fx, row: fy},
782-
{col: tx, row: ty}
783-
]
784-
});
774+
if (result.to !== undefined) {
775+
const [fx, fy] = Pigs2Game.algebraic2coords(result.from!);
776+
const [tx, ty] = Pigs2Game.algebraic2coords(result.to);
777+
rep.annotations.push({
778+
type: "move",
779+
arrow: true,
780+
style: "dashed",
781+
targets: [
782+
{col: fx, row: fy},
783+
{col: tx, row: ty}
784+
]
785+
});
786+
}
785787
} else if (result.type === "damage") {
786788
const [x, y] = Pigs2Game.algebraic2coords(result.where as string);
787789
rep.annotations.push({

0 commit comments

Comments
 (0)