Skip to main content

State reference

nexBash.state is the read-only data surface. Each read builds a fresh, deeply frozen plain object from the live runtime owners — it is "safe to inspect and stringify", not a place to write flags and not a hot-path read.

if (nexBash.state.combat.hasTarget) {
// react to the current snapshot
}

The hot combat decision path does not read state; it reads a per-tick decision context built directly over the live owners (see the decision model). state exists for the config UI, debug overlays, logging, and integrations.

Branches

BranchValueContents
state.systemobjectversion, enabled (a run is live).
state.areaobjectActive area id, name, and targetThreshold.
state.strategyobjectActive class strategy id (null on an unsupported class).
state.combatobjecthasTarget, the active target ({ id, name } or null), and targetCount.
state.sessionobjectPer-run scoreboard: kills, gold, elapsedMs (all 0 when no run is active).
state.effectsobjectTransient bashing-effect availability: bloodcloak, maya, deathcape.
state.battlerageobjectbalance (on battlerage balance) plus the configured shieldBuffer, ccBuffer, generalBuffer reserves.
state.optionsobjectA copy of the live player option flags.

Example shape

{
system: { version: "1.0.0", enabled: true },
area: { id: 137, name: "Tuar", targetThreshold: 5 },
strategy: { id: "magi" },
combat: { hasTarget: true, target: { id: 4821, name: "a tuar warrior" }, targetCount: 3 },
session: { kills: 18, gold: 2400, elapsedMs: 305000 },
effects: { bloodcloak: false, maya: false, deathcape: true },
battlerage: { balance: true, shieldBuffer: 17, ccBuffer: 35, generalBuffer: 48 },
options: { rageToRaze: true, swapOnShield: true, skipNonPartyRooms: true, useMorimbuul: false, logging: false, notices: true }
}

Serialization contract

The complete state tree is JSON-serializable and contains no function values:

const report = JSON.parse(JSON.stringify(nexBash.state));

This is the preferred shape for debug captures and bug reports. The snapshot is deeply frozen; call a method under nexBash.api to request a change.

Fresh reads

A captured branch does not update in place — every property access on nexBash.state builds a new snapshot. Read the branch again after a transition:

const before = nexBash.state.combat;
// combat progresses…
const after = nexBash.state.combat;

Use events when an integration needs to know when to re-read.

Convenience accessors

A few live values are also exposed directly on the global for quick reads (these return live references, not frozen copies — treat them as read-only):

AccessorReturns
nexBash.targetThe active target instance, or the NO_TARGET projection.
nexBash.targetsThe live list of room combatants.
nexBash.hasTargetWhether an active target exists.
nexBash.areaThe active (cloned) Area instance.
nexBash.currentStrategyThe active class strategy object (null if unsupported).
nexBash.supportedClassesThe class ids nexBash ships a strategy for.