Skip to content

Commit

Permalink
Tweak solution centering
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenAppers committed Sep 25, 2024
1 parent 0682eb2 commit 2e3ea47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ permissions:

jobs:
release:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.config.os }}

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
config:
- {os: macos-latest, flags: '--arch universal'}
- {os: ubuntu-latest, flags: ''}
- {os: windows-latest, flags: '']

steps:
- name: Checkout
Expand All @@ -32,4 +35,4 @@ jobs:
- name: Publish app
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn && yarn publish-app
run: yarn && yarn publish-app ${{ matrix.config.flags }}
12 changes: 7 additions & 5 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,27 @@ function App() {
const xSort = [...corners].sort((a, b) => a.chunk.x - b.chunk.x)
const zSort = [...corners].sort((a, b) => a.chunk.z - b.chunk.z)

let foundX, foundZ
let distX, distZ, foundX, foundZ
for (let i = 0; i < xSort.length - 1; i++) {
if (xSort[i].chunk.x === xSort[i + 1].chunk.x) {
foundZ = lerp(xSort[i].chunk.z, xSort[i + 1].chunk.z, 0.5)
distZ = Math.abs(xSort[i].chunk.z - xSort[i + 1].chunk.z)
break
}
}
for (let i = 0; i < zSort.length - 1; i++) {
if (zSort[i].chunk.z === zSort[i + 1].chunk.z) {
foundX = lerp(zSort[i].chunk.x, zSort[i + 1].chunk.x, 0.5)
distX = Math.abs(zSort[i].chunk.x - zSort[i + 1].chunk.x)
break
}
}

if (foundX && foundZ) log.info(`Found solution: ${foundX}, ${foundZ}`)
setSolution({ minX, maxX, minZ, maxZ, foundX, foundZ })
setSolution({ minX, maxX, minZ, maxZ, distX, distZ, foundX, foundZ })
}, [corners, setSolution])

const { minX, maxX, minZ, maxZ, foundX, foundZ } = solution
const { minX, maxX, minZ, maxZ, distX, distZ, foundX, foundZ } = solution

return (
<Container>
Expand Down Expand Up @@ -262,8 +264,8 @@ function App() {
<Td>
<Icon as={StarIcon} color="yellow.300" marginX="5px" />
</Td>
<Td>{foundX * 16 + 8 * (foundX >= 0 ? 1 : -1)}</Td>
<Td>{foundZ * 16 + 8 * (foundZ >= 0 ? 1 : -1)}</Td>
<Td>{foundX * 16 + 8 * (1 + (distX % 2))}</Td>
<Td>{foundZ * 16 + 8 * (1 + (distZ % 2))}</Td>
<Td>{foundX}</Td>
<Td>{foundZ}</Td>
<Td></Td>
Expand Down
2 changes: 2 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface Solution {
maxX?: number
minZ?: number
maxZ?: number
distX?: number
distZ?: number
foundX?: number
foundZ?: number
}
Expand Down

0 comments on commit 2e3ea47

Please sign in to comment.