PURPOSE
Provides a unified read-only adapter layer over four game-data domains (ships, weapons, enemies, artifacts) for the playground’s right-panel editor. Each adapter exposes a consistent shape so the editor UI can list entities, enumerate tunable stat definitions, and read current numeric values without knowing the underlying data-table format.
OWNS
StatConfiginterface — describes a single editable stat slot (key,label,min,max,step,category).DataAdapterinterface — the common adapter contract (type,getAll,getById,getStatDefs,getStatValue,getSavedValue).- Four concrete adapter constants:
ShipAdapter,WeaponAdapter,EnemyAdapter,ArtifactAdapter. - Three local stat-definition tables:
SHIP_STATS,WEAPON_STATS,ENEMY_STATS. - The
DATA_ADAPTERSregistry keyed by adaptertypeand theDATA_ADAPTER_LISTof registry keys.
READS FROM
../../data/ships—HULL_CLASSES,getShipDef.../../data/weapons—WEAPONS,WEAPON_MAP.../../data/enemies—ENEMY_TYPES,ENEMY_TYPE_MAP.../../data/artifacts—ARTIFACT_DEFS,ARTIFACT_MAP.
PUSHES TO
Nothing. This module is read-only; it exposes adapter objects for consumers to import. There are no writes, no store mutations, no events.
DOES NOT
- Does not mutate game data tables.
- Does not persist edits —
getSavedValuecurrently aliasesgetStatValuefor every adapter; there is no separate saved-overrides store. - Does not render UI; it only supplies data shape.
- Does not validate stat ranges against the source data; the
min/max/stepvalues are editor hints only. - Does not handle hot-reload, level scaling beyond the ship-adapter calling
getShipDef(id, 1), or tier traversal beyond the single artifact tier-0 template.
Signals
None. No event emission, no subscriptions. Adapters are pure functions over the imported data.
Entry points
DATA_ADAPTERS— registry consumed by the playground editor to pick an adapter by string key ('ships','weapons','enemies','artifacts').DATA_ADAPTER_LIST— list of registry keys.- Individual named exports
ShipAdapter,WeaponAdapter,EnemyAdapter,ArtifactAdapterfor direct imports. StatConfigandDataAdaptertypes for downstream typing.
Pattern notes
- All adapters conform to the same
DataAdaptershape, letting the editor stay generic over data type. - Stat keys may be dotted paths.
WeaponAdapter.getStatValuesplits on.and walks two levels (e.g.damage.base);ArtifactAdapterusestierN.<valueKey>and parses the tier index from the prefix. ShipAdapter.getByIdswallows errors fromgetShipDefand returnsnullso missing/invalid ids do not throw.WeaponAdapter.getAllfilters out entries markeddisabled.EnemyAdapter.getAllde-duplicates byidusing aSetwhile preserving first-seen order fromENEMY_TYPES.ArtifactAdapter.getStatDefsderives stat slots from the first artifact’s tier-0valueskeys, converts camelCase to spaced labels via a regex, and uses fixed editor bounds (min: 0,max: 1000,step: 0.1).- Methods that need
this(e.g.getStatValuecallingthis.getById) are defined with thefunctionkeyword rather than arrow form so the adapter object binds as receiver. getSavedValueis a stub aliasinggetStatValueon every adapter — placeholder for a future saved-overrides path.