diff options
| author | Georgios Andreadis <G.Andreadis@student.tudelft.nl> | 2017-11-10 10:26:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-10 10:26:59 +0100 |
| commit | f67bcd2043a416d16431b905de2470ac6005550e (patch) | |
| tree | fcf84736defa9742f5384ed51f32f5615cd70001 | |
| parent | 46137ff8dafa045a376549527df6098e10782420 (diff) | |
| parent | 319696f82257cc90e06c3a47d17758f8975eb9d0 (diff) | |
Merge pull request #58 from atlarge-research/chore/bithound
Bithound integration
| -rw-r--r-- | .bithoundrc | 17 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | src/util/tile-calculations.js | 24 |
3 files changed, 33 insertions, 9 deletions
diff --git a/.bithoundrc b/.bithoundrc new file mode 100644 index 00000000..bf7f1f15 --- /dev/null +++ b/.bithoundrc @@ -0,0 +1,17 @@ +{ + "ignore": [ + ], + "test": [ + ], + "dependencies": { + "unused-ignores": [ + "react-scripts", + "prettier", + "node-sass-chokidar", + "lint-staged", + "konva", + "husky", + "npm-run-all" + ] + } +} diff --git a/package.json b/package.json index 50326e4a..7e802606 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "approximate-number": "^2.0.0", "classnames": "^2.2.5", "husky": "^0.14.3", - "isomorphic-fetch": "^2.2.1", "konva": "^1.7.2", "lint-staged": "^4.3.0", "node-sass-chokidar": "^0.0.3", diff --git a/src/util/tile-calculations.js b/src/util/tile-calculations.js index 9a1dc1c0..95886eeb 100644 --- a/src/util/tile-calculations.js +++ b/src/util/tile-calculations.js @@ -1,12 +1,16 @@ export function deriveWallLocations(tiles) { + const { verticalWalls, horizontalWalls } = getWallSegments(tiles); + return mergeWallSegments(verticalWalls, horizontalWalls); +} + +function getWallSegments(tiles) { const verticalWalls = {}; const horizontalWalls = {}; - // Determine wall segments - tiles.forEach(tile => { const x = tile.positionX, y = tile.positionY; + for (let dX = -1; dX <= 1; dX++) { for (let dY = -1; dY <= 1; dY++) { if (Math.abs(dX) === Math.abs(dY)) { @@ -14,14 +18,15 @@ export function deriveWallLocations(tiles) { } let doInsert = true; - tiles.forEach(otherTile => { + for (let tileIndex in tiles) { if ( - otherTile.positionX === x + dX && - otherTile.positionY === y + dY + tiles[tileIndex].positionX === x + dX && + tiles[tileIndex].positionY === y + dY ) { doInsert = false; + break; } - }); + } if (!doInsert) { continue; } @@ -59,10 +64,13 @@ export function deriveWallLocations(tiles) { } }); - // Merge walls into longer segments + return { verticalWalls, horizontalWalls }; +} +function mergeWallSegments(vertical, horizontal) { const result = []; - const walls = [verticalWalls, horizontalWalls]; + const walls = [vertical, horizontal]; + for (let i = 0; i < 2; i++) { const wallList = walls[i]; for (let a in wallList) { |
