From a7ecf71aabc8f8f0d0d74f987e55c1aeb923d884 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Sat, 29 Jun 2024 06:38:09 -0600 Subject: [PATCH] Fix capture counting when analyzing a finished game Fixes https://github.com/online-go/online-go.com/issues/2735 --- src/engine/GobanEngine.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/engine/GobanEngine.ts b/src/engine/GobanEngine.ts index b07cfb5a..0e915def 100644 --- a/src/engine/GobanEngine.ts +++ b/src/engine/GobanEngine.ts @@ -1445,14 +1445,16 @@ export class GobanEngine extends BoardState { ret.white.prisoners = this.white_prisoners; ret.black.prisoners = this.black_prisoners; - for (let y = 0; y < this.height; ++y) { - for (let x = 0; x < this.width; ++x) { - if (this.removal[y][x]) { - if (this.board[y][x] === JGOFNumericPlayerColor.BLACK) { - ret.white.prisoners += 1; - } - if (this.board[y][x] === JGOFNumericPlayerColor.WHITE) { - ret.black.prisoners += 1; + if (this._cur_move === this.last_official_move) { + for (let y = 0; y < this.height; ++y) { + for (let x = 0; x < this.width; ++x) { + if (this.removal[y][x]) { + if (this.board[y][x] === JGOFNumericPlayerColor.BLACK) { + ret.white.prisoners += 1; + } + if (this.board[y][x] === JGOFNumericPlayerColor.WHITE) { + ret.black.prisoners += 1; + } } } }