Skip to content

Commit

Permalink
fix bug with non-lion double movers capturing lion for counterstrike …
Browse files Browse the repository at this point in the history
…rules
  • Loading branch information
maconard committed May 27, 2024
1 parent f3fa0d6 commit 219c271
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/variant/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 219c271

Please sign in to comment.