UNPKG

@typed-tabletop-simulator/lib

Version:
21 lines (20 loc) 665 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GameGrid = void 0; class GameGrid { size; constructor(size) { this.size = size; } round = (coordinate) => { const qGrid = Math.round(coordinate.q); const rGrid = Math.round(coordinate.r); coordinate.q -= qGrid; coordinate.r -= rGrid; if (Math.abs(coordinate.q) >= Math.abs(coordinate.r)) { return { q: qGrid + Math.round(coordinate.q + 0.5 * coordinate.r), r: rGrid }; } return { q: qGrid, r: rGrid + Math.round(coordinate.q + 0.5 * coordinate.r) }; }; } exports.GameGrid = GameGrid;