@typed-tabletop-simulator/lib
Version:
Library with some helping modules for working with Tabletop Simulator
21 lines (20 loc) • 665 B
JavaScript
;
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;