Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions locales/en/apgames.json
Original file line number Diff line number Diff line change
Expand Up @@ -4561,9 +4561,9 @@
"PARTIAL": "Select one of the highlighted cells to move the glider. If a bar has appeared at the edge of the board, you can click it to move the glider off the board."
},
"go": {
"INITIAL_SETUP": "Choose a number of points to add to the second player's score, and the next player will choose sides (0.5 will be added to prevent draws). This implementation uses Chinese area rules. Scores are based on the current area ownership. Players do need to capture all dead stones before ending the game with two consecutive passes.",
"INITIAL_SETUP": "Choose a number of points to add to the second player's score, and the next player will choose sides. This implementation uses Chinese area rules. Scores are based on the current area ownership. Players do need to capture all dead stones before ending the game with two consecutive passes.",
"INSTRUCTIONS": "Select an intersection to place a piece.",
"INVALID_KOMI": "You must choose an integer number of points to add to the second player's score.",
"INVALID_KOMI": "You must choose an number in increments of 0.5 (like 4 or 4.5) to add to the second player's score.",
"INVALID_PIE": "You cannot accept or reject a pie offer now.",
"INVALID_PLAYSECOND": "You cannot choose to play second from this board state.",
"KOMI_CHOICE": "You may either make the first move on the board and let your opponent keep the bonus points (an integer) or you may choose \"Play second\" and take the bonus points for yourself.",
Expand Down
14 changes: 8 additions & 6 deletions src/games/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ export class GoGame extends GameBase {
return result;
}

// player typed something in the move textbox, check if it is an integer
if (! /^-?\d+$/.test(m)) {
// player typed something in the move textbox,
// check if it is an integer or a number with 0.5 decimal part
if (! /^-?\d+(\.[05])?$/.test(m)) {
result.valid = false;
result.message = i18next.t("apgames:validation.go.INVALID_KOMI");
return result
Expand Down Expand Up @@ -359,6 +360,7 @@ export class GoGame extends GameBase {
result.valid = true;
result.complete = 1;
result.message = i18next.t("apgames:validation._general.VALID_MOVE");
result.canrender = true;
return result;
}

Expand Down Expand Up @@ -505,7 +507,7 @@ export class GoGame extends GameBase {
}
if (m.length === 0) { return this; }
this.results = [];

if (this.isKomiTurn()) {
// first move, get the Komi proposed value, and add komi to game state
this.komi = parseInt(m, 10);
Expand Down Expand Up @@ -570,7 +572,7 @@ export class GoGame extends GameBase {
if (this.gameover) {
this.scores = [this.getPlayerScore(1), this.getPlayerScore(2)];
// draws by score are impossible
this.winner = this.scores[0] > this.scores[1] ? [1] : [2];
this.winner = this.scores[0] > this.scores[1] ? [1] : [2];
this.results.push(
{type: "eog"},
{type: "winners", players: [...this.winner]}
Expand Down Expand Up @@ -687,9 +689,9 @@ export class GoGame extends GameBase {
.map(pair => pair[0]);
let komi = 0.0;
if (player === 1 && this.komi !== undefined && this.komi < 0)
komi = -this.komi + 0.5; // 0.5 is to prevent draws
komi = -this.komi;
if (player === 2 && this.komi !== undefined && this.komi > 0)
komi = this.komi + 0.5;
komi = this.komi;

const terr = this.getTerritories();
return terr.filter(t => t.owner === player).reduce((prev, curr) => prev + curr.cells.length, komi + playerPieces.length);
Expand Down
2 changes: 1 addition & 1 deletion src/games/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class ProductGame extends GameBase {
}
}

return moves;
return moves.sort((a,b) => a.localeCompare(b));
}

public randomMove(): string {
Expand Down
5 changes: 3 additions & 2 deletions src/games/stiletto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class StilettoGame extends InARowBase {
for (let col = 0; col < this.boardSize; col++) {
const cell = this.coords2algebraic(col, row);
if (this.board.has(cell)) { continue; }
moves.push(this.normaliseMove(cell));
moves.push(this.normaliseMove(cell));
}
}

Expand Down Expand Up @@ -269,7 +269,7 @@ export class StilettoGame extends InARowBase {
}
*/

return moves;
return moves.sort((a,b) => a.localeCompare(b));
}

public randomMove(): string {
Expand Down Expand Up @@ -429,6 +429,7 @@ export class StilettoGame extends InARowBase {

result.valid = true;
result.message = i18next.t("apgames:validation._general.VALID_MOVE");
result.canrender = true;
return result;
}

Expand Down