tiger-lib 1.18.0

Library used by the tools ck3-tiger, vic3-tiger, and imperator-tiger. This library holds the bulk of the code for them. It can be built either for ck3-tiger with the feature ck3, or for vic3-tiger with the feature vic3, or for imperator-tiger with the feature imperator, but not both at the same time.
Documentation
use crate::block::Block;
use crate::db::{Db, DbKind};
use crate::everything::Everything;
use crate::game::GameFlags;
use crate::item::{Item, ItemLoader};
use crate::scopes::Scopes;
use crate::token::Token;
use crate::tooltipped::Tooltipped;
use crate::validate::validate_possibly_named_color;
use crate::validator::Validator;
use crate::vic3::tables::modifs::maybe_warn_modifiable_capitalization;

#[derive(Clone, Debug)]
pub struct PopType {}

inventory::submit! {
    ItemLoader::Normal(GameFlags::Vic3, Item::PopType, PopType::add)
}

impl PopType {
    pub fn add(db: &mut Db, key: Token, block: Block) {
        db.add(Item::PopType, key, block, Box::new(Self {}));
    }
}

impl DbKind for PopType {
    fn validate(&self, key: &Token, block: &Block, data: &Everything) {
        let mut vd = Validator::new(block, data);

        maybe_warn_modifiable_capitalization(key);

        data.verify_exists(Item::Localization, key);
        let loca = format!("{key}_desc");
        data.verify_exists_implied(Item::Localization, &loca, key);
        let loca = format!("{key}_no_icon");
        data.verify_exists_implied(Item::Localization, &loca, key);
        let loca = format!("{key}_only_icon");
        data.verify_exists_implied(Item::Localization, &loca, key);
        let loca = format!("{key}_QUALIFICATIONS_DESC").to_uppercase();
        data.verify_exists_implied(Item::Localization, &loca, key);

        vd.field_item("texture", Item::File);
        vd.field_validated("color", validate_possibly_named_color);
        vd.replaced_field("strata", "social class definitions");

        vd.field_integer("start_quality_of_life");
        vd.field_numeric("wage_weight");
        vd.field_bool("paid_private_wage");
        vd.field_numeric("literacy_target");
        vd.field_numeric("consumption_mult");
        vd.field_numeric("dependent_wage");

        vd.field_bool("unemployment");
        vd.field_numeric("unemployment_wealth");

        vd.field_numeric_range("political_engagement_base", 0.0..=1.0);
        vd.field_numeric("political_engagement_literacy_factor");
        vd.field_script_value_rooted("political_engagement_mult", Scopes::Pop);

        vd.advice_field("qualifications_growth_desc", "removed in 1.9");
        vd.field_script_value_rooted("qualifications", Scopes::Pop);

        vd.field_script_value_rooted("portrait_age", Scopes::Pop);
        vd.field_script_value_rooted("portrait_pose", Scopes::Pop);
        vd.field_trigger_rooted("portrait_is_female", Tooltipped::No, Scopes::Pop);

        // undocumented

        vd.field_numeric("education_access");
        vd.field_numeric_range("working_adult_ratio", 0.0..=1.0);
        vd.field_bool("can_always_hire");
        vd.field_bool("subsistence_income");
        vd.field_bool("ignores_employment_proportionality");
        vd.field_bool("is_slave");
        vd.field_bool("military");
        vd.field_numeric("sol_change_impact");
        vd.field_bool("pays_land_tax");
    }
}