diff --git a/Cargo.lock b/Cargo.lock index ff5f783..43dc96f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,6 +202,15 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "colored" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "csv" version = "1.4.0" @@ -359,6 +368,7 @@ version = "0.1.0" dependencies = [ "clap", "cli-table", + "colored", "derive_more", "env_logger", "log", @@ -805,13 +815,22 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets", + "windows-targets 0.53.5", ] [[package]] @@ -823,6 +842,22 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + [[package]] name = "windows-targets" version = "0.53.5" @@ -830,58 +865,106 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ "windows-link", - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_aarch64_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + [[package]] name = "windows_i686_gnu" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_i686_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnu" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "windows_x86_64_msvc" version = "0.53.1" diff --git a/lib_efo/Cargo.toml b/lib_efo/Cargo.toml index 291afa5..99817c4 100644 --- a/lib_efo/Cargo.toml +++ b/lib_efo/Cargo.toml @@ -14,3 +14,4 @@ log = {workspace = true} derive_more = {workspace = true} cli-table = "0.5.0" uuid = { version = "1.18.1", features = ["serde", "v4"] } +colored = "3.0.0" diff --git a/lib_efo/src/error.rs b/lib_efo/src/error.rs index d0ad190..f03e8ee 100644 --- a/lib_efo/src/error.rs +++ b/lib_efo/src/error.rs @@ -203,6 +203,16 @@ pub enum EpochError { #[diagnostic(code(EpochError::Unknown))] Unknown(String), + /// The user tried to parse an acronim that doen't match any stats known to the system. + #[error("Unknown stat acronym: {0}")] + #[diagnostic(code(EpochError::UnknownStatAcronim))] + UnknownStatAcronim(String), + + /// The user gave a stat:identifier pair that was incorrect + #[error("Expected a stat and a number, got: {0}")] + #[diagnostic(code(EpochError::IllFormedStatQualifier))] + IllFormedStatQualifier(String), + /// User error, meant to be very explicit over what happened and what to do. #[error("An user facing error")] #[diagnostic(code(EpochError::UserError))] diff --git a/lib_efo/src/stats.rs b/lib_efo/src/stats.rs index 0cd8903..7e5ad13 100644 --- a/lib_efo/src/stats.rs +++ b/lib_efo/src/stats.rs @@ -1,450 +1,351 @@ -//! Module holing all stats and methods to use them +//! Module that holds all statistics for an entity and the helper methods that operate on them. +//! +//! The statistics are grouped into thematic sections (Demographics, Economy, Social, Military, +//! Infrastructure). Each field is a `GenericStat`, an internal wrapper around a numeric value +//! that provides convenience methods such as `max()`, `clamp()`, and arithmetic ops. +//! +//! The documentation for each field follows the same three‑part template: +//! * **Purpose** – What the stat represents. +//! * **Effect** – Gameplay consequence of the stat. +//! * **Source** – Formula or function that generates the stat value. #![allow(dead_code)] +#![deny(clippy::missing_docs_in_private_items)] +use cli_table::Table; +use colored::Colorize; +use derive_more::Display; +use serde::{Deserialize, Serialize}; use uuid::Uuid; mod implementations; -/// Statistics that describe the population of a city and its social climate. +/// Aggregated statistics for a single entity. /// -/// The struct is split into four logical groups: -/// * **Core metrics** – values that change every turn and drive the city’s behaviour. -/// * **Derived metrics** – calculated from the core metrics and other game data. -/// * **Hidden metrics** – internal state that influences derived values but is not exposed directly to the player. -/// * **Resource & skill metrics** – affect production and the city’s efficiency. -/// -/// All statistics are represented by custom wrappers (`PrimaryStat`, `InferredStat`, …) to keep -/// type‑safety and to indicate how they are normally updated. -struct Demographics { - // ──────────────────────────────────────────────────────────────────────────────── - // 1. Core metrics – the “raw” population data - // ──────────────────────────────────────────────────────────────────────────────── - /// Population count +/// The struct is intentionally flat to keep access fast; the fields are logically grouped +/// by comment blocks that describe each thematic section. +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +// Derive more +#[derive(Table)] +// #[derive(Add, Sub)] +struct OverallStats { + // ──────────────────────── Demographics ──────────────────────── + /// Total economic health of the entity. /// - /// *Effect*: Drives resource consumption and output capacity. - /// *Source*: Updated by the growth/decay formulas each turn. - population: PrimaryStat, + /// **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. + 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. + pub population: GenericStat, - /// Growth rate of the population (per‑turn change). + /// Per‑turn change in population. /// - /// *Effect*: Forecasts future needs and indicates potential unrest. - /// *Source*: Derivative of `population`, `happiness`, and `stability`. - growth_rate: PrimaryStat, + /// **Purpose** – The growth rate of the population. + /// **Effect** – Predicts future needs and signals potential social unrest. + /// **Source** – Derived from `population`, `happiness`, and `stability`. + pub growth_rate: GenericStat, - /// Crime level of the city. + /// Crime level (0–1 scale). /// - /// *Effect*: Can trigger riots and lower stability. - /// *Source*: Result of the crime function (often influenced by class disparity and law enforcement). - crime: PrimaryStat, + /// **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). + pub crime: GenericStat, - /// Overall health of the population. + /// Base happiness of the population (0–1 scale). /// - /// *Effect*: Affects population size and can generate unrest. - /// *Source*: Output of the health function (influenced by sanitation, disease spread, etc.). - health: PrimaryStat, + /// **Purpose** – A measure of citizen contentment. + /// **Effect** – Influences productivity, tax compliance, and unrest. + /// **Source** – Output of the happiness function (affected by class, war, infrastructure). + pub happiness: GenericStat, - /// Base skill of the populace (e.g., general craftsmanship). + // ──────────────────────── Economy ──────────────────────── + /// Aggregate economic health of the entity. /// - /// *Effect*: Determines how efficiently the city can produce goods. - /// *Source*: Global slider set by the player; may be modified by education or tech bonuses. - skill: PrimaryStat, + /// **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. + pub economy: GenericStat, - // ──────────────────────────────────────────────────────────────────────────────── - // 2. Derived metrics – calculated from the core data - // ──────────────────────────────────────────────────────────────────────────────── - /// Overall “demographics” score. + /// Food produced by the entity. /// - /// *Effect*: Used as a weighting factor for major random events (e.g., disasters, hero visits). - /// *Source*: Inferred from the primary metrics, with a heavy emphasis on `population` and `unrest`. - demographics: InferredStat, + /// **Purpose** – Amount of consumable resources available. + /// **Effect** – Keeps the population alive and productive. + /// **Source** – `food = farm_yield + tech_level`. + pub food: GenericStat, - /// Expected consumption of resources. + /// Strength of the industry. /// - /// *Effect*: Drives the city’s production targets and food/water needs. - /// *Source*: `consumption = f(population, class distribution, technology level)`. - consumption: InferredStat, + /// **Purpose** – Industrial production capacity. + /// **Effect** – Drives tax revenue and unit production. + /// **Source** – `industry = factory_output + tech_level`. + pub industry: GenericStat, - /// Level of social unrest. + /// Scientific output. /// - /// *Effect*: Predicts riots, rebellions, tax evasion, and other disruptive behaviour. - /// *Source*: `unrest = f(happiness, crime, war, stability)`. - unrest: InferredStat, + /// **Purpose** – Rate of research progress. + /// **Effect** – Determines how quickly new technologies are unlocked. + /// **Source** – `science = research_center_output + tech_level`. + pub science: GenericStat, - // ──────────────────────────────────────────────────────────────────────────────── - // 3. Hidden metrics – internal state not directly exposed - // ──────────────────────────────────────────────────────────────────────────────── - /// Base happiness of the population (internal scale). + /// Trade volume / exports. /// - /// *Effect*: Influences productivity, tax compliance, and the calculation of `unrest`. - /// *Source*: Output of the happiness function (affected by class, war, and infrastructure). - happiness: HiddenStat, + /// **Purpose** – Measure of export activity. + /// **Effect** – Influences influence and wealth. + /// **Source** – `trade = trade_network_output`. + pub trade: GenericStat, + // // ──────────────────────── Social ──────────────────────── + // /// Overall social prestige. + // /// + // /// **Purpose** – Reflects the cultural standing of the entity. + // /// **Effect** – Affects diplomacy and citizen morale. + // /// **Source** – Sum of `culture`, `education`, `tourism`, etc. + // pub social: GenericStat, - /// Base level of fear among citizens (internal scale). - /// - /// *Effect*: Contributes to `unrest`, crime, and population growth rate. - /// *Source*: Result of monster encounters, external threats, and environmental hazards. - fear: HiddenStat, -} -/// Statistics that describe the city’s economic health and its impact on the empire. -/// -/// The fields are divided into three groups: -/// * **Core metrics** – the raw values that the player can control or that the engine updates. -/// * **Derived metrics** – numbers calculated from the core metrics (often the ones displayed to the player). -/// * **Hidden metrics** – internal helpers that drive the derived values but are not exposed to the UI. -struct Economics { - // ──────────────────────────────────────── - // 1. Core metrics – raw, player‑controlled values - // ──────────────────────────────────────── - /// Amount of food produced by the city. - /// - /// *Effect*: Food is required to keep the population alive and productive. - /// *Source*: `food = farm_yield + tech_level`. - food: PrimaryStat, + // /// Cultural output from arts, theatres, museums, etc. + // /// + // /// **Purpose** – Measure of cultural production. + // /// **Effect** – Drives tourism, prestige, and happiness. + // /// **Source** – `culture = Σ(cultural_building_output)`. + // pub culture: GenericStat, - /// Strength of the city’s industry. - /// - /// *Effect*: Drives tax revenue and the ability to produce units. - /// *Source*: `industry = factory_output + tech_level`. - industry: PrimaryStat, + // /// Level of education/literacy. + // /// + // /// **Purpose** – Measure of the citizenry’s knowledge. + // /// **Effect** – Improves productivity, science output, and reduces unrest. + // /// **Source** – `education = Σ(education_building_output)`. + // pub education: GenericStat, - /// Scientific output of the city. - /// - /// *Effect*: Determines how fast research is completed. - /// *Source*: `science = research_center_output + tech_level`. - science: PrimaryStat, + // /// Tourism revenue. + // /// + // /// **Purpose** – Income generated by visitors. + // /// **Effect** – Provides an additional income stream. + // /// **Source** – `tourism = number_of_tourists × price_per_tourist`. + // pub tourism: GenericStat, - /// Revenue collected through taxation. - /// - /// *Effect*: Funds city upkeep and projects. - /// *Source*: `tax = tax_rate × wealth × (1 – evasion)`. - tax: PrimaryStat, + // /// Cultural influence over the region. + // /// + // /// **Purpose** – Measure of soft power. + // /// **Effect** – Grants diplomatic bonuses and increases sway in the empire. + // /// **Source** – `influence = culture × population`. + // pub influence: GenericStat, - /// Debt / budget deficit of the city. + // ──────────────────────── Military ──────────────────────── + /// Overall military power. /// - /// *Effect*: Affects stability and population growth. - /// *Source*: Result of budget calculations; naturally decays if `eco_power` stays high. - debt: PrimaryStat, + /// **Purpose** – Composite measure of combat capability. + /// **Effect** – Determines defensive and offensive strength. + /// **Source** – Sum of `army`, `strength`, `fortification`, etc. + pub military: GenericStat, - /// Trade volume / exports generated by the city. + /// Number of battle‑ready units. /// - /// *Effect*: Influences influence and wealth. - /// *Source*: `trade = trade_network_output`. - trade: PrimaryStat, + /// **Purpose** – Size of the active army. + /// **Effect** – Directly dictates defense and attack potential. + /// **Source** – Sum of all trained and equipped units. + pub army: GenericStat, - // ──────────────────────────────────────── - // 2. Derived metrics – calculated from core data - // ──────────────────────────────────────── - /// Overall economic power of the city. + /// Composite strength of the army. /// - /// *Effect*: Used to rank the city’s importance within the empire. - /// *Source*: `eco_power = wealth × stability × influence`. - eco_power: InferredStat, + /// **Purpose** – Tech, training, and equipment bonuses aggregated. + /// **Effect** – Determines combat effectiveness and required force to defeat an enemy. + /// **Source** – `strength = Σ(unit_strength) × tech_bonus × training_bonus`. + pub strength: GenericStat, - /// Net monetary output – the city’s “wealth” or GDP. + /// Defensive bonus from fortifications. /// - /// *Effect*: Determines the city’s overall financial health. - /// *Source*: `wealth = tax + trade + industry_profits`. - wealth: InferredStat, + /// **Purpose** – Wall and tower defenses. + /// **Effect** – Adds a multiplier to overall defense. + /// **Source** – `fortification = Σ(fortification_building_bonus)`. + pub fortification: GenericStat, - // ──────────────────────────────────────── - // 3. Hidden metrics – internal helpers - // ──────────────────────────────────────── - /// Cost of maintaining the city’s infrastructure. + /// Threat level facing the entity. /// - /// *Effect*: Drain on the budget (reduces available funds for projects). - /// *Source*: `infra_cost = cost_of_wonders + cost_of_roads + ...`. - infra_cost: InferredStat, -} -/// Statistics that govern the city’s cultural life and its influence on the empire. -/// -/// The fields are grouped into: -/// * **Core metrics** – the raw outputs that the player can build into. -/// * **Derived metrics** – values calculated from the core metrics (often the ones displayed to the player). -/// * **Hidden metrics** – internal helpers that help derive the derived values (none in this struct, but the pattern is kept for consistency). -struct Social { - // ───────────────────────────────────────────────────────────── - // 1. Core metrics – directly produced by the city - // ───────────────────────────────────────────────────────────── - /// Cultural output from arts, theatres, museums, etc. - /// - /// *Effect*: Drives tourism, prestige, and overall happiness. - /// *Source*: `culture = Σ(cultural_building_output)`. - culture: PrimaryStat, + /// **Purpose** – Likelihood of being attacked. + /// **Effect** – Triggers early warning alerts and strategic decisions. + /// **Source** – `threat = (enemy_proximity + enemy_strength) / defense`. + pub threat: GenericStat, - /// Religious influence from temples, churches, etc. + // ──────────────────────── Infrastructure ──────────────────────── + /// Total infrastructure power. /// - /// *Effect*: Affects stability and political influence. - /// *Source*: `religion = Σ(religious_building_output)`. - religion: PrimaryStat, + /// **Purpose** – Overall built‑environment capacity. + /// **Effect** – Supports population size and efficiency. + /// **Source** – Sum of all infrastructure components. + pub infrastructure: GenericStat, - /// Level of education/literacy in the city. + /// Bureaucratic power. /// - /// *Effect*: Improves productivity, science output, and reduces unrest. - /// *Source*: `education = Σ(education_building_output)`. - education: PrimaryStat, + /// **Purpose** – Efficiency of the city’s administrative machinery. + /// **Effect** – Improves resource management and policy implementation. + /// **Source** – `bureaucracy = Σ(bureaucracy_building_output)`. + pub bureaucracy: GenericStat, - // ───────────────────────────────────────────────────────────── - // 2. Derived metrics – calculated from core data - // ───────────────────────────────────────────────────────────── - /// Tourism revenue generated by the city’s attractions. + /// Transportation level. /// - /// *Effect*: Provides an additional income stream. - /// *Source*: `tourism = number_of_tourists × price_per_tourist`. - tourism: PrimaryStat, + /// **Purpose** – Availability and quality of transport infrastructure. + /// **Effect** – Impacts logistics, mobility, and trade. + /// **Source** – `transportation = Σ(transport_building_output)`. + pub transportation: GenericStat, - /// Overall social prestige of the city. + /// Sprawl / urban density. /// - /// *Effect*: Determines the city’s standing in the empire and in diplomatic relations. - /// *Source*: `social = f(culture, religion, education, influence)` (the exact formula is hidden but inferred from the other values). - social: InferredStat, + /// **Purpose** – Measure of city sprawl and clutter. + /// **Effect** – Affects health, happiness, and infrastructure efficiency. + /// **Source** – `sprawl = Σ(sprawl_factor)`. + pub sprawl: GenericStat, - /// Cultural influence over the surrounding region. + /// Health infrastructure quality. /// - /// *Effect*: Increases the city’s sway in the empire and can grant diplomatic bonuses. - /// *Source*: `influence = culture × population`. - influence: InferredStat, + /// **Purpose** – Public health capacity. + /// **Effect** – Affects population health and can generate unrest. + /// **Source** – `health = output_of_health_function` (influenced by sanitation, disease spread, etc.). + pub health: GenericStat, } -/// Statistics that describe a city’s armed forces and its battlefield posture. +/// Strategic context and meta‑data for an entity. /// -/// The fields are split into two logical groups: -/// * **Core metrics** – raw numbers that the player can influence with units, training, or infrastructure. -/// * **Derived metrics** – values calculated each turn from the core metrics (the ones most players will see). -/// -/// All stats use wrapper types (`PrimaryStat`, `InferredStat`) so that the compiler can enforce -/// that only the correct kinds of values are combined in formulas. -struct Military { - // ───────────────────────────────────────────────── - // 1. Core metrics – the raw, game‑state numbers - // ───────────────────────────────────────────────── - /// Number of battle‑ready units (size, type, equipment, etc.). +/// All fields are intentionally simple – the logic that interprets them +/// lives in separate modules (e.g. `map`, `network`, `governance`). +#[derive(Debug, Clone, Default)] +pub struct Strategics { + // ──── Location & Spatial Data (hidden) ─────────────────────────────── + /// Cartesian coordinates of the entity on the world map. /// - /// *Effect*: Determines the city’s direct defensive and offensive capability. - /// *Source*: Sum of all units in the army list that are trained and equipped. - army: PrimaryStat, + /// **Purpose** – Position of the entity in the simulation grid. + /// **Effect** – Used for distance calculations, visibility, and + /// map‑based event logic. + /// **Source** – Supplied by the map generator. + pub position: (usize, usize), - /// Composite strength of the army (tech, training, equipment). + /// Euclidean distance to the empire’s capital (in tile units). /// - /// *Effect*: Adds to combat power in battles and determines the required force to defeat the enemy. - /// *Source*: `strength = Σ(unit_strength) × tech_bonus × training_bonus`. - strength: PrimaryStat, - - /// Readiness/morale of the forces. - /// - /// *Effect*: Modifies the actual combat effectiveness in battles. - /// *Source*: Output of the morale function, which may depend on recent victories, supply levels, etc. - readiness: PrimaryStat, - - /// Defensive bonus from fortifications (walls, towers, etc.). - /// - /// *Effect*: Adds a defensive multiplier to the city’s overall defense rating. - /// *Source*: `fortification = Σ(fortification_building_bonus)`. - fortification: PrimaryStat, - - /// Strategic importance of the city’s location. - /// - /// *Effect*: Influences enemy targeting decisions and the city’s priority for defense upgrades. - /// *Source*: `strategic_value = f(proximity_to_borders, resource_nodes, transport_hubs)`. - strategic_value: PrimaryStat, - - // ───────────────────────────────────────────────── - // 2. Derived metrics – calculated from the core data - // ───────────────────────────────────────────────── - /// Overall threat level facing the city. - /// - /// *Effect*: Predicts the likelihood of being attacked and can trigger early warning alerts. - /// *Source*: `threat = (enemy_proximity + enemy_strength) / defense`. - threat: InferredStat, - - // ───────────────────────────────────────────────── - // 3. Main combined metric – the city’s total military power - // ───────────────────────────────────────────────── - /// Combined military power used for empire‑wide rankings and event weighting. - /// - /// *Effect*: The “size” of the city’s armed forces in the eyes of the empire. - /// *Source*: `military = f(army, strength, readiness, fortification, strategic_value)`. - military: InferredStat, -} -/// Statistics that describe a city’s built environment and its ability to support the population. -/// -/// The fields are separated into two logical groups: -/// * **Core infrastructure** – the raw assets the player builds and upgrades. -/// * **Derived infrastructure** – numbers calculated each turn from the core assets (the ones you’ll see in the UI). -/// -/// All stats use the wrapper types (`PrimaryStat`, `InferredStat`) so that the compiler can -/// keep the formulas type‑safe and easy to reason about. -struct Infrastructure { - // ─────────────────────────────────────────────────────────── - // 1. Core infrastructure – the raw, player‑controlled values - // ─────────────────────────────────────────────────────── - /// Communication network strength. - /// - /// *Effect*: Enables espionage, real‑time resource monitoring, and can unlock advanced building upgrades. - /// *Source*: `communications = Σ(communication_building_bonus)`. - communications: PrimaryStat, - - /// Total water and electricity supply capacity. - /// - /// *Effect*: Required for industry output and maintaining population health. - /// *Source*: `needs = Σ(supply_unit_output)`. - needs: PrimaryStat, - - /// Total amount of waste / pollution produced by the city. - /// - /// *Effect*: Reduces health and happiness, can trigger unrest if too high. - /// *Source*: `pollution = Σ(building_pollution)`. - pollution: PrimaryStat, - - /// Available building slots (housing, industry, etc.). - /// - /// *Effect*: Caps how many new structures can be added until more slots are built. - /// *Source*: `space = Σ(slot_building_capacity)`. - space: PrimaryStat, - - // ─────────────────────────────────────────────────────────── - // 2. Derived infrastructure – calculated from core data - // ─────────────────────────────────────────────────────── - /// Overall connectivity of the city (roads, rails, ports, etc.). - /// - /// *Effect*: Drives trade volume, military supply lines, and logistics efficiency. - /// *Source*: `connectivity = Σ(link_strength)`. - connectivity: InferredStat, - - /// Total infrastructure power of the city. - /// - /// *Effect*: Used to rank the city’s importance within the empire and to calculate event weights. - /// *Source*: `infrastructure = f(connectivity, communications, needs, pollution, space)`. - infrastructure: InferredStat, -} - -/// Strategic context and meta‑data for a city. -/// -/// The struct is divided into three logical parts: -/// * **Location & spatial data** – hidden values that feed map‑based calculations. -/// * **Strategic positioning** – meta‑information that determines specialization, trade, and defense. -/// * **Political & relational data** – things that influence diplomacy, governance, and inter‑city links. -/// -/// All fields use the wrapper types (`HiddenStat`, `PrimaryStat`, `InferredStat`) so the compiler -/// can enforce that only the correct kinds of values are combined in formulas. -struct Strategics { - // ──────────────────────────────────────── - // 1. Location & spatial data (hidden) - // ──────────────────────────────────────── - /// Cartesian coordinates of the city on the world map. - /// - /// *Effect*: Used for distance calculations, visibility, and map‑based event logic. - /// *Source*: Raw coordinates supplied by the map generator. - position: HiddenStat, - - /// Euclidean distance to the empire’s capital. - /// - /// *Effect*: Influences trade costs, supply line strength, and early warning range. - /// *Source*: `distance_to_capital = dist(position, capital_position)`. - distance_to_capital: HiddenStat, + /// **Purpose** – Metric of remoteness from the political centre. + /// **Effect** – Influences trade costs, supply‑line strength, + /// and the range of early‑warning signals. + /// **Source** – `distance_to_capital = dist(position, capital_position)`. + pub distance_to_capital: usize, /// List of nearby resource nodes (mines, forests, farms, etc.). /// - /// *Effect*: Drives the city’s specialization and determines the default output mix. - /// *Source*: `ressources = filter(resource_list, distance ≤ detection_radius)`. - ressources: HiddenStat, + /// **Purpose** – Resource map around the entity. + /// **Effect** – Drives the entity’s specialization and determines + /// the default output mix. + /// **Source** – `resources = filter(resource_list, distance ≤ detection_radius)`. + pub resources: Vec, - /// The city’s chosen specialization tag (e.g., “Agricultural Hub”, “Industrial Center”). + /// The entity’s chosen specialization tag + /// (e.g., “Agricultural Hub”, “Industrial Center”). /// - /// *Effect*: Sets the default output multipliers for production. - /// *Source*: `specialisation = tag_assigned_by_player_or_ai`. - specialisation: HiddenStat, + /// **Purpose** – Identity that dictates default production multipliers. + /// **Effect** – Alters output curves and trade attractiveness. + /// **Source** – `specialization = tag_assigned_by_player_or_ai`. + pub specialization: String, - // ──────────────────────────────────────── - // 2. Strategic positioning (hidden + public) - // ──────────────────────────────────────── - /// Current governor or leader assigned to the city. + // ──── Strategic Positioning (hidden + public) ───────────────────── + /// Current governor or leader assigned to the entity. /// - /// *Effect*: Adds personal bonuses and can modify policies or diplomatic stance. - /// *Source*: `governor = selected_leader_uuid`. - governor: Uuid, + /// **Purpose** – Leadership identity. + /// **Effect** – Adds personal bonuses and may modify policies + /// or diplomatic stance. + /// **Source** – `governor = selected_leader_uuid`. + pub governor: Uuid, - /// The city’s classification (capital, trade hub, frontier post, etc.). + /// The entity’s classification (capital, trade hub, frontier post, etc.). /// - /// *Effect*: Alters base production, tax rates, and certain event probabilities. - /// *Source*: `category = tag_assigned_by_player_or_ai`. - category: PrimaryStat, + /// **Purpose** – Functional role within the empire. + /// **Effect** – Alters base production, tax rates, and + /// certain event probabilities. + /// **Source** – `role = tag_assigned_by_player_or_ai`. + pub role: String, - /// The faction or empire to which the city currently belongs. + /// The faction or empire to which the entity currently belongs. /// - /// *Effect*: Determines diplomatic relations, war status, and access to empire‑wide bonuses. - /// *Source*: `faction = current_faction_uuid`. - faction: Uuid, + /// **Purpose** – Political affiliation. + /// **Effect** – Determines diplomatic relations, war status, + /// and access to empire‑wide bonuses. + /// **Source** – `faction = current_faction_uuid`. + pub faction: Uuid, - // ──────────────────────────────────────── - // 3. Links & relational data - // ──────────────────────────────────────── - /// UIDs of all entities the city is linked to (roads, trade routes, alliances, war declarations, etc.). + /// UIDs of all entities the entity is linked to (roads, trade routes, + /// alliances, war declarations, etc.). /// - /// *Effect*: Influences economic, military, and diplomatic interactions. - /// *Source*: `links = Vec` collected from the city’s network manager. - links: Vec, + /// **Purpose** – Connectivity network. + /// **Effect** – Influences economic, military, and diplomatic + /// interactions. + /// **Source** – `links = Vec` collected from the entity’s + /// network manager. + pub links: Vec, - // ──────────────────────────────────────── - // 4. Meta‑statistics (derived) - // ──────────────────────────────────────── - /// Prestige / reputation of the city in the eyes of the empire and foreign powers. + /// Prestige / reputation of the entity in the eyes of the empire + /// and foreign powers. /// - /// *Effect*: Affects foreign relations, diplomatic offers, and event weighting. - /// *Source*: `prestige = f(culture, trade, military)`. - prestige: InferredStat, + /// **Purpose** – Social standing metric. + /// **Effect** – Affects diplomatic influence, trade bonuses, + /// and event outcomes. + /// **Source** – `prestige = calculate_prestige(...)`. + pub prestige: usize, } -// --- STAT TYPES --------------------------------------------------------------- -// The game distinguishes four kinds of statistics. -// The *visibility* of a stat determines whether it is shown to the player -// (Primary / Inferred) and whether the player can change it manually -// (Primary / Hidden). -// -// All four stat structs simply wrap a signed integer, but they all -// implement the same behaviour via the `GameStat` trait below. +/// A summary of the stats, only for display purposes +#[allow(clippy::missing_docs_in_private_items)] +#[derive(Table)] +pub struct SummaryStats { + #[table(title = "Demo")] + demographics: GenericStat, + #[table(title = "Eco")] + economy: GenericStat, + // #[table(title = "Social")] + // social: GenericStat, + #[table(title = "Milit")] + military: GenericStat, + #[table(title = "Infra")] + infrastructure: GenericStat, +} +/// Bridge between the CLI and the statistics logic. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[allow(missing_docs)] +pub enum ListStats { + Demographics, + Population, + Growthrate, + Crime, + Happiness, + Economy, + Food, + Industry, + Science, + Trade, + Social, + Culture, + Education, + Tourism, + Influence, + Military, + Army, + Strength, + Fortification, + Threat, + Infrastructure, + Bureaucracy, + Transportation, + Sprawl, + Health, +} + +// fn print_generic_stat() /// A stat that is shown to the player *and* can be modified manually. #[allow(missing_docs)] -pub struct PrimaryStat { +#[derive(Debug, Clone, Default, Serialize, Deserialize, Display)] +pub struct GenericStat { pub value: isize, } -/// A stat that is hidden from the recap UI, but still user‑editable. -#[allow(missing_docs)] -pub struct HiddenStat { - pub value: isize, -} - -/// A stat that is calculated from other data, shown to the player, -/// but not directly editable. -#[allow(missing_docs)] -pub struct InferredStat { - pub value: isize, -} - -/// A stat that is calculated from other data and hidden from the UI. -#[allow(missing_docs)] -pub struct HiddenInferredStat { - pub value: isize, -} - -// --- VISIBILITY ENUM ------------------------------------------------------------ - -/// The underlying visibility level for a stat. -/// The enum is used by `GameStat::visibility` to let the UI decide -/// whether to display a particular stat or not. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum VisibilityLevel { - /// Primary stat – shown & editable. - Primary, - /// Hidden stat – not shown, editable. - Hidden, - /// Inferred stat – shown, calculated. - Inferred, - /// Hidden inferred stat – not shown, calculated. - HiddenInferred, -} - /// --- TRAITS --------------------------------------------------------------- /// A stat is a *game value* that can be converted to two different /// normalised ranges – a 50‑point range for “gaming” logic and a @@ -461,12 +362,19 @@ pub trait GameStat { self.to_50() / 5 } + /// As a colored delta (when the stat is used as a delta) + fn to_delta(&self) -> String { + let get_value = self.get_value(); + if get_value < 0 { + format!("{}", get_value.to_string().red()) + } else { + format!("{}", get_value.to_string().green()) + } + } + /// Return the raw integer value, always bound to 0-70 fn get_value(&self) -> isize; - /// Return the stat’s visibility level. - fn visibility(&self) -> VisibilityLevel; - /// Return the raw integer value, always bound to 0-70 fn change_value(&mut self, value: isize); @@ -475,6 +383,7 @@ pub trait GameStat { where Self: Sized; } + /// Trait for objects that can expose a stat via a string key. /// The trait returns a *boxed* trait object so callers do not need to know /// the concrete type that was stored. @@ -483,3 +392,8 @@ pub trait Accessible { /// `None` if the key does not exist. fn get_val(&self, key: &str) -> Option>; } + +// pub trait Displayable { +// fn summary(&self) -> String; +// fn full_description(&self) -> String; +// } diff --git a/lib_efo/src/stats/implementations.rs b/lib_efo/src/stats/implementations.rs index 156d3e3..508cfd2 100644 --- a/lib_efo/src/stats/implementations.rs +++ b/lib_efo/src/stats/implementations.rs @@ -1,10 +1,13 @@ //! All traits implementatition for the main structs are deffered here -use crate::stats::VisibilityLevel; -use crate::stats::{ - Demographics, Economics, GameStat, HiddenInferredStat, HiddenStat, InferredStat, - Infrastructure, Military, PrimaryStat, Social, -}; +use std::str::FromStr; + +use crate::error::EpochError; +use crate::stats; +use crate::stats::GameStat; +use crate::stats::GenericStat; +use crate::stats::ListStats; +use crate::stats::OverallStats; /// Generates an `impl GameStat for ` where the only difference between /// multiple implementations is the visibility level. @@ -13,16 +16,12 @@ use crate::stats::{ /// * `$type`: the concrete type that implements `GameStat` /// * `$vis`: the enum variant of `VisibilityLevel` to return macro_rules! impl_game_stat { - ($type:ident, $vis:ident) => { + ($type:ident) => { impl GameStat for $type { fn get_value(&self) -> isize { self.value } - fn visibility(&self) -> VisibilityLevel { - VisibilityLevel::$vis - } - fn change_value(&mut self, value: isize) { self.value = value; } @@ -37,11 +36,6 @@ macro_rules! impl_game_stat { }; } -impl_game_stat!(PrimaryStat, Primary); -impl_game_stat!(HiddenStat, Hidden); -impl_game_stat!(InferredStat, Inferred); -impl_game_stat!(HiddenInferredStat, HiddenInferred); - /// A field accessor to be able to modify fields on the fly macro_rules! field_accessor { ($name:ident { $($field:ident),* }) => { @@ -67,87 +61,158 @@ macro_rules! field_accessor { }; } -field_accessor!(Demographics { +impl_game_stat!(GenericStat); +field_accessor!(OverallStats { + demographics, population, growth_rate, crime, - health, - skill, - demographics, - consumption, - unrest, happiness, - fear -}); -field_accessor!(Economics { + economy, food, industry, science, - tax, - debt, trade, - eco_power, - wealth, - infra_cost -}); -field_accessor!(Social { - culture, - religion, - education, - tourism, - social, - influence -}); - -field_accessor!(Military { + // social, + // culture, + // education, + // tourism, + // influence, + military, army, strength, - readiness, fortification, - strategic_value, threat, - military + infrastructure, + bureaucracy, + transportation, + sprawl, + health }); -field_accessor!(Infrastructure { - communications, - needs, - pollution, - space, - connectivity, - infrastructure -}); -// field_accessor!(Strategics { -// position, -// distance_to_capital, -// ressources, -// specialisation, -// governor, -// category, -// faction, -// links, -// prestige -// }); + +impl FromStr for ListStats { + type Err = EpochError; + + /// Convert an acronym (e.g. `"cri"`) into the corresponding enum variant. + fn from_str(s: &str) -> Result { + match s.to_ascii_lowercase().as_str() { + "dem" | "demog" | "demographics" | "demo" => Ok(ListStats::Demographics), + "pop" | "popul" | "populations" => Ok(ListStats::Population), + "grow" | "grw" | "growth" => Ok(ListStats::Growthrate), + "cri" | "crim" | "crimes" => Ok(ListStats::Crime), + "hapn" | "happines" | "hap" => Ok(ListStats::Happiness), + "eco" | "economy" | "econ" => Ok(ListStats::Economy), + "food" | "fo" | "agr" | "agri" => Ok(ListStats::Food), + "industry" | "indus" | "ind" => Ok(ListStats::Industry), + "science" | "sci" | "sc" => Ok(ListStats::Science), + "trade" | "trd" | "tr" => Ok(ListStats::Trade), + "social" | "soc" | "sl" => Ok(ListStats::Social), + "culture" | "cul" | "cl" => Ok(ListStats::Culture), + "education" | "edu" | "ed" => Ok(ListStats::Education), + "tourism" | "tour" | "tm" => Ok(ListStats::Tourism), + "influence" | "infl" | "influ" => Ok(ListStats::Influence), + "military" | "mil" | "mt" => Ok(ListStats::Military), + "army" | "arm" | "ar" => Ok(ListStats::Army), + "strength" | "str" | "st" => Ok(ListStats::Strength), + "fortification" | "fort" | "ft" => Ok(ListStats::Fortification), + "threat" | "thr" | "th" => Ok(ListStats::Threat), + "infrastructure" | "infra" | "infr" => Ok(ListStats::Infrastructure), + "bureaucracy" | "bureau" | "bur" => Ok(ListStats::Bureaucracy), + "transportation" | "trans" | "trns" => Ok(ListStats::Transportation), + "sprawl" | "spr" | "spra" => Ok(ListStats::Sprawl), + "health" | "hlth" | "hlt" => Ok(ListStats::Health), + _ => Err(EpochError::UnknownStatAcronim(s.to_owned())), + } + } +} + +impl From for &str { + fn from(value: ListStats) -> Self { + match value { + ListStats::Demographics => "demographics", + ListStats::Population => "population", + ListStats::Growthrate => "growthrate", + ListStats::Crime => "crime", + ListStats::Happiness => "happiness", + ListStats::Economy => "economy", + ListStats::Food => "food", + ListStats::Industry => "industry", + ListStats::Science => "science", + ListStats::Trade => "trade", + ListStats::Social => "social", + ListStats::Culture => "culture", + ListStats::Education => "education", + ListStats::Tourism => "tourism", + ListStats::Influence => "influence", + ListStats::Military => "military", + ListStats::Army => "army", + ListStats::Strength => "strength", + ListStats::Fortification => "fortification", + ListStats::Threat => "threat", + ListStats::Infrastructure => "infrastructure", + ListStats::Bureaucracy => "bureaucracy", + ListStats::Transportation => "transportation", + ListStats::Sprawl => "sprawl", + ListStats::Health => "health", + } + } +} + +/// A generic stat pair with (stat, value), used mainly for clap +/// Accepts two forms +/// 1. "cri 10" (two separate tokens) +/// 2. "cri:10" (one token with a separator) +pub struct StatPair(ListStats, GenericStat); +impl FromStr for StatPair { + type Err = EpochError; + + fn from_str(s: &str) -> Result { + let (stat_str, val_str) = if let Some(idx) = s.find(':') { + (&s[..idx], &s[idx + 1..]) + } else { + let parts: Vec<&str> = s.split_whitespace().collect(); + if parts.len() != 2 { + return Err(EpochError::IllFormedStatQualifier(s.to_owned())); + } + (parts[0], parts[1]) + }; + + let stat: ListStats = stat_str.parse()?; + let value: isize = val_str + .parse() + .map_err(|_| EpochError::IllFormedStatQualifier(val_str.to_owned()))?; + Ok(StatPair(stat, stats::GenericStat { value })) + } +} #[cfg(test)] pub(crate) mod test { #![allow(clippy::unwrap_used)] + use super::*; use crate::stats::GameStat; - use crate::stats::PrimaryStat; + use crate::stats::GenericStat; + use std::str::FromStr; struct Person { - name: PrimaryStat, - age: PrimaryStat, - email: PrimaryStat, + name: GenericStat, + age: GenericStat, + email: GenericStat, + } + + /// Helper that asserts that a string parses to the expected ListStats variant. + fn assert_stat_ok(input: &str, expected: ListStats) { + let parsed = ListStats::from_str(input).expect("should parse"); + assert_eq!(parsed, expected, "input `{}` parsed incorrectly", input); } field_accessor!(Person { name, age, email }); #[test] - fn bob() { + fn test_field_accessors() { let person = Person { - name: PrimaryStat { value: 10 }, - age: PrimaryStat { value: 20 }, - email: PrimaryStat { value: 70 }, + name: GenericStat { value: 10 }, + age: GenericStat { value: 20 }, + email: GenericStat { value: 70 }, }; let name = person.get_field("name").unwrap(); let email = person.get_field("email").unwrap(); @@ -156,4 +221,179 @@ pub(crate) mod test { assert_eq!(age.to_50(), 10); assert_eq!(email.to_50(), 50); } + + #[test] + fn test_clap_serialisation() {} + /// Helper that asserts that a stat pair string parses to the expected `StatPair`. + fn assert_pair_ok(input: &str, expected_stat: ListStats, expected_val: isize) { + let pair = StatPair::from_str(input).expect("should parse"); + assert_eq!(pair.0, expected_stat, "stat mismatch"); + assert_eq!(pair.1.value, expected_val, "value mismatch"); + } + #[test] + fn test_stat_pair_parsing() { + // Colon syntax + assert_pair_ok("cri:10", ListStats::Crime, 10); + assert_pair_ok("POP:-5", ListStats::Population, -5); + assert_pair_ok("growth:0", ListStats::Growthrate, 0); + + // Space syntax (clap concatenates two separate args into one string) + assert_pair_ok("cri 10", ListStats::Crime, 10); + assert_pair_ok("Pop -5", ListStats::Population, -5); + assert_pair_ok("grow 0", ListStats::Growthrate, 0); + } + #[test] + fn test_list_stats_all_aliases() { + let stats = OverallStats::default(); + // Demographics + assert_stat_ok("dem", ListStats::Demographics); + assert_stat_ok("Demog", ListStats::Demographics); + assert_stat_ok("DEMOGRAPHICS", ListStats::Demographics); + assert_stat_ok("Demo", ListStats::Demographics); + stats.get_field(ListStats::Demographics.into()); + // Population + assert_stat_ok("pop", ListStats::Population); + assert_stat_ok("Popul", ListStats::Population); + assert_stat_ok("POPULATIONS", ListStats::Population); + stats.get_field(ListStats::Population.into()); + + // Growthrate + assert_stat_ok("grow", ListStats::Growthrate); + assert_stat_ok("GRW", ListStats::Growthrate); + assert_stat_ok("Growth", ListStats::Growthrate); + stats.get_field(ListStats::Growthrate.into()); + + // Crime + assert_stat_ok("cri", ListStats::Crime); + assert_stat_ok("CRIM", ListStats::Crime); + assert_stat_ok("Crimes", ListStats::Crime); + stats.get_field(ListStats::Crime.into()); + + // Happiness + assert_stat_ok("hapn", ListStats::Happiness); + assert_stat_ok("HAPPINES", ListStats::Happiness); + assert_stat_ok("hap", ListStats::Happiness); + stats.get_field(ListStats::Happiness.into()); + + // Economy + assert_stat_ok("eco", ListStats::Economy); + assert_stat_ok("Economy", ListStats::Economy); + assert_stat_ok("econ", ListStats::Economy); + stats.get_field(ListStats::Economy.into()); + + // Food + assert_stat_ok("food", ListStats::Food); + assert_stat_ok("fo", ListStats::Food); + assert_stat_ok("agr", ListStats::Food); + assert_stat_ok("agri", ListStats::Food); + stats.get_field(ListStats::Food.into()); + + // Industry + assert_stat_ok("industry", ListStats::Industry); + assert_stat_ok("Indus", ListStats::Industry); + assert_stat_ok("ind", ListStats::Industry); + stats.get_field(ListStats::Industry.into()); + + // Science + assert_stat_ok("science", ListStats::Science); + assert_stat_ok("sci", ListStats::Science); + assert_stat_ok("sc", ListStats::Science); + stats.get_field(ListStats::Science.into()); + + // Trade + assert_stat_ok("trade", ListStats::Trade); + assert_stat_ok("trd", ListStats::Trade); + assert_stat_ok("tr", ListStats::Trade); + stats.get_field(ListStats::Trade.into()); + + // Social + assert_stat_ok("social", ListStats::Social); + assert_stat_ok("soc", ListStats::Social); + assert_stat_ok("sl", ListStats::Social); + stats.get_field(ListStats::Social.into()); + + // Culture + assert_stat_ok("culture", ListStats::Culture); + assert_stat_ok("cul", ListStats::Culture); + assert_stat_ok("cl", ListStats::Culture); + stats.get_field(ListStats::Culture.into()); + + // Education + assert_stat_ok("education", ListStats::Education); + assert_stat_ok("edu", ListStats::Education); + assert_stat_ok("ed", ListStats::Education); + stats.get_field(ListStats::Education.into()); + + // Tourism + assert_stat_ok("tourism", ListStats::Tourism); + assert_stat_ok("tour", ListStats::Tourism); + assert_stat_ok("tm", ListStats::Tourism); + stats.get_field(ListStats::Tourism.into()); + + // Influence + assert_stat_ok("influence", ListStats::Influence); + assert_stat_ok("infl", ListStats::Influence); + assert_stat_ok("influ", ListStats::Influence); + stats.get_field(ListStats::Influence.into()); + + // Military + assert_stat_ok("military", ListStats::Military); + assert_stat_ok("mil", ListStats::Military); + assert_stat_ok("mt", ListStats::Military); + stats.get_field(ListStats::Military.into()); + + // Army + assert_stat_ok("army", ListStats::Army); + assert_stat_ok("arm", ListStats::Army); + assert_stat_ok("ar", ListStats::Army); + stats.get_field(ListStats::Army.into()); + + // Strength + assert_stat_ok("strength", ListStats::Strength); + assert_stat_ok("str", ListStats::Strength); + assert_stat_ok("st", ListStats::Strength); + stats.get_field(ListStats::Strength.into()); + + // Fortification + assert_stat_ok("fortification", ListStats::Fortification); + assert_stat_ok("fort", ListStats::Fortification); + assert_stat_ok("ft", ListStats::Fortification); + stats.get_field(ListStats::Fortification.into()); + + // Threat + assert_stat_ok("threat", ListStats::Threat); + assert_stat_ok("thr", ListStats::Threat); + assert_stat_ok("th", ListStats::Threat); + stats.get_field(ListStats::Threat.into()); + + // Infrastructure + assert_stat_ok("infrastructure", ListStats::Infrastructure); + assert_stat_ok("infra", ListStats::Infrastructure); + assert_stat_ok("infr", ListStats::Infrastructure); + stats.get_field(ListStats::Infrastructure.into()); + + // Bureaucracy + assert_stat_ok("bureaucracy", ListStats::Bureaucracy); + assert_stat_ok("bureau", ListStats::Bureaucracy); + assert_stat_ok("bur", ListStats::Bureaucracy); + stats.get_field(ListStats::Bureaucracy.into()); + + // Transportation + assert_stat_ok("transportation", ListStats::Transportation); + assert_stat_ok("trans", ListStats::Transportation); + assert_stat_ok("trns", ListStats::Transportation); + stats.get_field(ListStats::Transportation.into()); + + // Sprawl + assert_stat_ok("sprawl", ListStats::Sprawl); + assert_stat_ok("spr", ListStats::Sprawl); + assert_stat_ok("spra", ListStats::Sprawl); + stats.get_field(ListStats::Sprawl.into()); + + // Health + assert_stat_ok("health", ListStats::Health); + assert_stat_ok("hlth", ListStats::Health); + assert_stat_ok("hlt", ListStats::Health); + stats.get_field(ListStats::Health.into()); + } }