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
impl Ruleset
Sourcepub fn from_ron(text: &str) -> Result<Self, LoadError>
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.
Sourcepub fn type_index(&self, name: &str) -> Option<usize>
pub fn type_index(&self, name: &str) -> Option<usize>
Intern a type name to its chart index, or None if not in types:.
Sourcepub fn stat_index(&self, name: &str) -> Option<usize>
pub fn stat_index(&self, name: &str) -> Option<usize>
Intern a stat name to its index, or None if not in stats:.
Sourcepub fn resource_index(&self, name: &str) -> Option<usize>
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).