Useful structs
This commit is contained in:
parent
529f90b93e
commit
1e0c6dfb53
|
|
@ -2,6 +2,7 @@
|
|||
// File: config/src/monsters.rs
|
||||
//! The inner config for monster module
|
||||
//!
|
||||
#![allow(dead_code)]
|
||||
|
||||
use clap::{Args, ValueEnum};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
//! (`MonsterConfig`) and delegates to the appropriate sub‑routine (clean, export or show).
|
||||
//!
|
||||
|
||||
pub mod monster_structs;
|
||||
|
||||
use anyhow::Result;
|
||||
use cli_parser::Config;
|
||||
use config::monsters::MonsterConfig;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
//! # Monster Structures
|
||||
//!
|
||||
//! The `monster_structs` crate defines the data model that represents a monster
|
||||
//! as it is loaded from the database. All structs are intentionally kept
|
||||
//!
|
||||
//! ## Overview
|
||||
//! ```text
|
||||
//! FullMonster → MonsterStats
|
||||
//! ↘ MonsterAttacks → Vec<MonsterSingleAttack>
|
||||
//! ↗ MonsterResistances → Vec<MonsterSingleResistance>
|
||||
//! ```
|
||||
//!
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// A monster ready for consumption by other modules.
|
||||
pub struct FullMonster {
|
||||
/// Unique identifier, derived when the monster is instantiated.
|
||||
pub id: usize,
|
||||
|
||||
/// Monster’s name.
|
||||
pub name: String,
|
||||
|
||||
/// Serialized stats directly copied from the database table.
|
||||
pub stats: MonsterStats,
|
||||
|
||||
/// Collection of attacks, wrapped in a helper that exposes useful functions.
|
||||
pub attacks: MonsterAttacks,
|
||||
|
||||
/// Collection of resistances, wrapped in a helper for convenient iteration.
|
||||
pub resistances: MonsterResistances,
|
||||
}
|
||||
|
||||
/// Raw stat values deserialized straight from the database.
|
||||
pub struct MonsterStats {}
|
||||
|
||||
/// A helper wrapper around all attacks belonging to a monster.
|
||||
///
|
||||
/// The inner vector holds individual attack rows (`MonsterSingleAttack`);
|
||||
/// helper methods on this struct (not shown here) can split or aggregate
|
||||
/// these rows into more ergonomic data structures.
|
||||
pub struct MonsterAttacks {
|
||||
/// All attack rows for the monster, as read from the database.
|
||||
pub attacks: Vec<MonsterSingleAttack>,
|
||||
}
|
||||
|
||||
/// A helper wrapper around all resistances belonging to a monster.
|
||||
///
|
||||
/// The inner vector contains `MonsterSingleResistance` entries; methods
|
||||
/// on this struct can provide iterators or lookup functions that are
|
||||
/// easier to consume than raw rows.
|
||||
pub struct MonsterResistances {
|
||||
/// All resistance rows for the monster, as read from the database.
|
||||
pub resistances: Vec<MonsterSingleResistance>,
|
||||
}
|
||||
|
||||
/// Represents a single row of resistance data for a monster.
|
||||
pub struct MonsterSingleResistance {}
|
||||
|
||||
/// Represents a single attack entry as deserialized from the database.
|
||||
pub struct MonsterSingleAttack {}
|
||||
Loading…
Reference in New Issue