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

FileResponsibility
/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

ModeDescription
Event Uses tournament entrants, auto-handles round, armies, and metadata
Non-event Manual setup: opponent, armies, scenario, scoring system

UI flow

  1. Select game mode
  2. Select opponent (event or manual)
  3. Create game
  4. Select armies (non-event only)
  5. Choose first player
  6. 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

  1. Load user via /auth/me.php
  2. Apply subscription gate
  3. Load tournaments
  4. User selects opponent
  5. Create game via API
  6. Assign armies (if needed)
  7. Start game → redirect

Key JavaScript functions

FunctionPurpose
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

EndpointPurpose
/auth/me.phpUser + subscription
/tournaments/list.phpLoad events/scoring
/games/create.phpCreate game
/games/setup_side.phpAssign armies
/games/start.phpStart game
/armies/list.phpLoad armies
/armies/import_*.phpGuest 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)