|
|
|
@ -56,7 +56,7 @@ export interface HexMap { |
|
|
|
|
* In ROWS and EVEN_ROWS mode, this is the width of the map. |
|
|
|
|
* In COLUMNS and EVEN_COLUMNS mode, this is the height of the map. |
|
|
|
|
*/ |
|
|
|
|
readonly cells_per_line: number |
|
|
|
|
readonly cellsPerLine: number |
|
|
|
|
/** |
|
|
|
|
* The list of tile lines. There are always exactly {lines} lines. |
|
|
|
|
* Lines have a constant length; there are always exactly {cells_per_line} cells in a line. |
|
|
|
@ -71,10 +71,10 @@ export interface HexMap { |
|
|
|
|
readonly xid: string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function initializeMap({lines, cells_per_line, displayMode, xid}: {lines: number, cells_per_line: number, displayMode: HexMapRepresentation, xid: string}): HexMap { |
|
|
|
|
export function initializeMap({lines, cellsPerLine, displayMode, xid}: {lines: number, cellsPerLine: number, displayMode: HexMapRepresentation, xid: string}): HexMap { |
|
|
|
|
const lineCells: HexLine[] = []; |
|
|
|
|
const emptyLine: HexCell[] = []; |
|
|
|
|
for (let cell = 0; cell < cells_per_line; cell += 1) { |
|
|
|
|
for (let cell = 0; cell < cellsPerLine; cell += 1) { |
|
|
|
|
emptyLine.push(EMPTY_CELL) |
|
|
|
|
} |
|
|
|
|
for (let line = 0; line < lines; line += 1) { |
|
|
|
@ -82,7 +82,7 @@ export function initializeMap({lines, cells_per_line, displayMode, xid}: {lines: |
|
|
|
|
} |
|
|
|
|
return { |
|
|
|
|
lines, |
|
|
|
|
cells_per_line, |
|
|
|
|
cellsPerLine: cellsPerLine, |
|
|
|
|
displayMode, |
|
|
|
|
lineCells, |
|
|
|
|
xid |
|
|
|
@ -91,7 +91,7 @@ export function initializeMap({lines, cells_per_line, displayMode, xid}: {lines: |
|
|
|
|
|
|
|
|
|
export function isValidCoordinate(map: HexMap, {line, cell}: StorageCoordinates) { |
|
|
|
|
return line >= 0 && line < map.lines && Number.isInteger(line) |
|
|
|
|
&& cell >= 0 && cell < map.cells_per_line && Number.isInteger(cell); |
|
|
|
|
&& cell >= 0 && cell < map.cellsPerLine && Number.isInteger(cell); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function areCellsEquivalent(left: HexCell|null, right: HexCell|null): boolean { |
|
|
|
|