Skip to content

Commit

Permalink
Add check for ruin/tower square intersect
Browse files Browse the repository at this point in the history
  • Loading branch information
TheApplePieGod committed Jan 6, 2025
1 parent c4a6140 commit a6aefb0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/src/components/sidebar/map-editor/MapGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ function verifyMap(map: CurrentMap, bodies: Bodies): string {
if (numMoneyTowers !== 2) {
return `Expected exactly 2 money towers, found ${numMoneyTowers}`
}
for (const body of bodies.bodies.values()) {
// Check distance to nearby ruins

for (const checkRuin of map.staticMap.ruins) {
if (squareIntersects(checkRuin, body.pos, 2)) {
return (
`Tower at (${body.pos.x}, ${body.pos.y}) is too close to ruin ` +
`at (${checkRuin.x}, ${checkRuin.y}), must be ` +
`>= 3 away`
)
}
}
}

return ''
}
Expand Down

0 comments on commit a6aefb0

Please sign in to comment.