Skip to main content

Ruleset

Struct Ruleset 

Source
pub struct Ruleset {
    pub stats: Vec<String>,
    pub types: Vec<TypeName>,
    pub resources: Vec<String>,
    pub type_chart: Vec<TypeChartEntry>,
    pub effects: Vec<EffectRecord>,
}
Expand description

A whole no-code ruleset (doc 11 §1). Flat table of effect records plus the shared types vocabulary and the optional type_chart relation (doc 12 §2).

Fields§

§stats: Vec<String>

The opaque stat names; the game’s RuleBindings maps these ↔ P::Stat. Order is the interned stat index.

§types: Vec<TypeName>

The opaque type names; index = interned chart index (doc 12 §3.2).

§resources: Vec<String>

The opaque resource names (MP / SP / mana — doc 13 §4). Order is the interned resource index, which the game’s RuleBindings maps ↔ the engine’s opaque resource id. Empty by default ⇒ no game declares a resource ⇒ the cost gate is inert.

§type_chart: Vec<TypeChartEntry>

The attacker-type → defender-type → [num, den] relation (doc 12 §2).

§effects: Vec<EffectRecord>

The effect records (moves / statuses / abilities / items / weather).

Implementations§

Source§

impl Ruleset

Source

pub fn from_ron(text: &str) -> Result<Self, LoadError>

Parse a rules.ron text into a Ruleset. Pure deserialization; the closed-vocabulary binding (events, types, stats) happens in crate::CompiledRuleset::compile.

The implicit_some RON extension is enabled so authors write the ergonomic chance:[30,100] / unless:HasType("Rock") (doc 11 §1) rather than the verbose Some(...). This affects parsing only; it adds no entropy and no nondeterminism.

Source

pub fn type_index(&self, name: &str) -> Option<usize>

Intern a type name to its chart index, or None if not in types:.

Source

pub fn stat_index(&self, name: &str) -> Option<usize>

Intern a stat name to its index, or None if not in stats:.

Source

pub fn resource_index(&self, name: &str) -> Option<usize>

Intern a resource name to its index, or None if not in resources: (the MP/SP/mana cost gate, doc 13 §4).

Trait Implementations§

Source§

impl Clone for Ruleset

Source§

fn clone(&self) -> Ruleset

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 Ruleset

Source§

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

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

impl<'de> Deserialize<'de> for Ruleset

Source§

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

Deserialize this value from the given Serde deserializer. Read more

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.