diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-13 02:04:28 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-13 02:04:28 +0300 |
commit | f74f6478a16564cf48b55ae2968fe44740eb92ab (patch) | |
tree | 9b428ad0d65486dabc9a92e614703135ced536ea | |
parent | 93379c8826034601bbaad017366ddd2e484574e3 (diff) | |
download | carcassonne-engine-ts-f74f6478a16564cf48b55ae2968fe44740eb92ab.tar.gz |
feat: improve Board.print()
-rw-r--r-- | src/Board/Board.ts | 12 |
1 files changed, 11 insertions, 1 deletions
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[] { |