diff --git a/bin_efo/src/main.rs b/bin_efo/src/main.rs index 8122c30..f6087b1 100644 --- a/bin_efo/src/main.rs +++ b/bin_efo/src/main.rs @@ -24,6 +24,8 @@ #![deny(clippy::unwrap_used)] use clap::{ArgAction, Parser, Subcommand}; +use lib_efo::Displayable; +use lib_efo::entity::Entity; use crate::commands::init::InitCmd; use crate::{commands::epoch::cli_epoch::EpochCmd, error::AppError}; @@ -75,12 +77,12 @@ enum TopLevelCmd { fn main() -> miette::Result<()> { env_logger::init(); - // let e = Entity::default(); - // println!("{e:#?}"); - // println!("{}", e.oneline_display()); - // e.print_short(); - // e.print_full(); - // println!("{}", e.to_pretty_tree()); + let e = Entity::default(); + println!("{e:#?}"); + println!("{}", e.oneline_display()); + e.print_short(); + e.print_full(); + println!("{}", e.to_pretty_tree()); let cli = Cli::parse(); if let Err(e) = exec_dispatch(cli) { diff --git a/lib_efo/src/entity/implementations.rs b/lib_efo/src/entity/implementations.rs index 053a500..6381a44 100644 --- a/lib_efo/src/entity/implementations.rs +++ b/lib_efo/src/entity/implementations.rs @@ -66,12 +66,14 @@ impl Entity { /// Just show a pretty tree pub fn to_pretty_tree(&self) -> String { // Helper that indents a line - let indent = |level: usize, s: &str| -> String { format!("{}{}", " |".repeat(level), s) }; + let indent = |level: usize, s: &str| -> String { + format!(" {}{}", "│ ".repeat(level.saturating_sub(1)), s) + }; let mut out = String::new(); - out.push_str(&indent(0, "self\n")); - out.push_str(&indent(1, &format!("├─ name: {}\n", self.name))); + // out.push_str(&indent(0, "self\n")); + out.push_str(&indent(0, &format!("name: {}\n", self.name))); out.push_str(&indent(1, "├─ metadata\n")); out.push_str(&indent( 2, diff --git a/lib_efo/src/stats.rs b/lib_efo/src/stats.rs index 3f82e7a..cf40bfc 100644 --- a/lib_efo/src/stats.rs +++ b/lib_efo/src/stats.rs @@ -12,6 +12,7 @@ #![allow(dead_code)] #![deny(clippy::missing_docs_in_private_items)] +use cli_table::Color; use cli_table::Table; use colored::Colorize; use derive_more::Display; @@ -35,12 +36,14 @@ pub struct OverallStats { /// **Purpose** - A single value summarizing all economic indicators. /// **Effect** - Drives tax revenue, spending power, and overall economic influence. /// **Source** - Sum of `industry`, `science`, `trade`, and other economic contributors. + #[table(title = "DEM", color = "Color::Blue", bold)] pub demographics: GenericStat, /// Population count. /// /// **Purpose** - The number of citizens living in the entity. /// **Effect** - Determines resource consumption, tax base, and potential unrest. /// **Source** - Updated by the growth/decay formulas each turn. + #[table(title = "POP")] pub population: GenericStat, /// Per-turn change in population. @@ -48,6 +51,7 @@ pub struct OverallStats { /// **Purpose** - The growth rate of the population. /// **Effect** - Predicts future needs and signals potential social unrest. /// **Source** - Derived from `population`, `happiness`, and `stability`. + #[table(title = "GRW")] pub growth_rate: GenericStat, /// Crime level (0-1 scale). @@ -55,6 +59,7 @@ pub struct OverallStats { /// **Purpose** - How frequently crimes occur. /// **Effect** - Can trigger riots and reduce stability. /// **Source** - Result of the crime function (influenced by class disparity and law enforcement). + #[table(title = "CRM")] pub crime: GenericStat, /// Base happiness of the population (0-1 scale). @@ -62,6 +67,7 @@ pub struct OverallStats { /// **Purpose** - A measure of citizen contentment. /// **Effect** - Influences productivity, tax compliance, and unrest. /// **Source** - Output of the happiness function (affected by class, war, infrastructure). + #[table(title = "HPY")] pub happiness: GenericStat, // ──────────────────────── Economy ──────────────────────── @@ -70,6 +76,7 @@ pub struct OverallStats { /// **Purpose** - A single value summarizing all economic metrics. /// **Effect** - Drives revenue, spending, and empire-wide economic influence. /// **Source** - Sum of `food`, `industry`, `science`, `trade`, etc. + #[table(title = "ECO", color = "Color::Blue", bold)] pub economy: GenericStat, /// Food produced by the entity. @@ -77,6 +84,7 @@ pub struct OverallStats { /// **Purpose** - Amount of consumable resources available. /// **Effect** - Keeps the population alive and productive. /// **Source** - `food = farm_yield + tech_level`. + #[table(title = "FOD")] pub food: GenericStat, /// Strength of the industry. @@ -84,6 +92,7 @@ pub struct OverallStats { /// **Purpose** - Industrial production capacity. /// **Effect** - Drives tax revenue and unit production. /// **Source** - `industry = factory_output + tech_level`. + #[table(title = "IND")] pub industry: GenericStat, /// Scientific output. @@ -91,6 +100,7 @@ pub struct OverallStats { /// **Purpose** - Rate of research progress. /// **Effect** - Determines how quickly new technologies are unlocked. /// **Source** - `science = research_center_output + tech_level`. + #[table(title = "SCI")] pub science: GenericStat, /// Trade volume / exports. @@ -98,6 +108,7 @@ pub struct OverallStats { /// **Purpose** - Measure of export activity. /// **Effect** - Influences influence and wealth. /// **Source** - `trade = trade_network_output`. + #[table(title = "TRD")] pub trade: GenericStat, // // ──────────────────────── Social ──────────────────────── // /// Overall social prestige. @@ -105,6 +116,7 @@ pub struct OverallStats { // /// **Purpose** - Reflects the cultural standing of the entity. // /// **Effect** - Affects diplomacy and citizen morale. // /// **Source** - Sum of `culture`, `education`, `tourism`, etc. + // #[table(title = "SOC", color = "Color::Blue", bold)] // pub social: GenericStat, // /// Cultural output from arts, theatres, museums, etc. @@ -112,6 +124,7 @@ pub struct OverallStats { // /// **Purpose** - Measure of cultural production. // /// **Effect** - Drives tourism, prestige, and happiness. // /// **Source** - `culture = Σ(cultural_building_output)`. + // #[table(title = "CLU")] // pub culture: GenericStat, // /// Level of education/literacy. @@ -119,6 +132,7 @@ pub struct OverallStats { // /// **Purpose** - Measure of the citizenry's knowledge. // /// **Effect** - Improves productivity, science output, and reduces unrest. // /// **Source** - `education = Σ(education_building_output)`. + // #[table(title = "EDU")] // pub education: GenericStat, // /// Tourism revenue. @@ -126,6 +140,7 @@ pub struct OverallStats { // /// **Purpose** - Income generated by visitors. // /// **Effect** - Provides an additional income stream. // /// **Source** - `tourism = number_of_tourists x price_per_tourist`. + // #[table(title = "TOR")] // pub tourism: GenericStat, // /// Cultural influence over the region. @@ -133,6 +148,7 @@ pub struct OverallStats { // /// **Purpose** - Measure of soft power. // /// **Effect** - Grants diplomatic bonuses and increases sway in the empire. // /// **Source** - `influence = culture x population`. + // #[table(title = "INF")] // pub influence: GenericStat, // ──────────────────────── Military ──────────────────────── @@ -141,6 +157,7 @@ pub struct OverallStats { /// **Purpose** - Composite measure of combat capability. /// **Effect** - Determines defensive and offensive strength. /// **Source** - Sum of `army`, `strength`, `fortification`, etc. + #[table(title = "MIL", color = "Color::Blue", bold)] pub military: GenericStat, /// Number of battle-ready units. @@ -148,6 +165,7 @@ pub struct OverallStats { /// **Purpose** - Size of the active army. /// **Effect** - Directly dictates defense and attack potential. /// **Source** - Sum of all trained and equipped units. + #[table(title = "ARM")] pub army: GenericStat, /// Composite strength of the army. @@ -155,6 +173,7 @@ pub struct OverallStats { /// **Purpose** - Tech, training, and equipment bonuses aggregated. /// **Effect** - Determines combat effectiveness and required force to defeat an enemy. /// **Source** - `strength = Σ(unit_strength) x tech_bonus x training_bonus`. + #[table(title = "STR")] pub strength: GenericStat, /// Defensive bonus from fortifications. @@ -162,6 +181,7 @@ pub struct OverallStats { /// **Purpose** - Wall and tower defenses. /// **Effect** - Adds a multiplier to overall defense. /// **Source** - `fortification = Σ(fortification_building_bonus)`. + #[table(title = "FRT")] pub fortification: GenericStat, /// Threat level facing the entity. @@ -169,6 +189,7 @@ pub struct OverallStats { /// **Purpose** - Likelihood of being attacked. /// **Effect** - Triggers early warning alerts and strategic decisions. /// **Source** - `threat = (enemy_proximity + enemy_strength) / defense`. + #[table(title = "THR")] pub threat: GenericStat, // ──────────────────────── Infrastructure ──────────────────────── @@ -177,6 +198,7 @@ pub struct OverallStats { /// **Purpose** - Overall built-environment capacity. /// **Effect** - Supports population size and efficiency. /// **Source** - Sum of all infrastructure components. + #[table(title = "IFR", color = "Color::Blue", bold)] pub infrastructure: GenericStat, /// Bureaucratic power. @@ -184,6 +206,7 @@ pub struct OverallStats { /// **Purpose** - Efficiency of the city's administrative machinery. /// **Effect** - Improves resource management and policy implementation. /// **Source** - `bureaucracy = Σ(bureaucracy_building_output)`. + #[table(title = "BUR")] pub bureaucracy: GenericStat, /// Transportation level. @@ -191,6 +214,7 @@ pub struct OverallStats { /// **Purpose** - Availability and quality of transport infrastructure. /// **Effect** - Impacts logistics, mobility, and trade. /// **Source** - `transportation = Σ(transport_building_output)`. + #[table(title = "TRP")] pub transportation: GenericStat, /// Sprawl / urban density. @@ -198,6 +222,7 @@ pub struct OverallStats { /// **Purpose** - Measure of city sprawl and clutter. /// **Effect** - Affects health, happiness, and infrastructure efficiency. /// **Source** - `sprawl = Σ(sprawl_factor)`. + #[table(title = "SPR")] pub sprawl: GenericStat, /// Health infrastructure quality. @@ -205,6 +230,7 @@ pub struct OverallStats { /// **Purpose** - Public health capacity. /// **Effect** - Affects population health and can generate unrest. /// **Source** - `health = output_of_health_function` (influenced by sanitation, disease spread, etc.). + #[table(title = "HLT")] pub health: GenericStat, }