📜 Battle Log
{history.length === 0 ? (
"The battle begins..."
) : (
history.map((move, i) => (
{Math.floor(i / 2) + 1}
{getPieceName(move.piece)}
{String.fromCharCode(97 + move.from.c)}{8 - move.from.r} → {String.fromCharCode(97 + move.to.c)}{8 - move.to.r}
))
)}
el?.scrollIntoView({ behavior: 'smooth' })} />
);
}
const getPieceName = (p) => {
const names = {
'P': 'Pawn', 'N': 'Knight', 'B': 'Bishop', 'R': 'Rook', 'Q': 'Queen', 'K': 'King',
'p': 'Pawn', 'n': 'Knight', 'b': 'Bishop', 'r': 'Rook', 'q': 'Queen', 'k': 'King',
};
return names[p] || p;
};