Just config
This commit is contained in:
parent
d451b99a48
commit
4cf73ff243
|
|
@ -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<String>,
|
||||
|
||||
/// Optional path to an existing configuration file.
|
||||
/// If omitted, a new config will be created with default values.
|
||||
#[arg(short, long)]
|
||||
pub config: Option<String>,
|
||||
|
||||
/// 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,
|
||||
}
|
||||
|
|
@ -70,12 +70,3 @@ impl From<&str> for GraphTargetType {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::*;
|
||||
|
||||
// #[test]
|
||||
// fn it_works() {}
|
||||
// }
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
facet = "0.42.0"
|
||||
|
|
|
|||
|
|
@ -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<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;
|
||||
}
|
||||
|
||||
/// 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
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue