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 std::sync::LazyLock;

use tiger_tables::datatype::*;

use crate::datatype::CaseInsensitiveStr;
use crate::helpers::{BiTigerHashMap, TigerHashMap, TigerHashSet};
use crate::scopes::Scopes;

use Datatype::Vic3;
use Vic3Datatype::*;

pub static LOWERCASE_DATATYPE_SET: LazyLock<TigerHashSet<CaseInsensitiveStr>> =
    LazyLock::new(|| {
        let mut set = TigerHashSet::default();

        for (name, _, _) in GLOBAL_PROMOTES_VIC3.iter().copied() {
            set.insert(CaseInsensitiveStr(name));
        }

        for (name, _, _) in GLOBAL_FUNCTIONS_VIC3.iter().copied() {
            set.insert(CaseInsensitiveStr(name));
        }

        for (name, _, _, _) in PROMOTES_VIC3.iter().copied() {
            set.insert(CaseInsensitiveStr(name));
        }

        for (name, _, _, _) in FUNCTIONS_VIC3.iter().copied() {
            set.insert(CaseInsensitiveStr(name));
        }
        set
    });

pub static DATATYPE_AND_SCOPE_MAP: LazyLock<BiTigerHashMap<Datatype, Scopes>> =
    LazyLock::new(|| {
        let mut map = BiTigerHashMap::default();
        for (datatype, scope) in DATATYPE_AND_SCOPE.iter().copied() {
            map.insert(datatype, scope);
        }
        map
    });

pub static GLOBAL_PROMOTES_MAP: LazyLock<TigerHashMap<&'static str, (Args, Datatype)>> =
    LazyLock::new(|| {
        let mut map = TigerHashMap::default();
        for (name, args, datatype) in GLOBAL_PROMOTES_VIC3.iter().copied() {
            map.insert(name, (args, datatype));
        }
        map
    });

pub static GLOBAL_FUNCTIONS_MAP: LazyLock<TigerHashMap<&'static str, (Args, Datatype)>> =
    LazyLock::new(|| {
        let mut map = TigerHashMap::default();
        for (name, args, datatype) in GLOBAL_FUNCTIONS_VIC3.iter().copied() {
            map.insert(name, (args, datatype));
        }
        map
    });

#[allow(clippy::type_complexity)]
pub static PROMOTES_MAP: LazyLock<TigerHashMap<&'static str, Vec<(Datatype, Args, Datatype)>>> =
    LazyLock::new(|| {
        let mut map = TigerHashMap::<&'static str, Vec<(Datatype, Args, Datatype)>>::default();
        for (name, from, args, to) in PROMOTES_VIC3.iter().copied() {
            map.entry(name).or_default().push((from, args, to));
        }
        map
    });

#[allow(clippy::type_complexity)]
pub static FUNCTIONS_MAP: LazyLock<TigerHashMap<&'static str, Vec<(Datatype, Args, Datatype)>>> =
    LazyLock::new(|| {
        let mut map = TigerHashMap::<&'static str, Vec<(Datatype, Args, Datatype)>>::default();
        for (name, from, args, to) in FUNCTIONS_VIC3.iter().copied() {
            map.entry(name).or_default().push((from, args, to));
        }
        map
    });

// TODO: find the right datatypes for the commented out ones
const DATATYPE_AND_SCOPE: &[(Datatype, Scopes)] = &[
    (Vic3(Country), Scopes::Country),
    (Vic3(Battle), Scopes::Battle),
    // (Vic3(BattleSide),Scopes::BattleSide),
    (Vic3(Building), Scopes::Building),
    (Vic3(BuildingType), Scopes::BuildingType),
    (Vic3(CanalType), Scopes::CanalType),
    (Vic3(Character), Scopes::Character),
    (Vic3(CivilWar), Scopes::CivilWar),
    (Vic3(CommanderOrderType), Scopes::CommanderOrderType),
    (Vic3(CountryCreation), Scopes::CountryCreation),
    (Vic3(CountryDefinition), Scopes::CountryDefinition),
    (Vic3(CountryFormation), Scopes::CountryFormation),
    (Vic3(Culture), Scopes::Culture),
    (Vic3(Decree), Scopes::Decree),
    (Vic3(DiplomaticAction), Scopes::DiplomaticAction),
    (Vic3(DiplomaticPact), Scopes::DiplomaticPact),
    (Vic3(DiplomaticPlay), Scopes::DiplomaticPlay),
    (Vic3(DiplomaticRelations), Scopes::DiplomaticRelations),
    (Vic3(Front), Scopes::Front),
    (Vic3(Goods), Scopes::Goods),
    (Vic3(Hq), Scopes::Hq),
    (Vic3(Ideology), Scopes::Ideology),
    (Vic3(Institution), Scopes::Institution),
    (Vic3(InstitutionType), Scopes::InstitutionType),
    // (Vic3(InterestMarker),Scopes::InterestMarker),
    (Vic3(InterestGroup), Scopes::InterestGroup),
    (Vic3(InterestGroupTrait), Scopes::InterestGroupTrait),
    // (Vic3(InterestGroupType),Scopes::InterestGroupType),
    (Vic3(JournalEntry), Scopes::JournalEntry),
    (Vic3(Law), Scopes::Law),
    (Vic3(LawType), Scopes::LawType),
    (Vic3(Market), Scopes::Market),
    (Vic3(MarketGoods), Scopes::MarketGoods),
    (Vic3(Objective), Scopes::Objective),
    (Vic3(Party), Scopes::Party),
    (Vic3(PoliticalMovement), Scopes::PoliticalMovement),
    (Vic3(Pop), Scopes::Pop),
    (Vic3(PopType), Scopes::PopType),
    (Vic3(Province), Scopes::Province),
    (Vic3(Religion), Scopes::Religion),
    (Vic3(ShippingLane), Scopes::ShippingLanes),
    (Vic3(State), Scopes::State),
    (Vic3(StateRegion), Scopes::StateRegion),
    (Vic3(StateTrait), Scopes::StateTrait),
    (Vic3(StrategicRegion), Scopes::StrategicRegion),
    (Vic3(Technology), Scopes::Technology),
    // (Vic3(TechnologyStatus),Scopes::TechnologyStatus),
    (Vic3(Theater), Scopes::Theater),
    (Vic3(War), Scopes::War),
];