|
|
@ -56,7 +56,7 @@ export interface HexMap { |
|
|
|
* In ROWS and EVEN_ROWS mode, this is the width of the map. |
|
|
|
* 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. |
|
|
|
* 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. |
|
|
|
* 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. |
|
|
|
* 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 |
|
|
|
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 lineCells: HexLine[] = []; |
|
|
|
const emptyLine: HexCell[] = []; |
|
|
|
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) |
|
|
|
emptyLine.push(EMPTY_CELL) |
|
|
|
} |
|
|
|
} |
|
|
|
for (let line = 0; line < lines; line += 1) { |
|
|
|
for (let line = 0; line < lines; line += 1) { |
|
|
@ -82,7 +82,7 @@ export function initializeMap({lines, cells_per_line, displayMode, xid}: {lines: |
|
|
|
} |
|
|
|
} |
|
|
|
return { |
|
|
|
return { |
|
|
|
lines, |
|
|
|
lines, |
|
|
|
cells_per_line, |
|
|
|
cellsPerLine: cellsPerLine, |
|
|
|
displayMode, |
|
|
|
displayMode, |
|
|
|
lineCells, |
|
|
|
lineCells, |
|
|
|
xid |
|
|
|
xid |
|
|
@ -91,7 +91,7 @@ export function initializeMap({lines, cells_per_line, displayMode, xid}: {lines: |
|
|
|
|
|
|
|
|
|
|
|
export function isValidCoordinate(map: HexMap, {line, cell}: StorageCoordinates) { |
|
|
|
export function isValidCoordinate(map: HexMap, {line, cell}: StorageCoordinates) { |
|
|
|
return line >= 0 && line < map.lines && Number.isInteger(line) |
|
|
|
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 { |
|
|
|
export function areCellsEquivalent(left: HexCell|null, right: HexCell|null): boolean { |
|
|
|