Skip to content

Commit

Permalink
Merge pull request #218 from Ido-Barnea/207-added-permanent-kill-type…
Browse files Browse the repository at this point in the history
…-of-kill-log

[#207] Added permanent kill log
  • Loading branch information
Ido-Barnea authored Feb 21, 2024
2 parents 229ae1e + ff634ca commit 2350c86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion development/code/logic/PieceLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function revertPieceMoveOnBoard(piece: Piece) {

export function onPieceFellOffTheBoard(draggedPiece: Piece) {
draggedPiece.position.boardId = VOID_BOARD_ID;
killPieceByGame(draggedPiece, 'gravity');
killPieceByGame(draggedPiece, 'the void');
game.setFellOffTheBoardPiece(draggedPiece);
game.endMove(false);
}
Expand Down Expand Up @@ -282,6 +282,7 @@ export function permanentlyKillPiece(targetPiece: Piece) {
game.increaseDeathCounter();
game.setIsPieceKilled(true);

targetPiece.position.boardId = VOID_BOARD_ID;
game.setPieces(game.getPieces().filter((piece) => piece !== targetPiece));

if (targetPiece instanceof King) endGame();
Expand Down
14 changes: 12 additions & 2 deletions development/code/ui/logs/Log.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { NOTATIONS_LETTERS, NOTATIONS_NUMBERS } from '../../Constants';
import {
NOTATIONS_LETTERS,
NOTATIONS_NUMBERS,
VOID_BOARD_ID,
} from '../../Constants';
import { Piece } from '../../logic/pieces/Piece';
import { Position } from '../../logic/pieces/PiecesUtilities';
import { Logger } from './Logger';
Expand Down Expand Up @@ -59,7 +63,13 @@ export class KillLog extends Log {
name: killedPieceName,
} = killedPiece;

let message = `${killedPieceIcon} ${killedPieceColor} ${killedPieceName} was killed by `;
let message = `${killedPieceIcon} ${killedPieceColor} ${killedPieceName} was `;

if (killedPiece.position.boardId === VOID_BOARD_ID) {
message += 'permanently ';
}
message += 'killed by ';

if (cause instanceof Piece) {
const {
pieceIcon: killerPieceIcon,
Expand Down

0 comments on commit 2350c86

Please sign in to comment.