Skip to content

Commit 3d2a4ff

Browse files
committed
map export fixes
1 parent 956328d commit 3d2a4ff

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,27 @@ function verifyMap(map: CurrentMap, bodies: Bodies): string {
147147
// Validate initial bodies
148148
for (const body of bodies.bodies.values()) {
149149
// Check distance from cat to other cats and cheese mines
150+
let body_type = undefined
151+
switch (body.robotType) {
152+
case RobotType.CAT:
153+
body_type = 'Cat'
154+
break
155+
case RobotType.RAT:
156+
body_type = 'Rat'
157+
break
158+
case RobotType.RAT_KING:
159+
body_type = 'Rat King'
160+
break
161+
default:
162+
body_type = 'Unknown'
163+
}
150164

151165
for (const checkCheeseMine of map.staticMap.cheeseMines) {
152-
if (squareIntersects(checkCheeseMine, body.pos, 4)) {
166+
if (squareIntersects(checkCheeseMine, body.pos, 2)) {
153167
return (
154-
`Cheese mine at (${checkCheeseMine.x}, ${checkCheeseMine.y}) is too close to cheese mine ` +
168+
`Cheese mine at (${checkCheeseMine.x}, ${checkCheeseMine.y}) is too close to ${body_type} ` +
155169
`at (${body.pos.x}, ${body.pos.y}), must be ` +
156-
`>= 5 away`
170+
`>= 3 away`
157171
)
158172
}
159173
}
@@ -162,7 +176,7 @@ function verifyMap(map: CurrentMap, bodies: Bodies): string {
162176
if (checkBody === body) continue
163177
if (squareIntersects(checkBody.pos, body.pos, 0)) {
164178
return (
165-
`Cat at (${body.pos.x}, ${body.pos.y}) is too close to cat ` +
179+
`${body_type} at (${body.pos.x}, ${body.pos.y}) is too close to cat ` +
166180
`at (${checkBody.pos.x}, ${checkBody.pos.y}), must be ` +
167181
`>= 1 away`
168182
)
@@ -175,7 +189,7 @@ function verifyMap(map: CurrentMap, bodies: Bodies): string {
175189
if (wall !== -1) {
176190
const pos = map.indexToLocation(wall)
177191
return (
178-
`Cat at (${body.pos.x}, ${body.pos.y}) is too close to wall ` +
192+
`${body_type} at (${body.pos.x}, ${body.pos.y}) is too close to wall ` +
179193
`at (${pos.x}, ${pos.y}), must be ` +
180194
`>= 3 away`
181195
)

0 commit comments

Comments
 (0)