pub struct StateDecl {
pub id: StateId,
pub scope: StateScope,
pub initial: i32,
pub note: Option<String>,
pub name: Option<String>,
pub display: Option<StateDisplay>,
}Expand description
One declared runtime datum (DSL v0.10, spec-0031): a named, scoped, integer-valued counter.
This is what FlagId is not. A flag is boolean, party-wide and
monotonic — no verb clears one — which is exactly right for “this has
happened” and useless for a balance, a floor number, or “a ride is in
progress”. A datum clears, counts down as well as up, and states its scope.
Fields§
§id: StateIdUnique datum id (state/<kebab>).
scope: StateScopeWho holds the value. Required — see StateScope.
initial: i32The value the datum starts at, and the value clear-state returns it to.
Defaults to 0.
One field rather than a separate initial and cleared: “the value this
datum has when nothing has happened to it yet” is one fact, and two fields
would let a campaign declare a datum that can never be returned to its own
starting state.
note: Option<String>Free prose: what this datum means. Never machine-checked, never shown to a
player — the forcing function that makes an author say what the number is,
the same role cast[].doing plays.
name: Option<String>The player-visible name of this datum (DSL v0.10, spec-0032).
A named datum is a currency. There is no separate currencies section
and there deliberately is not: a purse is a runtime datum that the player
can see, and “the player can see it” is a property of the datum, not a
different object class. A second struct carrying id + scope +
initial + name would be a private copy of this one, which is the defect
CLAUDE.md names second.
Present ⇒ every set-state / add-state / clear-state on this datum
also states the new balance to whoever holds it, on the action bar, as
<name>: <value> with the value carried by vanilla’s own score
component. Absent ⇒ the datum is silent bookkeeping and emission is exactly
what it was.
Player-visible, so it is inventoried under state.<id>.name and
translated like any other authored line.
display: Option<StateDisplay>Where this datum stands on screen between changes (spec-0076).
The announcement name buys fades with the action bar; a datum that
declares display also occupies a vanilla display slot, so its balance is
on screen at every moment for every player. Declared, never automatic: a
creator may want a named tally that is spoken only when it moves, and the
engine does not decide which of two named datums is the purse.
Present ⇒ setup heads the datum’s objective with its translated name,
paints the value gold, and puts the objective in the slot. Requires name
(the slot’s heading is the display name, and without one it would show the
objective’s id) and a player scope (the sidebar hides #-prefixed
holders, which is what a party datum’s value lives on); one datum per
campaign may stand, because the slot holds one objective — all three are
DW0919. Absent ⇒ the datum announces itself and stands nowhere.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for StateDecl
impl<'de> Deserialize<'de> for StateDecl
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for StateDecl
impl JsonSchema for StateDecl
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more