| Crates.io | zzstat |
| lib.rs | zzstat |
| version | 0.1.4 |
| created_at | 2025-12-31 14:03:12.150506+00 |
| updated_at | 2025-12-31 14:03:12.150506+00 |
| description | A deterministic, hardcode-free stat calculation engine designed for MMORPGs |
| homepage | |
| repository | https://github.com/singoesdeep/zzstat |
| max_upload_size | |
| id | 2014776 |
| size | 100,838 |
A deterministic, hardcode-free stat calculation engine designed for MMORPGs.
StatContextStats flow through a simple pipeline:
[StatSource] → [StatTransform] → [ResolvedStat]
Add to your Cargo.toml:
[dependencies]
zzstat = "0.1.0"
use zzstat::*;
use zzstat::source::ConstantSource;
use zzstat::transform::MultiplicativeTransform;
let mut resolver = StatResolver::new();
let hp_id = StatId::from_str("HP");
// Register sources (additive)
resolver.register_source(hp_id.clone(), Box::new(ConstantSource(100.0)));
resolver.register_source(hp_id.clone(), Box::new(ConstantSource(50.0)));
// Register transform
resolver.register_transform(hp_id.clone(), Box::new(MultiplicativeTransform::new(1.5)));
// Resolve
let context = StatContext::new();
let resolved = resolver.resolve(&hp_id, &context).unwrap();
assert_eq!(resolved.value, 225.0); // (100 + 50) * 1.5
The examples/ directory contains several example programs:
basic.rs - Basic stat resolution with sources and transformsdependencies.rs - Stats that depend on other statscomplex.rs - Complex character stat systemcycle_detection.rs - Error handling for circular dependenciescontext.rs - Using StatContext for conditional calculationsRun examples with:
cargo run --example basic
cargo run --example dependencies
cargo run --example complex
See examples/README.md for more details.
stat_id - Stat identifier typesource - Stat sources (produce base values)transform - Stat transforms (modify values)resolver - Main stat resolverresolved - Resolved stat resultscontext - Context for conditional calculationsgraph - Dependency graph managementerror - Error typesThis project is licensed under the MIT License. See LICENSE file for details.