Rename cells_per_line to cellsPerLine for consistency.

main
Mari 3 years ago
parent 3ad2a0c7b1
commit ea4ce1c23f
  1. 2
      client/src/App.tsx
  2. 10
      client/src/state/HexMap.ts
  3. 2
      client/src/ui/HexMapRenderer.tsx
  4. 2
      client/src/ui/debug/ConsoleConnection.tsx

@ -38,7 +38,7 @@ function App() {
} : null), [map]) } : null), [map])
const mapElement = !!offsets && !!map ? <HexMapRenderer map={map} offsets={offsets} /> : null; const mapElement = !!offsets && !!map ? <HexMapRenderer map={map} offsets={offsets} /> : null;
const {width, height} = useMemo(() => !!offsets && !!map ? sizeFromLinesAndCells({ const {width, height} = useMemo(() => !!offsets && !!map ? sizeFromLinesAndCells({
bottomMargin: 10, cells: map.cells_per_line, lines: map.lines, offsets: offsets, rightMargin: 10 bottomMargin: 10, cells: map.cellsPerLine, lines: map.lines, offsets: offsets, rightMargin: 10
}) : {width: 1, height: 1}, [map, offsets]); }) : {width: 1, height: 1}, [map, offsets]);
const colorPickerElement = !!user ? <HexColorPicker color={user?.activeColor} onChangeComplete={(colorResult) => dispatch({ const colorPickerElement = !!user ? <HexColorPicker color={user?.activeColor} onChangeComplete={(colorResult) => dispatch({
type: USER_ACTIVE_COLOR, type: USER_ACTIVE_COLOR,

@ -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 {

@ -6,7 +6,7 @@ import {RenderOffsets, storageCoordinatesToKey} from "../state/Coordinates";
function HexMapRenderer({map, offsets}: {map: HexMap, offsets: RenderOffsets}) { function HexMapRenderer({map, offsets}: {map: HexMap, offsets: RenderOffsets}) {
const tiles: ReactElement[] = []; const tiles: ReactElement[] = [];
for (let line = 0; line < map.lines; line += 1) { for (let line = 0; line < map.lines; line += 1) {
for (let cell = 0; cell < map.cells_per_line; cell += 1) { for (let cell = 0; cell < map.cellsPerLine; cell += 1) {
const coords = {line, cell}; const coords = {line, cell};
const cellData = getCell(map, coords); const cellData = getCell(map, coords);
if (cellData !== null) { if (cellData !== null) {

@ -88,7 +88,7 @@ export class ConsoleConnection {
state: { state: {
map: initializeMap({ map: initializeMap({
lines, lines,
cells_per_line: cells, cellsPerLine: cells,
displayMode: orientationFromString(displayMode), displayMode: orientationFromString(displayMode),
xid xid
}), }),

Loading…
Cancel
Save