Skip to content

Commit

Permalink
[#206] Fixed shield log
Browse files Browse the repository at this point in the history
  • Loading branch information
Ido-Barnea committed Feb 21, 2024
1 parent 86b9ad5 commit 20ca9df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions development/code/logic/items/Inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Log } from '../../ui/logs/Log';
import { INVENTORY_WIDTH } from '../../Constants';
import { Player } from '../Players';
import { Item } from './Items';
import { Logger } from '../../ui/logs/Logger';

export class Inventory {
items: Array<Item> = [];
Expand All @@ -15,6 +16,7 @@ export class Inventory {
if (this.items.length >= INVENTORY_WIDTH) return false;
this.items.push(item);
new Log(`${this.player.color} received a ${item.name}.`).addToQueue();
Logger.logMessages();
return true;
}

Expand Down
9 changes: 5 additions & 4 deletions development/code/logic/items/Shield.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Item } from './Items';
import { shieldResource } from '../../ui/Resources';
import { Position } from '../pieces/PiecesUtilities';
import { Log } from '../../ui/logs/Log';
import { Log, MovementLog } from '../../ui/logs/Log';
import { getPieceByPosition } from '../Utilities';
import { spawnItemOnPiece } from '../../LogicAdapter';
import { Logger } from '../../ui/logs/Logger';

export class Shield extends Item {
constructor(position?: Position) {
Expand All @@ -14,9 +15,9 @@ export class Shield extends Item {
const piece = getPieceByPosition(position);
if (!piece) return;

new Log(
`${piece.player.color} ${piece.name} placed a ${this.name} on ${piece}.`,
).addToQueue();
const logCoordinates = MovementLog.convertPositionToNotation(piece.position.coordinates);
new Log(`${piece.player.color} ${piece.name} on ${logCoordinates} equiped a ${this.name}.`).addToQueue();
Logger.logMessages();

this.position = position;
piece.health++;
Expand Down

0 comments on commit 20ca9df

Please sign in to comment.