Game Setup feature
Split architecture (HTML + JS)
Interactive UX
Authenticated UX
/app/game_setup.html
This page is responsible for creating and configuring games.
It supports both event-based and non-event workflows,
including opponent selection, army setup, and game initialisation.
File structure
| File | Responsibility |
/app/game_setup.html |
UI layout and interaction containers [oai_citation:0‡game_setup.html](sediment://file_00000000261c7246a591897e9a186051) |
/app/scripts/game_setup.js |
All logic, state handling, and API interaction [oai_citation:1‡game_setup.js](sediment://file_000000009a3072439954e895b1df8076) |
Purpose
- Create new games (event or non-event)
- Select opponent (registered or guest)
- Assign armies to both sides
- Import guest armies (multiple formats)
- Apply scoring systems
- Start the game and transition to gameplay
Game modes
| Mode | Description |
| Event |
Uses tournament entrants, auto-handles round, armies, and metadata |
| Non-event |
Manual setup: opponent, armies, scenario, scoring system |
UI flow
- Select game mode
- Select opponent (event or manual)
- Create game
- Select armies (non-event only)
- Choose first player
- Start game → redirect to gameplay
Key UI sections
Subscription gate
- Blocks access if no subscription or trial used
Mode selector
- Event vs Non-event toggle
Event setup
- Event selection
- Entrant search
- Opponent selection
Non-event setup
- User search
- Guest opponent option
- Game metadata fields
Army selection
- Player army dropdown
- Opponent army dropdown
- Guest army import + manual fallback
Start section
- First player selection
- Start game button
Data flow
- Load user via
/auth/me.php
- Apply subscription gate
- Load tournaments
- User selects opponent
- Create game via API
- Assign armies (if needed)
- Start game → redirect
Key JavaScript functions
| Function | Purpose |
init() | Initial page setup |
setMode() | Switch event/non-event mode |
createGame() | Create game via API |
refreshArmies() | Load available armies |
setArmy() | Assign army to side |
giImportGuestArmy() | Import guest army |
startGame() | Start game and redirect |
Backend dependencies
| Endpoint | Purpose |
/auth/me.php | User + subscription |
/tournaments/list.php | Load events/scoring |
/games/create.php | Create game |
/games/setup_side.php | Assign armies |
/games/start.php | Start game |
/armies/list.php | Load armies |
/armies/import_*.php | Guest army import |
Special logic
- Subscription gating before access
- Event mode hides army selection
- Guest opponents require ephemeral armies
- Army assignment required before start (non-event)
- Dynamic UI updates based on state
Technical notes
- Large JS file (high complexity but structured)
- Heavy state management in frontend
- Multiple API dependencies
- Well-aligned with target architecture (good baseline)