diff --git a/locales/en/apgames.json b/locales/en/apgames.json index a995f5bc..ccbc8375 100644 --- a/locales/en/apgames.json +++ b/locales/en/apgames.json @@ -1346,11 +1346,11 @@ "name": "37x37 board" }, "#ruleset": { - "description": "Area counting; situational superko", + "description": "Area scoring; situational superko", "name": "AGA Rules" }, "positional": { - "description": "Area counting; positional superko", + "description": "Area scoring; positional superko", "name": "Positional Superko" } }, diff --git a/src/games/product.ts b/src/games/product.ts index 096577a1..375933e6 100644 --- a/src/games/product.ts +++ b/src/games/product.ts @@ -451,7 +451,7 @@ export class ProductGame extends GameBase { if (this.gameover) { // tied scores is a P2 win - this.winner = this.getPlayerScore(1) > this.getPlayerScore(2) ? [1] : [2]; + this.winner = this.getPlayerScore(1) >= this.getPlayerScore(2) ? [1] : [2]; this.results.push( {type: "eog"}, {type: "winners", players: [...this.winner]} diff --git a/src/games/spora.ts b/src/games/spora.ts index e5717b2d..e3f96279 100644 --- a/src/games/spora.ts +++ b/src/games/spora.ts @@ -416,6 +416,27 @@ export class SporaGame extends GameBase { return this.findDead(this.currplayer, cloned).length === 0; } + // this method is called at the end, when the last player makes a sequence of placements + // in this case, after placing some stones, some captures might become legal, + // so we need to try placing piece by piece, and evaluate their validity + private validSequence(cells: string[]): boolean { + const prevplayer = this.currplayer === 1 ? 2 : 1; + // we'll simulate the process in a cloned board + const cloned = this.cloneBoard(); + for (const cell of cells) { + // place the stack (herein, its size is irrelevant) + cloned.set(cell, [this.currplayer, 1]); + // compute all enemy captures + const dead = this.findDead(prevplayer, cloned); + dead.forEach(cell => cloned.delete(cell)); + // if there are still friendly captures, the placement is illegal + if (this.findDead(this.currplayer, cloned).length > 0) { + return false; + } + } + return true; + } + // What pieces are orthogonally adjacent to a given area? public getAdjacentPieces(area: string[], pieces: string[]): string[] { // convert area strings to numeric coordinates @@ -546,11 +567,12 @@ export class SporaGame extends GameBase { result.message = i18next.t("apgames:validation.spora.MAXIMUM_STACK"); return result; } - if (! this.validPlacement(cell) ) { - result.valid = false; - result.message = i18next.t("apgames:validation.spora.SELF_CAPTURE"); - return result; - } + } + // check if the sequence of placements are able to make legal captures + if (! this.validSequence(cells) ) { + result.valid = false; + result.message = i18next.t("apgames:validation.spora.SELF_CAPTURE"); + return result; } result.valid = true; result.complete = this.reserve[this.currplayer - 1] > cells.length ? -1 : 1; // end when all pieces are on board