Skip to content

Commit a6aefb0

Browse files
Add check for ruin/tower square intersect
1 parent c4a6140 commit a6aefb0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

client/src/components/sidebar/map-editor/MapGenerator.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ function verifyMap(map: CurrentMap, bodies: Bodies): string {
123123
if (numMoneyTowers !== 2) {
124124
return `Expected exactly 2 money towers, found ${numMoneyTowers}`
125125
}
126+
for (const body of bodies.bodies.values()) {
127+
// Check distance to nearby ruins
128+
129+
for (const checkRuin of map.staticMap.ruins) {
130+
if (squareIntersects(checkRuin, body.pos, 2)) {
131+
return (
132+
`Tower at (${body.pos.x}, ${body.pos.y}) is too close to ruin ` +
133+
`at (${checkRuin.x}, ${checkRuin.y}), must be ` +
134+
`>= 3 away`
135+
)
136+
}
137+
}
138+
}
126139

127140
return ''
128141
}

0 commit comments

Comments
 (0)