fix: correct captured pieces display logic
All checks were successful
CI Pipeline / Code Linting (pull_request) Successful in 14s
CI Pipeline / Run Tests (pull_request) Successful in 21s
CI Pipeline / Build Verification (pull_request) Successful in 12s
CI Pipeline / Generate Quality Report (pull_request) Successful in 19s

Fixes inverted display of captured pieces in UI sidebars.

Issue:
- "Captured by White" was showing white pieces
- "Captured by Black" was showing black pieces

This is backwards! The display should show:
- "Captured by White" = black pieces that white captured
- "Captured by Black" = white pieces that black captured

Root Cause:
The capturedPieces object stores pieces by their color:
- capturedPieces.white = white pieces that were captured (by black)
- capturedPieces.black = black pieces that were captured (by white)

So the display logic was inverted.

The Fix:
- whiteCaptured (header "Captured by Black") now displays captured.white
- blackCaptured (header "Captured by White") now displays captured.black

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Christoph Wagner 2025-11-23 15:42:02 +01:00
parent 8390862a73
commit 90fcf25dec

View File

@ -223,12 +223,14 @@ class ChessApp {
const captured = this.game.gameState.capturedPieces;
whiteCaptured.innerHTML = captured.black.map(piece =>
`<span class="captured-piece black">${piece.getSymbol()}</span>`
// "Captured by Black" shows white pieces that black captured
whiteCaptured.innerHTML = captured.white.map(piece =>
`<span class="captured-piece white">${piece.getSymbol()}</span>`
).join('') || '-';
blackCaptured.innerHTML = captured.white.map(piece =>
`<span class="captured-piece white">${piece.getSymbol()}</span>`
// "Captured by White" shows black pieces that white captured
blackCaptured.innerHTML = captured.black.map(piece =>
`<span class="captured-piece black">${piece.getSymbol()}</span>`
).join('') || '-';
}