diff --git a/crates/config/src/fast_tables.rs b/crates/config/src/fast_tables.rs new file mode 100644 index 0000000..c9bdd86 --- /dev/null +++ b/crates/config/src/fast_tables.rs @@ -0,0 +1,57 @@ +//! # `fast_table` Configuration +//! +//! This module defines the command‑line configuration used by the **fast‑tables** +//! tool. The struct `FastTableConfig` is a thin wrapper around the `clap` +//! `Args` derive macro, which automatically turns the struct into a CLI +//! parser. All public fields are exposed to the user via command‑line flags +//! (or environment variables) and are documented below. +//! + +use clap::{Args, ValueEnum}; + +/// Configuration for the `fast‑tables` command. +/// +/// This struct is passed directly to `clap::Command::new` when creating the +/// CLI. Each field corresponds to a CLI flag; the attribute annotations +/// control how `clap` renders help text and parses values. +/// +#[derive(Args, Debug, Clone)] +pub struct FastTableConfig { + /// Target table type to generate or operate on. + #[arg()] + pub target: TableTargetType, + + /// Optional path to the destination directory for the generated tables. + #[arg(short, long)] + pub destination: Option, + + /// Optional path to an existing configuration file. + /// If omitted, a new config will be created with default values. + #[arg(short, long)] + pub config: Option, + + /// Simple string filter applied to class names. + /// Empty string matches all classes. + #[arg(long)] + pub filter: String, +} + +/// Enumerated set of table target types. +/// +/// This enum implements `ValueEnum`, which gives it two important traits: +/// * It can be used directly as a `clap` argument type. +/// * It can be parsed from a string (`"classes"`, `"alchemy"`, etc.) in a +/// case‑insensitive manner. +#[derive(ValueEnum, Debug, Clone)] +pub enum TableTargetType { + /// Classes table + Classes, + /// Alchemy table + Alchemy, + /// Brewry table + Brewry, + /// All crafting tables + AllCraft, + /// All tables + All, +} diff --git a/crates/config/src/graph.rs b/crates/config/src/graph.rs index 060e996..e57cde7 100644 --- a/crates/config/src/graph.rs +++ b/crates/config/src/graph.rs @@ -70,12 +70,3 @@ impl From<&str> for GraphTargetType { } } } - -// #[cfg(test)] -// mod tests { -// use super::*; - -// #[test] -// fn it_works() {} -// } -// diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 94b3c35..c0be66a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -7,6 +7,7 @@ #![warn(missing_docs, clippy::missing_docs_in_private_items)] // Internal Modules +pub mod fast_tables; pub mod graph; pub mod make; pub mod statsolver; diff --git a/crates/fast_class/Cargo.toml b/crates/fast_class/Cargo.toml index 3be632b..b11a1e0 100644 --- a/crates/fast_class/Cargo.toml +++ b/crates/fast_class/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" edition = "2024" [dependencies] +facet = "0.42.0" diff --git a/crates/fast_class/src/lib.rs b/crates/fast_class/src/lib.rs index 131a32a..d33de83 100644 --- a/crates/fast_class/src/lib.rs +++ b/crates/fast_class/src/lib.rs @@ -1,15 +1,135 @@ +//! # 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 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, +} + +/// 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, +} + +/// 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, + /// List of costs required to activate the skill. + pub cost: Vec, + /// 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; +} + /// r[bulk.export] pub fn add(left: u64, right: u64) -> u64 { left + right } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +// Subcommands: +// dashboard [classes, alchemy, cooking, forge] --filter name=Archer +// export [classes, ] --filter name=Archer +// graph [classes, alch] --filter +//