Adds some stats implementations
This commit is contained in:
parent
debc59c02f
commit
087425f4e8
|
|
@ -202,6 +202,15 @@ version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
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]]
|
[[package]]
|
||||||
name = "csv"
|
name = "csv"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
|
@ -359,6 +368,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"cli-table",
|
"cli-table",
|
||||||
|
"colored",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -805,13 +815,22 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
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]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.60.2"
|
version = "0.60.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.53.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -823,6 +842,22 @@ dependencies = [
|
||||||
"windows-link",
|
"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]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.53.5"
|
version = "0.53.5"
|
||||||
|
|
@ -830,58 +865,106 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-link",
|
"windows-link",
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.53.1",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.53.1",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.53.1",
|
||||||
"windows_i686_gnullvm",
|
"windows_i686_gnullvm 0.53.1",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.53.1",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.53.1",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.53.1",
|
||||||
"windows_x86_64_msvc",
|
"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]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
|
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
|
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
|
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnullvm"
|
name = "windows_i686_gnullvm"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
|
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
|
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]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
|
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]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
|
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]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.53.1"
|
version = "0.53.1"
|
||||||
|
|
|
||||||
|
|
@ -14,3 +14,4 @@ log = {workspace = true}
|
||||||
derive_more = {workspace = true}
|
derive_more = {workspace = true}
|
||||||
cli-table = "0.5.0"
|
cli-table = "0.5.0"
|
||||||
uuid = { version = "1.18.1", features = ["serde", "v4"] }
|
uuid = { version = "1.18.1", features = ["serde", "v4"] }
|
||||||
|
colored = "3.0.0"
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,16 @@ pub enum EpochError {
|
||||||
#[diagnostic(code(EpochError::Unknown))]
|
#[diagnostic(code(EpochError::Unknown))]
|
||||||
Unknown(String),
|
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.
|
/// User error, meant to be very explicit over what happened and what to do.
|
||||||
#[error("An user facing error")]
|
#[error("An user facing error")]
|
||||||
#[diagnostic(code(EpochError::UserError))]
|
#[diagnostic(code(EpochError::UserError))]
|
||||||
|
|
|
||||||
|
|
@ -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)]
|
#![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;
|
use uuid::Uuid;
|
||||||
mod implementations;
|
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:
|
/// The struct is intentionally flat to keep access fast; the fields are logically grouped
|
||||||
/// * **Core metrics** – values that change every turn and drive the city’s behaviour.
|
/// by comment blocks that describe each thematic section.
|
||||||
/// * **Derived metrics** – calculated from the core metrics and other game data.
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
/// * **Hidden metrics** – internal state that influences derived values but is not exposed directly to the player.
|
// Derive more
|
||||||
/// * **Resource & skill metrics** – affect production and the city’s efficiency.
|
#[derive(Table)]
|
||||||
///
|
// #[derive(Add, Sub)]
|
||||||
/// All statistics are represented by custom wrappers (`PrimaryStat`, `InferredStat`, …) to keep
|
struct OverallStats {
|
||||||
/// type‑safety and to indicate how they are normally updated.
|
// ──────────────────────── Demographics ────────────────────────
|
||||||
struct Demographics {
|
/// Total economic health of the entity.
|
||||||
// ────────────────────────────────────────────────────────────────────────────────
|
|
||||||
// 1. Core metrics – the “raw” population data
|
|
||||||
// ────────────────────────────────────────────────────────────────────────────────
|
|
||||||
/// Population count
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Drives resource consumption and output capacity.
|
/// **Purpose** – A single value summarizing all economic indicators.
|
||||||
/// *Source*: Updated by the growth/decay formulas each turn.
|
/// **Effect** – Drives tax revenue, spending power, and overall economic influence.
|
||||||
population: PrimaryStat,
|
/// **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.
|
/// **Purpose** – The growth rate of the population.
|
||||||
/// *Source*: Derivative of `population`, `happiness`, and `stability`.
|
/// **Effect** – Predicts future needs and signals potential social unrest.
|
||||||
growth_rate: PrimaryStat,
|
/// **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.
|
/// **Purpose** – How frequently crimes occur.
|
||||||
/// *Source*: Result of the crime function (often influenced by class disparity and law enforcement).
|
/// **Effect** – Can trigger riots and reduce stability.
|
||||||
crime: PrimaryStat,
|
/// **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.
|
/// **Purpose** – A measure of citizen contentment.
|
||||||
/// *Source*: Output of the health function (influenced by sanitation, disease spread, etc.).
|
/// **Effect** – Influences productivity, tax compliance, and unrest.
|
||||||
health: PrimaryStat,
|
/// **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.
|
/// **Purpose** – A single value summarizing all economic metrics.
|
||||||
/// *Source*: Global slider set by the player; may be modified by education or tech bonuses.
|
/// **Effect** – Drives revenue, spending, and empire‑wide economic influence.
|
||||||
skill: PrimaryStat,
|
/// **Source** – Sum of `food`, `industry`, `science`, `trade`, etc.
|
||||||
|
pub economy: GenericStat,
|
||||||
|
|
||||||
// ────────────────────────────────────────────────────────────────────────────────
|
/// Food produced by the entity.
|
||||||
// 2. Derived metrics – calculated from the core data
|
|
||||||
// ────────────────────────────────────────────────────────────────────────────────
|
|
||||||
/// Overall “demographics” score.
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Used as a weighting factor for major random events (e.g., disasters, hero visits).
|
/// **Purpose** – Amount of consumable resources available.
|
||||||
/// *Source*: Inferred from the primary metrics, with a heavy emphasis on `population` and `unrest`.
|
/// **Effect** – Keeps the population alive and productive.
|
||||||
demographics: InferredStat,
|
/// **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.
|
/// **Purpose** – Industrial production capacity.
|
||||||
/// *Source*: `consumption = f(population, class distribution, technology level)`.
|
/// **Effect** – Drives tax revenue and unit production.
|
||||||
consumption: InferredStat,
|
/// **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.
|
/// **Purpose** – Rate of research progress.
|
||||||
/// *Source*: `unrest = f(happiness, crime, war, stability)`.
|
/// **Effect** – Determines how quickly new technologies are unlocked.
|
||||||
unrest: InferredStat,
|
/// **Source** – `science = research_center_output + tech_level`.
|
||||||
|
pub science: GenericStat,
|
||||||
|
|
||||||
// ────────────────────────────────────────────────────────────────────────────────
|
/// Trade volume / exports.
|
||||||
// 3. Hidden metrics – internal state not directly exposed
|
|
||||||
// ────────────────────────────────────────────────────────────────────────────────
|
|
||||||
/// Base happiness of the population (internal scale).
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Influences productivity, tax compliance, and the calculation of `unrest`.
|
/// **Purpose** – Measure of export activity.
|
||||||
/// *Source*: Output of the happiness function (affected by class, war, and infrastructure).
|
/// **Effect** – Influences influence and wealth.
|
||||||
happiness: HiddenStat,
|
/// **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).
|
// /// Cultural output from arts, theatres, museums, etc.
|
||||||
///
|
// ///
|
||||||
/// *Effect*: Contributes to `unrest`, crime, and population growth rate.
|
// /// **Purpose** – Measure of cultural production.
|
||||||
/// *Source*: Result of monster encounters, external threats, and environmental hazards.
|
// /// **Effect** – Drives tourism, prestige, and happiness.
|
||||||
fear: HiddenStat,
|
// /// **Source** – `culture = Σ(cultural_building_output)`.
|
||||||
}
|
// pub culture: GenericStat,
|
||||||
/// 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,
|
|
||||||
|
|
||||||
/// Strength of the city’s industry.
|
// /// Level of education/literacy.
|
||||||
///
|
// ///
|
||||||
/// *Effect*: Drives tax revenue and the ability to produce units.
|
// /// **Purpose** – Measure of the citizenry’s knowledge.
|
||||||
/// *Source*: `industry = factory_output + tech_level`.
|
// /// **Effect** – Improves productivity, science output, and reduces unrest.
|
||||||
industry: PrimaryStat,
|
// /// **Source** – `education = Σ(education_building_output)`.
|
||||||
|
// pub education: GenericStat,
|
||||||
|
|
||||||
/// Scientific output of the city.
|
// /// Tourism revenue.
|
||||||
///
|
// ///
|
||||||
/// *Effect*: Determines how fast research is completed.
|
// /// **Purpose** – Income generated by visitors.
|
||||||
/// *Source*: `science = research_center_output + tech_level`.
|
// /// **Effect** – Provides an additional income stream.
|
||||||
science: PrimaryStat,
|
// /// **Source** – `tourism = number_of_tourists × price_per_tourist`.
|
||||||
|
// pub tourism: GenericStat,
|
||||||
|
|
||||||
/// Revenue collected through taxation.
|
// /// Cultural influence over the region.
|
||||||
///
|
// ///
|
||||||
/// *Effect*: Funds city upkeep and projects.
|
// /// **Purpose** – Measure of soft power.
|
||||||
/// *Source*: `tax = tax_rate × wealth × (1 – evasion)`.
|
// /// **Effect** – Grants diplomatic bonuses and increases sway in the empire.
|
||||||
tax: PrimaryStat,
|
// /// **Source** – `influence = culture × population`.
|
||||||
|
// pub influence: GenericStat,
|
||||||
|
|
||||||
/// Debt / budget deficit of the city.
|
// ──────────────────────── Military ────────────────────────
|
||||||
|
/// Overall military power.
|
||||||
///
|
///
|
||||||
/// *Effect*: Affects stability and population growth.
|
/// **Purpose** – Composite measure of combat capability.
|
||||||
/// *Source*: Result of budget calculations; naturally decays if `eco_power` stays high.
|
/// **Effect** – Determines defensive and offensive strength.
|
||||||
debt: PrimaryStat,
|
/// **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.
|
/// **Purpose** – Size of the active army.
|
||||||
/// *Source*: `trade = trade_network_output`.
|
/// **Effect** – Directly dictates defense and attack potential.
|
||||||
trade: PrimaryStat,
|
/// **Source** – Sum of all trained and equipped units.
|
||||||
|
pub army: GenericStat,
|
||||||
|
|
||||||
// ────────────────────────────────────────
|
/// Composite strength of the army.
|
||||||
// 2. Derived metrics – calculated from core data
|
|
||||||
// ────────────────────────────────────────
|
|
||||||
/// Overall economic power of the city.
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Used to rank the city’s importance within the empire.
|
/// **Purpose** – Tech, training, and equipment bonuses aggregated.
|
||||||
/// *Source*: `eco_power = wealth × stability × influence`.
|
/// **Effect** – Determines combat effectiveness and required force to defeat an enemy.
|
||||||
eco_power: InferredStat,
|
/// **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.
|
/// **Purpose** – Wall and tower defenses.
|
||||||
/// *Source*: `wealth = tax + trade + industry_profits`.
|
/// **Effect** – Adds a multiplier to overall defense.
|
||||||
wealth: InferredStat,
|
/// **Source** – `fortification = Σ(fortification_building_bonus)`.
|
||||||
|
pub fortification: GenericStat,
|
||||||
|
|
||||||
// ────────────────────────────────────────
|
/// Threat level facing the entity.
|
||||||
// 3. Hidden metrics – internal helpers
|
|
||||||
// ────────────────────────────────────────
|
|
||||||
/// Cost of maintaining the city’s infrastructure.
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Drain on the budget (reduces available funds for projects).
|
/// **Purpose** – Likelihood of being attacked.
|
||||||
/// *Source*: `infra_cost = cost_of_wonders + cost_of_roads + ...`.
|
/// **Effect** – Triggers early warning alerts and strategic decisions.
|
||||||
infra_cost: InferredStat,
|
/// **Source** – `threat = (enemy_proximity + enemy_strength) / defense`.
|
||||||
}
|
pub threat: GenericStat,
|
||||||
/// 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,
|
|
||||||
|
|
||||||
/// Religious influence from temples, churches, etc.
|
// ──────────────────────── Infrastructure ────────────────────────
|
||||||
|
/// Total infrastructure power.
|
||||||
///
|
///
|
||||||
/// *Effect*: Affects stability and political influence.
|
/// **Purpose** – Overall built‑environment capacity.
|
||||||
/// *Source*: `religion = Σ(religious_building_output)`.
|
/// **Effect** – Supports population size and efficiency.
|
||||||
religion: PrimaryStat,
|
/// **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.
|
/// **Purpose** – Efficiency of the city’s administrative machinery.
|
||||||
/// *Source*: `education = Σ(education_building_output)`.
|
/// **Effect** – Improves resource management and policy implementation.
|
||||||
education: PrimaryStat,
|
/// **Source** – `bureaucracy = Σ(bureaucracy_building_output)`.
|
||||||
|
pub bureaucracy: GenericStat,
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
/// Transportation level.
|
||||||
// 2. Derived metrics – calculated from core data
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
/// Tourism revenue generated by the city’s attractions.
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Provides an additional income stream.
|
/// **Purpose** – Availability and quality of transport infrastructure.
|
||||||
/// *Source*: `tourism = number_of_tourists × price_per_tourist`.
|
/// **Effect** – Impacts logistics, mobility, and trade.
|
||||||
tourism: PrimaryStat,
|
/// **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.
|
/// **Purpose** – Measure of city sprawl and clutter.
|
||||||
/// *Source*: `social = f(culture, religion, education, influence)` (the exact formula is hidden but inferred from the other values).
|
/// **Effect** – Affects health, happiness, and infrastructure efficiency.
|
||||||
social: InferredStat,
|
/// **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.
|
/// **Purpose** – Public health capacity.
|
||||||
/// *Source*: `influence = culture × population`.
|
/// **Effect** – Affects population health and can generate unrest.
|
||||||
influence: InferredStat,
|
/// **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:
|
/// All fields are intentionally simple – the logic that interprets them
|
||||||
/// * **Core metrics** – raw numbers that the player can influence with units, training, or infrastructure.
|
/// lives in separate modules (e.g. `map`, `network`, `governance`).
|
||||||
/// * **Derived metrics** – values calculated each turn from the core metrics (the ones most players will see).
|
#[derive(Debug, Clone, Default)]
|
||||||
///
|
pub struct Strategics {
|
||||||
/// All stats use wrapper types (`PrimaryStat`, `InferredStat`) so that the compiler can enforce
|
// ──── Location & Spatial Data (hidden) ───────────────────────────────
|
||||||
/// that only the correct kinds of values are combined in formulas.
|
/// Cartesian coordinates of the entity on the world map.
|
||||||
struct Military {
|
|
||||||
// ─────────────────────────────────────────────────
|
|
||||||
// 1. Core metrics – the raw, game‑state numbers
|
|
||||||
// ─────────────────────────────────────────────────
|
|
||||||
/// Number of battle‑ready units (size, type, equipment, etc.).
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Determines the city’s direct defensive and offensive capability.
|
/// **Purpose** – Position of the entity in the simulation grid.
|
||||||
/// *Source*: Sum of all units in the army list that are trained and equipped.
|
/// **Effect** – Used for distance calculations, visibility, and
|
||||||
army: PrimaryStat,
|
/// 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.
|
/// **Purpose** – Metric of remoteness from the political centre.
|
||||||
/// *Source*: `strength = Σ(unit_strength) × tech_bonus × training_bonus`.
|
/// **Effect** – Influences trade costs, supply‑line strength,
|
||||||
strength: PrimaryStat,
|
/// and the range of early‑warning signals.
|
||||||
|
/// **Source** – `distance_to_capital = dist(position, capital_position)`.
|
||||||
/// Readiness/morale of the forces.
|
pub distance_to_capital: usize,
|
||||||
///
|
|
||||||
/// *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,
|
|
||||||
|
|
||||||
/// List of nearby resource nodes (mines, forests, farms, etc.).
|
/// List of nearby resource nodes (mines, forests, farms, etc.).
|
||||||
///
|
///
|
||||||
/// *Effect*: Drives the city’s specialization and determines the default output mix.
|
/// **Purpose** – Resource map around the entity.
|
||||||
/// *Source*: `ressources = filter(resource_list, distance ≤ detection_radius)`.
|
/// **Effect** – Drives the entity’s specialization and determines
|
||||||
ressources: HiddenStat,
|
/// the default output mix.
|
||||||
|
/// **Source** – `resources = filter(resource_list, distance ≤ detection_radius)`.
|
||||||
|
pub resources: Vec<String>,
|
||||||
|
|
||||||
/// 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.
|
/// **Purpose** – Identity that dictates default production multipliers.
|
||||||
/// *Source*: `specialisation = tag_assigned_by_player_or_ai`.
|
/// **Effect** – Alters output curves and trade attractiveness.
|
||||||
specialisation: HiddenStat,
|
/// **Source** – `specialization = tag_assigned_by_player_or_ai`.
|
||||||
|
pub specialization: String,
|
||||||
|
|
||||||
// ────────────────────────────────────────
|
// ──── Strategic Positioning (hidden + public) ─────────────────────
|
||||||
// 2. Strategic positioning (hidden + public)
|
/// Current governor or leader assigned to the entity.
|
||||||
// ────────────────────────────────────────
|
|
||||||
/// Current governor or leader assigned to the city.
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Adds personal bonuses and can modify policies or diplomatic stance.
|
/// **Purpose** – Leadership identity.
|
||||||
/// *Source*: `governor = selected_leader_uuid`.
|
/// **Effect** – Adds personal bonuses and may modify policies
|
||||||
governor: Uuid,
|
/// 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.
|
/// **Purpose** – Functional role within the empire.
|
||||||
/// *Source*: `category = tag_assigned_by_player_or_ai`.
|
/// **Effect** – Alters base production, tax rates, and
|
||||||
category: PrimaryStat,
|
/// 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.
|
/// **Purpose** – Political affiliation.
|
||||||
/// *Source*: `faction = current_faction_uuid`.
|
/// **Effect** – Determines diplomatic relations, war status,
|
||||||
faction: Uuid,
|
/// and access to empire‑wide bonuses.
|
||||||
|
/// **Source** – `faction = current_faction_uuid`.
|
||||||
|
pub faction: Uuid,
|
||||||
|
|
||||||
// ────────────────────────────────────────
|
/// UIDs of all entities the entity is linked to (roads, trade routes,
|
||||||
// 3. Links & relational data
|
/// alliances, war declarations, etc.).
|
||||||
// ────────────────────────────────────────
|
|
||||||
/// UIDs of all entities the city is linked to (roads, trade routes, alliances, war declarations, etc.).
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Influences economic, military, and diplomatic interactions.
|
/// **Purpose** – Connectivity network.
|
||||||
/// *Source*: `links = Vec<Uuid>` collected from the city’s network manager.
|
/// **Effect** – Influences economic, military, and diplomatic
|
||||||
links: Vec<Uuid>,
|
/// interactions.
|
||||||
|
/// **Source** – `links = Vec<Uuid>` collected from the entity’s
|
||||||
|
/// network manager.
|
||||||
|
pub links: Vec<Uuid>,
|
||||||
|
|
||||||
// ────────────────────────────────────────
|
/// Prestige / reputation of the entity in the eyes of the empire
|
||||||
// 4. Meta‑statistics (derived)
|
/// and foreign powers.
|
||||||
// ────────────────────────────────────────
|
|
||||||
/// Prestige / reputation of the city in the eyes of the empire and foreign powers.
|
|
||||||
///
|
///
|
||||||
/// *Effect*: Affects foreign relations, diplomatic offers, and event weighting.
|
/// **Purpose** – Social standing metric.
|
||||||
/// *Source*: `prestige = f(culture, trade, military)`.
|
/// **Effect** – Affects diplomatic influence, trade bonuses,
|
||||||
prestige: InferredStat,
|
/// and event outcomes.
|
||||||
|
/// **Source** – `prestige = calculate_prestige(...)`.
|
||||||
|
pub prestige: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- STAT TYPES ---------------------------------------------------------------
|
/// A summary of the stats, only for display purposes
|
||||||
// The game distinguishes four kinds of statistics.
|
#[allow(clippy::missing_docs_in_private_items)]
|
||||||
// The *visibility* of a stat determines whether it is shown to the player
|
#[derive(Table)]
|
||||||
// (Primary / Inferred) and whether the player can change it manually
|
pub struct SummaryStats {
|
||||||
// (Primary / Hidden).
|
#[table(title = "Demo")]
|
||||||
//
|
demographics: GenericStat,
|
||||||
// All four stat structs simply wrap a signed integer, but they all
|
#[table(title = "Eco")]
|
||||||
// implement the same behaviour via the `GameStat` trait below.
|
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.
|
/// A stat that is shown to the player *and* can be modified manually.
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct PrimaryStat {
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, Display)]
|
||||||
|
pub struct GenericStat {
|
||||||
pub value: isize,
|
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 ---------------------------------------------------------------
|
/// --- TRAITS ---------------------------------------------------------------
|
||||||
/// A stat is a *game value* that can be converted to two different
|
/// A stat is a *game value* that can be converted to two different
|
||||||
/// normalised ranges – a 50‑point range for “gaming” logic and a
|
/// normalised ranges – a 50‑point range for “gaming” logic and a
|
||||||
|
|
@ -461,12 +362,19 @@ pub trait GameStat {
|
||||||
self.to_50() / 5
|
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
|
/// Return the raw integer value, always bound to 0-70
|
||||||
fn get_value(&self) -> isize;
|
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
|
/// Return the raw integer value, always bound to 0-70
|
||||||
fn change_value(&mut self, value: isize);
|
fn change_value(&mut self, value: isize);
|
||||||
|
|
||||||
|
|
@ -475,6 +383,7 @@ pub trait GameStat {
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait for objects that can expose a stat via a string key.
|
/// 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 trait returns a *boxed* trait object so callers do not need to know
|
||||||
/// the concrete type that was stored.
|
/// the concrete type that was stored.
|
||||||
|
|
@ -483,3 +392,8 @@ pub trait Accessible {
|
||||||
/// `None` if the key does not exist.
|
/// `None` if the key does not exist.
|
||||||
fn get_val(&self, key: &str) -> Option<Box<dyn GameStat>>;
|
fn get_val(&self, key: &str) -> Option<Box<dyn GameStat>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub trait Displayable {
|
||||||
|
// fn summary(&self) -> String;
|
||||||
|
// fn full_description(&self) -> String;
|
||||||
|
// }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
//! All traits implementatition for the main structs are deffered here
|
//! All traits implementatition for the main structs are deffered here
|
||||||
|
|
||||||
use crate::stats::VisibilityLevel;
|
use std::str::FromStr;
|
||||||
use crate::stats::{
|
|
||||||
Demographics, Economics, GameStat, HiddenInferredStat, HiddenStat, InferredStat,
|
use crate::error::EpochError;
|
||||||
Infrastructure, Military, PrimaryStat, Social,
|
use crate::stats;
|
||||||
};
|
use crate::stats::GameStat;
|
||||||
|
use crate::stats::GenericStat;
|
||||||
|
use crate::stats::ListStats;
|
||||||
|
use crate::stats::OverallStats;
|
||||||
|
|
||||||
/// Generates an `impl GameStat for <TYPE>` where the only difference between
|
/// Generates an `impl GameStat for <TYPE>` where the only difference between
|
||||||
/// multiple implementations is the visibility level.
|
/// multiple implementations is the visibility level.
|
||||||
|
|
@ -13,16 +16,12 @@ use crate::stats::{
|
||||||
/// * `$type`: the concrete type that implements `GameStat`
|
/// * `$type`: the concrete type that implements `GameStat`
|
||||||
/// * `$vis`: the enum variant of `VisibilityLevel` to return
|
/// * `$vis`: the enum variant of `VisibilityLevel` to return
|
||||||
macro_rules! impl_game_stat {
|
macro_rules! impl_game_stat {
|
||||||
($type:ident, $vis:ident) => {
|
($type:ident) => {
|
||||||
impl GameStat for $type {
|
impl GameStat for $type {
|
||||||
fn get_value(&self) -> isize {
|
fn get_value(&self) -> isize {
|
||||||
self.value
|
self.value
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visibility(&self) -> VisibilityLevel {
|
|
||||||
VisibilityLevel::$vis
|
|
||||||
}
|
|
||||||
|
|
||||||
fn change_value(&mut self, value: isize) {
|
fn change_value(&mut self, value: isize) {
|
||||||
self.value = value;
|
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
|
/// A field accessor to be able to modify fields on the fly
|
||||||
macro_rules! field_accessor {
|
macro_rules! field_accessor {
|
||||||
($name:ident { $($field:ident),* }) => {
|
($name:ident { $($field:ident),* }) => {
|
||||||
|
|
@ -67,87 +61,158 @@ macro_rules! field_accessor {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
field_accessor!(Demographics {
|
impl_game_stat!(GenericStat);
|
||||||
|
field_accessor!(OverallStats {
|
||||||
|
demographics,
|
||||||
population,
|
population,
|
||||||
growth_rate,
|
growth_rate,
|
||||||
crime,
|
crime,
|
||||||
health,
|
|
||||||
skill,
|
|
||||||
demographics,
|
|
||||||
consumption,
|
|
||||||
unrest,
|
|
||||||
happiness,
|
happiness,
|
||||||
fear
|
economy,
|
||||||
});
|
|
||||||
field_accessor!(Economics {
|
|
||||||
food,
|
food,
|
||||||
industry,
|
industry,
|
||||||
science,
|
science,
|
||||||
tax,
|
|
||||||
debt,
|
|
||||||
trade,
|
trade,
|
||||||
eco_power,
|
// social,
|
||||||
wealth,
|
// culture,
|
||||||
infra_cost
|
// education,
|
||||||
});
|
// tourism,
|
||||||
field_accessor!(Social {
|
// influence,
|
||||||
culture,
|
military,
|
||||||
religion,
|
|
||||||
education,
|
|
||||||
tourism,
|
|
||||||
social,
|
|
||||||
influence
|
|
||||||
});
|
|
||||||
|
|
||||||
field_accessor!(Military {
|
|
||||||
army,
|
army,
|
||||||
strength,
|
strength,
|
||||||
readiness,
|
|
||||||
fortification,
|
fortification,
|
||||||
strategic_value,
|
|
||||||
threat,
|
threat,
|
||||||
military
|
infrastructure,
|
||||||
|
bureaucracy,
|
||||||
|
transportation,
|
||||||
|
sprawl,
|
||||||
|
health
|
||||||
});
|
});
|
||||||
field_accessor!(Infrastructure {
|
|
||||||
communications,
|
impl FromStr for ListStats {
|
||||||
needs,
|
type Err = EpochError;
|
||||||
pollution,
|
|
||||||
space,
|
/// Convert an acronym (e.g. `"cri"`) into the corresponding enum variant.
|
||||||
connectivity,
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
infrastructure
|
match s.to_ascii_lowercase().as_str() {
|
||||||
});
|
"dem" | "demog" | "demographics" | "demo" => Ok(ListStats::Demographics),
|
||||||
// field_accessor!(Strategics {
|
"pop" | "popul" | "populations" => Ok(ListStats::Population),
|
||||||
// position,
|
"grow" | "grw" | "growth" => Ok(ListStats::Growthrate),
|
||||||
// distance_to_capital,
|
"cri" | "crim" | "crimes" => Ok(ListStats::Crime),
|
||||||
// ressources,
|
"hapn" | "happines" | "hap" => Ok(ListStats::Happiness),
|
||||||
// specialisation,
|
"eco" | "economy" | "econ" => Ok(ListStats::Economy),
|
||||||
// governor,
|
"food" | "fo" | "agr" | "agri" => Ok(ListStats::Food),
|
||||||
// category,
|
"industry" | "indus" | "ind" => Ok(ListStats::Industry),
|
||||||
// faction,
|
"science" | "sci" | "sc" => Ok(ListStats::Science),
|
||||||
// links,
|
"trade" | "trd" | "tr" => Ok(ListStats::Trade),
|
||||||
// prestige
|
"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<ListStats> 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<Self, Self::Err> {
|
||||||
|
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)]
|
#[cfg(test)]
|
||||||
pub(crate) mod test {
|
pub(crate) mod test {
|
||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
|
use super::*;
|
||||||
use crate::stats::GameStat;
|
use crate::stats::GameStat;
|
||||||
use crate::stats::PrimaryStat;
|
use crate::stats::GenericStat;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
struct Person {
|
struct Person {
|
||||||
name: PrimaryStat,
|
name: GenericStat,
|
||||||
age: PrimaryStat,
|
age: GenericStat,
|
||||||
email: PrimaryStat,
|
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 });
|
field_accessor!(Person { name, age, email });
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bob() {
|
fn test_field_accessors() {
|
||||||
let person = Person {
|
let person = Person {
|
||||||
name: PrimaryStat { value: 10 },
|
name: GenericStat { value: 10 },
|
||||||
age: PrimaryStat { value: 20 },
|
age: GenericStat { value: 20 },
|
||||||
email: PrimaryStat { value: 70 },
|
email: GenericStat { value: 70 },
|
||||||
};
|
};
|
||||||
let name = person.get_field("name").unwrap();
|
let name = person.get_field("name").unwrap();
|
||||||
let email = person.get_field("email").unwrap();
|
let email = person.get_field("email").unwrap();
|
||||||
|
|
@ -156,4 +221,179 @@ pub(crate) mod test {
|
||||||
assert_eq!(age.to_50(), 10);
|
assert_eq!(age.to_50(), 10);
|
||||||
assert_eq!(email.to_50(), 50);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue