ravenous-tools/crates/fast_class/src/lib.rs

140 lines
4.7 KiB
Rust

//! # Class & Tool Utility
//!
//! This module defines the core data structures used for representing classes in the
//! game's balancing engine. Each class is a collection of metrics and a list of
//! skill tiers. The structures are intentionally lightweight and designed to be
//! serialisable with the `Facet` derive macro (used for JSON/YAML/CBOR export).
//!
//! The following concepts are modeled:
//!
//! * **`RavClass`** - The top-level representation of a playable class.
//! * **`Metrics`** - A set of performance indicators that can be used for
//! balancing decisions.
//! * **`SkillTier`** - A grouping of skills that are unlocked at a given level.
//! * **`Skill`** - An individual skill with its own cost, type, and effect
//! description.
//! * **`Cost`** - The resources required to cast a skill. The enum uses
//! `repr(C)` for ABI-compatibility with C-based tools.
//! * **`TType`** - A canonical representation of a skill's type (e.g. passive,
//! active, crowd-control). This enum is defined for readability but the
//! current `Skill::t_type` field uses raw `u8` values - see the note in
//! `Skill` for guidance on converting between the two.
//!
//! The module is free of external dependencies except for `facet`, which provides
//! the procedural macro used for deriving serialisation support.
use anyhow::Result;
use cli_parser::Config;
use config::fast_tables::FastTableConfig;
use facet::Facet;
/// Represents a playable class in the game.
///
/// A `RavClass` contains the public metadata of a class (name, image, description),
/// a set of *metrics* that quantify its strengths and weaknesses, and a list of
/// `SkillTier`s that hold the actual abilities.
///
/// The metrics are interpreted as scores between `0.0` and `5.0`. They are used
/// by the balancing engine to calculate power-level, but the struct itself does
/// not enforce this range; callers must validate it if required.
#[derive(Facet, Debug, Clone, Default)]
pub struct RavClass {
/// Human-readable name of the class.
pub name: String,
/// Path or URL to the class icon.
pub image: String,
/// Short flavor description.
pub description: String,
/// Quantitative metrics used for balancing.
pub radar: Metrics,
/// Ordered list of skill tiers. Typically one tier per level.
pub techniques: Vec<SkillTier>,
}
/// Metrics that quantify a class's capabilities.
///
/// All fields are `f32` values that usually lie in the range `[0.0, 1.0]`. The
/// semantics of each metric are intentionally simple: higher values mean the
/// class is better at that aspect. The struct derives `Default` via `Facet`,
/// which sets every metric to `0.0`.
#[derive(Facet, Debug, Clone, Default)]
pub struct Metrics {
pub survivability: f32,
pub damage: f32,
pub mobility: f32,
pub alterations: f32,
pub support: f32,
pub crowd_control: f32,
pub quality_of_live: f32,
}
/// A grouping of skills unlocked at a particular level.
///
/// Each `SkillTier` contains a vector of `Skill`. The ordering of tiers matters
/// for progression; callers should keep the slice sorted by the level that the
/// tier unlocks.
#[derive(Facet, Debug, Clone, Default)]
pub struct SkillTier {
/// Skills available at the tier's level.
pub skills: Vec<Skill>,
}
/// A single skill that a class can use.
///
/// The struct is intentionally flexible: it stores the skill name, level,
/// type(s), cost(s), and an effect description. Some fields are stored as
/// primitive types to keep the data compact, but helper functions can
/// translate between those primitives and the more descriptive enums.
#[derive(Facet, Debug, Clone, Default)]
pub struct Skill {
/// The display name of the skill.
pub name: String,
/// The skill level (e.g. 1-10).
pub level: usize,
/// Raw type identifiers.
pub t_type: Vec<TType>,
/// List of costs required to activate the skill.
pub cost: Vec<Cost>,
/// Human-readable effect description.
pub effect: String,
}
/// The resource cost required to cast a skill.
#[derive(Facet, Debug, Clone, PartialEq, Eq)]
#[repr(C)]
pub enum Cost {
Energy(u8),
Blood(u8),
}
/// Canonical representation of a skill's type.
#[derive(Facet, Debug, Clone, PartialEq, Eq)]
#[repr(C)]
pub enum TType {
Passive,
Active,
Exclusive,
CC,
Grab,
Unique,
}
pub trait Exportable {
fn to_tex(&self) -> String;
}
pub trait Graphable {
fn to_graph(&self) -> String;
}
pub fn make_better_gen(args: &FastTableConfig, config: &Config) -> Result<()> {
let _ = args;
let _ = config;
todo!()
}
// Subcommands:
// dashboard [classes, alchemy, cooking, forge] --filter name=Archer
// export [classes, ] --filter name=Archer
// graph [classes, alch] --filter
//