Skip to content

Commit 219c271

Browse files
committed
fix bug with non-lion double movers capturing lion for counterstrike rules
1 parent f3fa0d6 commit 219c271

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/variant/position.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,19 @@ export abstract class Position {
298298
piece.role = promote(this.rules)(role) || role;
299299

300300
const capture = this.board.set(md.to, piece),
301-
secondCapture = defined(md.midStep) ? this.board.take(md.midStep) : undefined;
301+
midCapture = defined(md.midStep) ? this.board.take(md.midStep) : undefined;
302+
303+
// process midCapture (if exists) before final destination capture
304+
if (defined(midCapture)) {
305+
if (!lionRoles.includes(role) && midCapture.color === this.turn && lionRoles.includes(midCapture.role))
306+
this.lastLionCapture = md.midStep;
307+
this.storeCapture(midCapture);
308+
}
302309
if (capture) {
303310
if (!lionRoles.includes(role) && capture.color === this.turn && lionRoles.includes(capture.role))
304311
this.lastLionCapture = md.to;
305312
this.storeCapture(capture);
306313
}
307-
if (defined(secondCapture)) this.storeCapture(secondCapture);
308314
}
309315
}
310316
}

0 commit comments

Comments
 (0)