From f74f6478a16564cf48b55ae2968fe44740eb92ab Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 13 Mar 2022 02:04:28 +0300 Subject: feat: improve Board.print() --- src/Board/Board.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Board/Board.ts b/src/Board/Board.ts index 4ba7a4c..1525c6c 100644 --- a/src/Board/Board.ts +++ b/src/Board/Board.ts @@ -14,7 +14,17 @@ export default class Board { } print() { - this.tiles.forEach(tile => tile.print()); + const maxY = _.maxBy(this.tiles, 'position.y').position.y; + const minY = _.minBy(this.tiles, 'position.y').position.y; + + _.range(maxY, minY - 1, -1) + .map(y => { + const rowTiles = _.filter(this.tiles, { position: { y } }); + // console.log({ rowTiles, y }); + console.log(rowTiles.map(tile => ` ${tile.sides[North]} `).join()); + console.log(rowTiles.map(tile => `${tile.sides[West]}${tile.center}${tile.sides[East]}`).join()); + console.log(rowTiles.map(tile => ` ${tile.sides[South]} `).join()); + }); } getAttachments(tile: Tile): Attachment[] { -- cgit v1.2.3