diff --git a/development/src/logic/logic.ts b/development/src/logic/logic.ts index c9ba4059..c9e9170b 100644 --- a/development/src/logic/logic.ts +++ b/development/src/logic/logic.ts @@ -294,11 +294,23 @@ function killPieceProcess( targetPiece: Piece, targetPosition: Position, ) { + const targetPieceLogo = targetPiece.pieceLogo; + const targetPieceColor = targetPiece.player.color; + const targetPieceName = targetPiece.name; + const draggedPieceLogo = draggedPiece.pieceLogo; + const draggedPieceColor = draggedPiece.player.color; + const draggedPieceName = draggedPiece.name; + if (targetPiece.position.board === OVERWORLD_BOARD_ID) { targetPiece.position = targetPosition; - Logger.logKill(`A ${targetPiece.player.color} ${targetPiece.name} - was killed by a ${draggedPiece.player.color} ${draggedPiece.name}.`); + Logger.logKill( + `A + ${targetPieceLogo} ${targetPieceColor} ${targetPieceName} + was killed by a + ${draggedPieceLogo} ${draggedPieceColor} ${draggedPieceName} + .`, + ); if (targetPiece.hasKilled) { targetPiece.position = { @@ -327,9 +339,13 @@ function killPieceProcess( spawnPieceOnBoard(targetPiece); } else { - Logger.logKill(`A ${targetPiece.player.color} ${targetPiece.name} was - permanently killed by a ${draggedPiece.player.color} - ${draggedPiece.name}.`); + Logger.logKill( + `A + ${targetPieceLogo} ${targetPieceColor} ${targetPieceName} + was permanently killed by a + ${draggedPieceLogo} ${draggedPieceColor} ${draggedPieceName} + .`, + ); pieces.forEach((piece) => { const areOnTheSamePosition = comparePositions( @@ -401,7 +417,9 @@ function castle(kingPiece: Piece, targetSquare: Square) { const rookPieceTargetSquare: Square = { position: rookPieceTargetPosition }; move(rookPiece, rookPieceTargetSquare, false); - Logger.logGeneral(`${kingPiece.player.color} castled.`); + Logger.logGeneral( + `${kingPiece.pieceLogo} ${kingPiece.player.color} castled.`, + ); return true; } diff --git a/development/src/logic/pieces.ts b/development/src/logic/pieces.ts index 9c3a096c..2674a397 100644 --- a/development/src/logic/pieces.ts +++ b/development/src/logic/pieces.ts @@ -46,11 +46,13 @@ export class Piece implements PieceType { name: string; hasMoved: boolean; hasKilled: boolean; + pieceLogo: string; constructor( position: Position, player: Player, resource: string, name: string, + pieceLogo: string, ) { this.position = position; this.player = player; @@ -58,6 +60,7 @@ export class Piece implements PieceType { this.name = name; this.hasMoved = false; this.hasKilled = false; + this.pieceLogo = pieceLogo; } validateMove(_: Piece | Square | Item): Position { @@ -89,7 +92,10 @@ export class Pawn extends Piece { enPassant: boolean; constructor(position: Position, player: Player) { - super(position, player, pawnResource, 'Pawn'); + const logo = player.color === PlayerColors.WHITE + ? '♙' + : '♟'; + super(position, player, pawnResource, 'Pawn', logo); this.enPassant = false; } @@ -158,7 +164,10 @@ export class Pawn extends Piece { export class Bishop extends Piece { constructor(position: Position, player: Player) { - super(position, player, bishopResource, 'Bishop'); + const logo = player.color === PlayerColors.WHITE + ? '♗' + : '♝'; + super(position, player, bishopResource, 'Bishop', logo); } validateMove(target: Piece | Square) { @@ -187,7 +196,10 @@ export class Bishop extends Piece { export class Knight extends Piece { constructor(position: Position, player: Player) { - super(position, player, knightResource, 'Knight'); + const logo = player.color === PlayerColors.WHITE + ? '♘' + : '♞'; + super(position, player, knightResource, 'Knight', logo); } validateMove(target: Piece | Square) { @@ -203,7 +215,10 @@ export class Knight extends Piece { export class Rook extends Piece { constructor(position: Position, player: Player) { - super(position, player, rookResource, 'Rook'); + const logo = player.color === PlayerColors.WHITE + ? '♖' + : '♜'; + super(position, player, rookResource, 'Rook', logo); } validateMove(target: Piece | Square) { @@ -240,7 +255,11 @@ export class Rook extends Piece { export class Queen extends Piece { constructor(position: Position, player: Player) { - super(position, player, queenResource, 'Queen'); + const logo = player.color === PlayerColors.WHITE + ? '♕' + : '♛'; + + super(position, player, queenResource, 'Queen', logo); } validateMove(target: Piece | Square) { @@ -284,7 +303,11 @@ export class Queen extends Piece { export class King extends Piece { constructor(position: Position, player: Player) { - super(position, player, kingResource, 'King'); + const logo = player.color === PlayerColors.WHITE + ? '♔' + : '♚'; + + super(position, player, kingResource, 'King', logo); } validateMove(target: Piece | Square) { diff --git a/development/src/ui/logger.ts b/development/src/ui/logger.ts index 938921fc..12d03bda 100644 --- a/development/src/ui/logger.ts +++ b/development/src/ui/logger.ts @@ -36,8 +36,16 @@ export class Logger { const toNotation = this.convertPositionToNotation( targetSquare.position.coordinates, ); - this.log(`${draggedPiece.player.color} ${draggedPiece.name} - moved from ${fromNotation} to ${toNotation}.`, LogColor.movement); + + const pieceLogo = `${draggedPiece.pieceLogo}`; + const pieceColor = `${draggedPiece.player.color}`; + const pieceName = `${draggedPiece.name}`; + + this.log(` + ${pieceLogo} ${pieceColor} ${pieceName} + moved from ${fromNotation} to ${toNotation}.`, + LogColor.movement, + ); } private static convertPositionToNotation(position: [number, number]) {