Skip to content

Commit 2b24031

Browse files
committed
Morphos: Fix duomorph first-move bug again and fix tiebreaker
1 parent 8ca7ece commit 2b24031

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/games/morphos.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,16 @@ export class MorphosGame extends GameBase {
407407
return false;
408408
}
409409

410+
public get numWeak(): number {
411+
let num = 0;
412+
for (const cell of [...this.board.keys()]) {
413+
if (this.isWeak(cell)) {
414+
num++;
415+
}
416+
}
417+
return num;
418+
}
419+
410420
public getButtons(): ICustomButton[] {
411421
if (this.randomCap() === null && this.empties.length === 0) return [{ label: "pass", move: "pass" }];
412422
return [];
@@ -530,7 +540,7 @@ export class MorphosGame extends GameBase {
530540
return result;
531541
}
532542
// in double placement, the stones must be orthogonally adjacent
533-
if (this.variants.includes("double") && this.stack[0]._version !== "20250325" && this.stack.length > 1 && parts.length === 2) {
543+
if (this.variants.includes("double") && this.stack[0]._version !== "20250325" && parts.length === 2) {
534544
const neighbours = g.neighbours(parts[0]);
535545
if (!neighbours.includes(parts[1])) {
536546
result.valid = false;
@@ -603,7 +613,7 @@ export class MorphosGame extends GameBase {
603613
}
604614
}
605615
}
606-
if ( (parts.length === 1 && (m.startsWith("x") || m === "pass" || adjEmpties.length === 0 || this.stack.length === 1)) || (parts.length === 2)) {
616+
if ( (parts.length === 1 && (m.startsWith("x") || m === "pass" || adjEmpties.length === 0)) || (parts.length === 2)) {
607617
complete = 1;
608618
message = i18next.t("apgames:validation._general.VALID_MOVE");
609619
} else if (parts.length === 1 && adjEmpties.length > 0) {
@@ -728,7 +738,7 @@ export class MorphosGame extends GameBase {
728738
}
729739

730740
// tie breaker
731-
if (this.board.size === this.boardSize * this.boardSize && this.connPath === undefined) {
741+
if (this.board.size === this.boardSize * this.boardSize && this.connPath === undefined && this.numWeak === 0) {
732742
this.gameover = true;
733743
let vertAdj = false;
734744
for (let y = 0; y < this.boardSize - 1; y++) {

0 commit comments

Comments
 (0)