pub struct StateDecl {
pub id: StateId,
pub scope: StateScope,
pub initial: i32,
pub note: Option<String>,
pub name: Option<String>,
}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.
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