fix {q,r} -> {x,y,z} conversion

This commit is contained in:
Gavin McDonald
2019-01-04 23:47:28 -05:00
parent d1b76727c8
commit 87c2fd9885

View File

@@ -8,8 +8,6 @@ import Point from './point.js';
const tilePointToHex = ({tilePoint, pixelPoint}) => ({tilePoint: new Hex(tilePoint), pixelPoint}); const tilePointToHex = ({tilePoint, pixelPoint}) => ({tilePoint: new Hex(tilePoint), pixelPoint});
window.debugged = -1;
const positive3x3 = [{ const positive3x3 = [{
x: 0, x: 0,
y: 0, y: 0,
@@ -323,7 +321,6 @@ export default class CartographerFlatXYZ extends Cartographer {
} }
boundingBox(upperLeftPoint, upperRightPoint, lowerLeftPoint, lowerRightPoint) { boundingBox(upperLeftPoint, upperRightPoint, lowerLeftPoint, lowerRightPoint) {
window.debugged++;
const upperLeftTile = this._pixelToTile(upperLeftPoint); const upperLeftTile = this._pixelToTile(upperLeftPoint);
const lowerLeftTile = this._pixelToTile(lowerLeftPoint); const lowerLeftTile = this._pixelToTile(lowerLeftPoint);
const lowerRightTile = this._pixelToTile(lowerRightPoint); const lowerRightTile = this._pixelToTile(lowerRightPoint);
@@ -340,7 +337,7 @@ export default class CartographerFlatXYZ extends Cartographer {
const bottom = top + height; const bottom = top + height;
const rows = rangeInclusive(top, bottom + 1); const rows = rangeInclusive(top, bottom + 1);
const makeAPoint = r => ({x: q, y: r, z: -q - r}); const makeAPoint = r => ({x: q, z: r, y: -q - r});
return funky.chain(rows) return funky.chain(rows)
.map(makeAPoint) .map(makeAPoint)
@@ -367,11 +364,8 @@ export default class CartographerFlatXYZ extends Cartographer {
// } // }
return funky.chain(columns) return funky.chain(columns)
.log(() => window.debugged < 1)
.map(processRow) .map(processRow)
.log(() => window.debugged < 1)
.flatten() .flatten()
.log(() => window.debugged < 1)
.value(); .value();
} }
} }