switched removed

This commit is contained in:
mathy 2025-05-06 14:44:40 +02:00
parent dc8c3d1faa
commit ea4a1714d0
1 changed files with 2 additions and 12 deletions

View File

@ -111,21 +111,11 @@ public class Board {
} else {
// convert each piece of both color into a character
Piece piece = board[x][y];
char pieceChar;
switch (piece.getType()) { // switch function avoids too many if-else
case King: pieceChar = 'K'; break;
case Queen: pieceChar = 'Q'; break;
case Bishop: pieceChar = 'B'; break;
case Knight: pieceChar = 'N'; break; // N because we already have King
case Rook: pieceChar = 'R'; break;
case Pawn: pieceChar = 'P'; break;
default: pieceChar = '?'; break; // safety net
}
String pieceChar = piece.getType().getSummary();
// Make black pieces in lowercase
if (!piece.isWhite()) {
pieceChar = Character.toLowerCase(pieceChar);
pieceChar = pieceChar.toLowerCase();
}
str.append(pieceChar).append(" "); // gives structure to the output