Maps: Validate and Sync
This skill covers validating and syncing WorkAdventure maps.
Important workflow note: Map editing is done by humans using the Tiled Map Editor. AI agents assist with validation, building TypeScript scripts, and syncing to the server.
For map editing instructions, see maps/README.md.
Map Architecture Overview
maps/ # Local source (tracked in git)
├── default/
│ ├── map.json # Main map file (edited in Tiled)
│ ├── tilesets/ # Tileset images
│ └── src/ # TypeScript scripts
│ └── main.ts
│ └── dist/ # Pre-built scripts (committed to git, symlinked to script/)
↓ sync-maps.sh ↓
EC2: /opt/workadventure/hackathon-infra/ # Cloned repo on server
├── maps/ # Served via nginx at /maps/*
└── assets/ # Served via nginx at /assets/*
Key points:
- •Maps are served locally from the EC2 instance via nginx (same origin as app)
- •The
hackathon-infrarepo is cloned during deployment - •
sync-maps.shSSHs into the server and runsgit pull - •Always commit map changes to git before syncing
Pre-Sync Checklist
1. Verify Environment
./scripts/validate-env.sh
2. Ensure Changes Are Committed and Pushed
git status git add maps/ git commit -m "Update maps" git push
Important: The sync script pulls from git, so changes must be pushed first.
Sync Maps to Server
./scripts/sync-maps.sh
What this does:
- •SSHs into the WorkAdventure EC2 instance
- •Runs
git pullto get latest changes - •Maps are immediately available (no container restart needed)
Success looks like:
- •"Pulling latest changes..."
- •"Maps updated successfully!"
After sync: Users may need to hard refresh their browser (Ctrl+Shift+R) to see changes.
Validating Maps
Before syncing, validate the map files:
Check JSON Syntax
python3 -m json.tool maps/default/map.json > /dev/null && echo "Valid JSON" || echo "Invalid JSON"
Check for Common Errors
Empty Data Arrays (CRITICAL - WILL CRASH CLIENT)
The Phaser game engine crashes on empty data arrays in tile layers:
grep -n '"data": \[\]' maps/default/map.json
Success: No output (no empty arrays).
Tileset Path Validation
Tileset paths in the map must be relative paths that exist:
grep -o '"image": "[^"]*"' maps/default/map.json
Building TypeScript Scripts
The dist/ folder is committed to git and contains pre-built scripts. You only need to rebuild locally if you modify maps/default/src/main.ts:
cd maps/default npm install # First time only npm run build git add dist/ git commit -m "Rebuild map scripts"
Important: Always commit the updated dist/ folder after rebuilding.
Interactive Zone Properties
These properties create interactive behaviors when added to tile layers or objects in Tiled:
| Property | Type | Description |
|---|---|---|
jitsiRoom | string | Opens Jitsi video call with this room name |
silent | boolean | Disables proximity audio in this zone |
openWebsite | string | Opens URL when player enters |
playAudio | string | Plays audio file from URL |
collides | boolean | Blocks player movement |
startLayer | boolean | Player spawn point |
focusable | boolean | Makes area appear in Explorer and auto-zooms camera |
Example: Creating a Jitsi Meeting Room
In Tiled:
- •Create a tile layer or object
- •Add custom property:
jitsiRoom=meeting-room-1 - •Save and sync
Example: Creating a Focusable Area
In Tiled (must be a rectangle object, not a tile layer):
- •Select floorLayer in the Objects panel
- •Use Rectangle tool (R) to draw over the area
- •Name it descriptively (e.g., "Meeting Room - Alpha")
- •Add custom property:
focusable=true(boolean) - •Save and sync
Troubleshooting
Map Not Loading in Browser
Check browser console for errors (F12 → Console).
Common causes:
- •
Changes not pushed to git:
bashgit status
Fix: Commit and push, then run
./scripts/sync-maps.sh - •
Tileset not found (404): Tileset paths in map.json must be relative and files must exist.
- •
Empty data array:
bashgrep '"data": \[\]' maps/default/map.json
Fix: Remove empty layers or add tile data in Tiled.
Jitsi Zones Not Working
- •Verify property name is exactly
jitsiRoom(case-sensitive) - •Verify property type is string (not boolean or number)
- •Check Jitsi service is healthy:
./scripts/status.sh
Sync Fails
- •SSH connection fails: Check your SSH key and that the EC2 instance is running
- •Git pull fails: Ensure you've pushed your changes first
TypeScript Build Fails (local)
If you modify maps/default/src/main.ts, rebuild locally before committing:
cd maps/default npm install # First time only npm run build
Then commit the updated dist/ folder along with your changes.
Workflow Summary
Human (in Tiled):
- •Edit
maps/default/map.json - •Add/modify tilesets, layers, properties
- •Save the file
AI Agent (validation & sync):
- •Validate JSON syntax
- •Check for empty data arrays
- •If TypeScript changed: build locally, commit
dist/ - •Commit and push to git
- •Run
./scripts/sync-maps.sh - •Verify in browser
After Sync:
- •Hard refresh WorkAdventure in browser (Ctrl+Shift+R)
- •Test interactive zones work as expected
Important Reminders
- •Always commit and push before sync - Server pulls from git
- •Never create empty data arrays - Crashes Phaser engine
- •Tileset paths must be relative - Not absolute filesystem paths
- •Test in browser after sync - Visual verification is important
- •Map scripts run in iframe - Cannot directly manipulate parent UI