From 219c2715b8a933b23034d3607a1f5954fea4c094 Mon Sep 17 00:00:00 2001 From: Michael Conard Date: Mon, 27 May 2024 15:00:40 +0000 Subject: [PATCH 1/2] fix bug with non-lion double movers capturing lion for counterstrike rules --- src/variant/position.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/variant/position.ts b/src/variant/position.ts index 3b5b73d..6d80ffe 100644 --- a/src/variant/position.ts +++ b/src/variant/position.ts @@ -298,13 +298,19 @@ export abstract class Position { piece.role = promote(this.rules)(role) || role; const capture = this.board.set(md.to, piece), - secondCapture = defined(md.midStep) ? this.board.take(md.midStep) : undefined; + midCapture = defined(md.midStep) ? this.board.take(md.midStep) : undefined; + + // process midCapture (if exists) before final destination capture + if (defined(midCapture)) { + if (!lionRoles.includes(role) && midCapture.color === this.turn && lionRoles.includes(midCapture.role)) + this.lastLionCapture = md.midStep; + this.storeCapture(midCapture); + } if (capture) { if (!lionRoles.includes(role) && capture.color === this.turn && lionRoles.includes(capture.role)) this.lastLionCapture = md.to; this.storeCapture(capture); } - if (defined(secondCapture)) this.storeCapture(secondCapture); } } } From a75385a1a5e357a9774d7a630c614d8d83ba07eb Mon Sep 17 00:00:00 2001 From: Michael Conard Date: Mon, 27 May 2024 15:32:20 +0000 Subject: [PATCH 2/2] changelog and minor version bump --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e765979..04a39e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for shogiops +## v0.16.2 + +- Fixed `chushogi` bug where non-Lion double movers making a mid-step Lion capture was not preventing Lion counterstrike. + ## v0.16.1 - Fixed `annanshogi` move generation. diff --git a/package-lock.json b/package-lock.json index c269126..83d156a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "shogiops", - "version": "0.16.1", + "version": "0.16.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "shogiops", - "version": "0.16.1", + "version": "0.16.2", "license": "GPL-3.0-or-later", "dependencies": { "@badrap/result": "^0.2" diff --git a/package.json b/package.json index 4b0d31a..8c550fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shogiops", - "version": "0.16.1", + "version": "0.16.2", "description": "Shogi rules and operations", "keywords": [ "shogi",