- TypeScript project using Vite
- Output: Single minified JavaScript bundle
- No external dependencies except OpenLayers types
The game exposes itself through a global window object with the following structure:
window.__MAP_GAME__ = {
available: boolean,
instance: {
activate: (mapElementId: string) => void,
deactivate: () => void
}
}-
Game Controller
- Main entry point
- Manages game state
- Handles OpenLayers integration
- Coordinates between all other components
-
Feature Manager
- Handles drawing/managing game elements
- Uses OpenLayers Vector layers
- Manages interactions with game objects
- Collision detection and spatial queries
-
UI Manager
- Creates overlay elements
- Score display
- Game controls
- Leaderboard display
- Modal dialogs for game events
-
API Client
- Handles communication with backend
- Score submission
- Leaderboard fetching
- Error handling and retry logic
- Spring Boot application
- H2 database (existing)
- RESTful API endpoints
GET /api/scores - Fetch highscores
POST /api/scores - Submit new score
GET /api/leaderboard - Get formatted leaderboard
- Client build produces single 'game-bundle.js'
- Host applications include bundle via script tag
- Check for window.MAP_GAME.available
- Activate using window.MAP_GAME.instance.activate('map-id')
- CORS configuration for API endpoints
- Rate limiting for score submission
- Basic validation of game results
- XSS prevention in leaderboard display
- Develop and test client in isolation
- Build and integrate with test applications
- Deploy backend separately
- Distribute client bundle to host applications