Units Page

Army unit management (create / edit / link to master units)
Authenticated CRUD Core Gameplay
/app/units.html

Source

  • /app/units.html (HTML + JS) [oai_citation:0‡units.html](sediment://file_000000000f00720a974c0990276935bf)

Purpose

  • Manage units within an army list
  • Support master unit linking (faction-based)
  • Allow legacy/free-text units
  • Maintain gameplay flags (General / BSB / Standard)

APIs Used

  • /armies/get.php
  • /units/list.php
  • /units/get.php
  • /units/create.php
  • /units/update.php
  • /units/delete.php
  • /faction units/list.php (search)

Core features

  • Unit list (left panel)
  • Create unit form
  • Edit selected unit panel
  • Master unit search + selection
  • Duplicate unit
  • Delete unit

Operational modes

Faction-locked mode

  • Requires master_unit_id
  • Units must belong to faction
  • No free-text units allowed

Legacy mode

  • No race/faction constraint
  • Allows free-text units
  • master_unit_id = -1

Unit ordering

  • Hero
  • Core
  • Special
  • Rare
  • Mercenary
  • Ally
  • Other
Then sorted alphabetically by name.

Gameplay flags

  • General
  • Battle Standard Bearer (BSB)
  • Standard
These flags directly affect scoring logic in gameplay.

Master unit search

  • Debounced search (220ms)
  • Calls: /faction units/list.php
  • Filtered by:
    • Faction (if locked)
    • Search text

UX flow

  1. Load army info
  2. Determine mode (legacy vs faction)
  3. Load units
  4. User actions:
    • Create unit
    • Select unit
    • Edit unit
    • Duplicate unit
    • Delete unit

Data rules

  • Each unit belongs to an army
  • Sort order increments by +10
  • Quantity fixed at 1 (current UI)
  • Points stored per unit

Dependencies

  • app_config.js
  • _api.js
  • Auth guard

Risks / observations

  • Large single-file JS (hard to maintain)
  • Mixed responsibilities:
    • UI
    • Validation
    • API calls
  • Hidden complexity (legacy vs faction mode)

Recommended improvements

  • Split into:
    • units.js
    • units_search.js
    • units_crud.js
  • Add validation layer abstraction
  • Add inline feedback instead of message blocks

Architecture classification

This is a Transactional CRUD Page:
  • Writes dominate over reads
  • Stateful interaction
  • Core gameplay data dependency