AbstractConstruct an empty entity owned by parent — shorthand for
new X({}, { parent }). The second argument must be absent.
The Logic that owns the entity.
Construct a new SohlEntity instance from persisted state. Subclasses call
super(data, options) first, then rehydrate their own fields from data.
Persisted state for the instance; every field is optional and
defaulted (the base reads none of it — the kind tag is derived, not
supplied). Subclasses interpret it per their own Data interface.
Construction options; options.parent (the owning Logic)
is required.
The serialization discriminator for this instance — the concrete class's static Kind. Written into the JSON by toJSON under the kind key and read back by sohl.utils.defaultFromJSON to select the constructor. Derived from the class, never stored per-instance.
Deep-copy this entity, re-parenting the copy under parent with no other
changes. Shorthand for clone({}, { parent }).
The Logic to own the cloned entity.
The cloned entity.
Deep-copy this entity, optionally overriding fields and clone options.
Field overrides applied to the clone.
Clone options (e.g. a new parent).
The cloned entity.
Serialize this instance to a plain object suitable for JSON serialization.
A plain object representing this instance, consistent with the
Data interface of the subclass.
The base emits only the kind tag. A subclass that adds state
overrides this, chaining ...super.toJSON(), and emits keys matching its
own Data interface in persisted form (a uuid/shortcode where the live
object holds a resolved reference). The governing rule: toJSON() output
must be valid data for the constructor. The transient parent is
deliberately not emitted — it is re-supplied on revival.
Abstract base class for all SoHL domain entities — test/combat results (sohl.entity.result.SuccessTestResult, sohl.entity.result.AttackResult, …), modifiers (sohl.entity.modifier.ValueModifier, …), strike modes, and dice. It establishes the shapes and machinery every entity shares: a constructor-input Data bag, an Options bag carrying the owning
parent, thekinddiscriminator, and thetoJSON/ clone round-trip used by sohl.utils.defaultToJSON / sohl.utils.defaultFromJSON.Two invariants every subclass inherits:
parentLogic is required and transient. The constructor throws withoutoptions.parent;parentis never serialized (it is not emitted by toJSON) and is re-supplied on revival. This is the "reference on the wire, live object in memory" rule — see the Entity serialization contract in the Runtime Contracts reference.Kindidentifies the concrete class for revival. Each subclass overrides the static Kind with a unique string and self-registers it (registerKind(X.Kind, X)); without that, sohl.utils.defaultFromJSON leaves the serialized form as inert data instead of reviving the concrete class.