How misted91/clash_royal works
Web Royale is a real-time 1v1 strategy game with solo play against a simple AI and online matches. The player selects a card and deploys it on the arena; the shared game engine simulates the match, while the client renders state and updates the HUD. Online, the server pairs players, runs the authoritative simulation, and broadcasts snapshots. The README documents both modes; edges below are limited to relationships shown in excerpts, the SOURCE INDEX, or README.
Main entry points: main.ts Client orchestration · engine.ts Match simulation · renderer.ts Arena renderer · ai.ts Solo AI
Components 14
Game client
- Client orchestration
src/client/main.ts - Card HUD
src/client/hud.ts - Arena renderer
src/client/renderer.ts
Game rules
- Match simulation
src/engine/engine.ts - Solo AI
src/engine/ai.ts - Arena rules
src/engine/arena.ts - Card catalogue
src/engine/cards.ts - Game state types
src/engine/types.ts
Online play
- WebSocket client
src/net/client.ts - Message protocol
src/net/protocol.ts - Player matchmaking
server/index.ts - Authoritative match
server/index.ts
Other components
- Player
- Online opponent
Connections 24
- Player → Client orchestration: starts game
README.md - Player → Card HUD: selects card
README.md - Client orchestration → Card HUD: creates and updates
src/client/main.ts - Client orchestration → Arena renderer: renders state
src/client/main.ts - Client orchestration → Match simulation: steps and reads state
src/client/main.ts - Client orchestration → Solo AI: updates in solo
src/client/main.ts - Client orchestration → WebSocket client: connects and sends deploys
src/client/main.ts - Card HUD → Card catalogue: displays catalogue
src/client/hud.ts - Arena renderer → Card catalogue: draws units
src/client/renderer.ts - Arena renderer → Arena rules: draws arena
src/client/renderer.ts - Arena renderer → Game state types: renders game state
src/client/renderer.ts - Match simulation → Arena rules: uses arena rules
src/engine/engine.ts - Match simulation → Card catalogue: uses card definitions
src/engine/engine.ts - Match simulation → Game state types: uses game types
src/engine/engine.ts - Solo AI → Match simulation: deploys cards
src/engine/ai.ts - Solo AI → Arena rules: reads arena bounds
src/engine/ai.ts - Solo AI → Card catalogue: chooses affordable cards
src/engine/ai.ts - WebSocket client → Message protocol: encodes messages
src/net/client.ts - Player matchmaking → Authoritative match: pairs players
server/index.ts - Authoritative match → Match simulation: simulates match
server/index.ts - Authoritative match → Message protocol: sends match messages
server/index.ts - Online opponent → Player matchmaking: joins queue
server/index.ts - WebSocket client → Player matchmaking: opens WebSocket
README.md - Authoritative match → WebSocket client: broadcasts snapshots
server/index.ts