Skip to main content

StateDecl

Struct StateDecl 

Source
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: StateId

Unique datum id (state/<kebab>).

§scope: StateScope

Who holds the value. Required — see StateScope.

§initial: i32

The 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 Clone for StateDecl

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StateDecl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for StateDecl

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for StateDecl

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for StateDecl

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for StateDecl

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for StateDecl

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.