All files Utils.ts

69.56% Statements 16/23
100% Branches 3/3
66.66% Functions 2/3
73.68% Lines 14/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  1x 1x   1x 1x 7x 7x 49x   7x       1x 49x   14x   20x   15x       1x                  
import { Board } from "./Board";
import { BoardPosition } from "./BoardPosition";
import { PathTile, TileType } from "./PathTile";
 
export function printBoard(board: Board) {
  for (let y = 0; y < board.height; y++) {
    let row = "";
    for (let x = 0; x < board.height; x++) {
      row += `| ${stringifyTile(board.getTile(new BoardPosition(x, y)))} |`;
    }
    console.log(row);
  }
}
 
export function stringifyTile(pathTile: PathTile): string {
  switch (pathTile.tileType) {
    case TileType.L:
      return `L-${pathTile.rotation}`;
    case TileType.T:
      return `T-${pathTile.rotation}`;
    case TileType.STREIGHT:
      return `S-${pathTile.rotation}`;
  }
}
 
export function printDistances(distances: number[][]) {
  for (let y = 0; y < distances.length; y++) {
    let rowStr = "";
    for (let x = 0; x < distances[0].length; x++) {
      rowStr += `| ${distances[x][y]} |`;
    }
    console.log(rowStr);
  }
}