Game Play feature
Monolithic gameplay page (HTML + embedded JavaScript)
Interactive UX
Authenticated UX
/app/game_play.html
This is the core gameplay interface. It allows users to manage turns, record scoring events, track unit states, and ultimately finalise a game.
File structure
| Component | Description |
|---|---|
| HTML layout | Defines full UI including score panels, event entry, unit lists |
| Inline CSS | Self-contained styling (legacy – not yet extracted) |
| Inline JavaScript | Full gameplay engine and API interaction logic |
⚠️ This file predates your split architecture and should eventually be refactored.
Purpose
- Run a game in real time
- Track player turns and rounds
- Record scoring events
- Maintain unit state (alive / destroyed / below 25%)
- Apply tournament scoring logic
- End and finalise games
UI sections
Header
- Game ID, status, round, player turn
- Player names and roles
Score panel
- Live VP totals
- Raw VP result
- Tournament result
- Summary metadata
Turn controls
- Start round
- End player turn
- End game
- Finalise game
Event entry
- Scoring player selector
- Event type selector
- Dynamic points logic
- Unit selector (context aware)
- Notes
Event history
- Chronological event list
- Hard delete capability
Units panel
- Per-side unit lists
- Visual state indicators
Data flow
- Page loads with
?game_id= - Calls
/games/play_state.php - Stores response in global
state - Renders all UI sections
- User actions trigger API calls
- State reloads after every mutation
Key JavaScript functions
| Function | Purpose |
|---|---|
loadState() | Loads full game state |
renderHeader() | Updates game metadata display |
renderTotals() | Displays scoring totals |
renderUnits() | Displays unit states |
renderEvents() | Displays event list |
renderTurnScoreTable() | Turn-by-turn scoring |
Game state control logic
- Game cannot end until at least one player turn exists
- Events cannot be recorded before first round
- Finalised games are locked
- End-of-game events are restricted to post-end phase
Scoring rules implemented
- UNIT_DESTROYED → full points (+General +100, BSB +50)
- UNIT_RUN_DOWN → destroyed + auto banner (+25)
- UNIT_BELOW_25% → 50% points (rounded up)
- OBJECTIVE_CONTROLLED → default 30 per objective
- End-game events use predefined defaults
Backend dependencies
| Endpoint | Purpose |
|---|---|
/games/play_state.php | Full game state |
/turns/start.php | Start round |
/turns/end.php | End player turn |
/events/create.php | Add event |
/events/delete.php | Delete event |
/games/end.php | End game |
/games/finalise.php | Finalise game |
Technical risks / notes
- Large monolithic file (high change risk)
- UI and logic tightly coupled
- No separation of concerns
- Harder to test in isolation
Recommendation: refactor to match the pattern used in game_breakdown (HTML + JS split).