use std::sync::LazyLock;
use tiger_tables::datatype::*;
use crate::datatype::CaseInsensitiveStr;
use crate::helpers::{BiTigerHashMap, TigerHashMap, TigerHashSet};
use crate::scopes::Scopes;
use Datatype::Imperator;
use ImperatorDatatype::*;
pub static LOWERCASE_DATATYPE_SET: LazyLock<TigerHashSet<CaseInsensitiveStr>> =
LazyLock::new(|| {
let mut set = TigerHashSet::default();
for (name, _, _) in GLOBAL_PROMOTES_IMPERATOR.iter().copied() {
set.insert(CaseInsensitiveStr(name));
}
for (name, _, _) in GLOBAL_FUNCTIONS_IMPERATOR.iter().copied() {
set.insert(CaseInsensitiveStr(name));
}
for (name, _, _, _) in PROMOTES_IMPERATOR.iter().copied() {
set.insert(CaseInsensitiveStr(name));
}
for (name, _, _, _) in FUNCTIONS_IMPERATOR.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_IMPERATOR.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_IMPERATOR.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_IMPERATOR.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_IMPERATOR.iter().copied() {
map.entry(name).or_default().push((from, args, to));
}
map
});
const DATATYPE_AND_SCOPE: &[(Datatype, Scopes)] = &[
(Imperator(Country), Scopes::Country),
(Imperator(Character), Scopes::Character),
(Imperator(Province), Scopes::Province),
(Imperator(Siege), Scopes::Siege),
(Imperator(Unit), Scopes::Unit),
(Imperator(Pop), Scopes::Pop),
(Imperator(Family), Scopes::Family),
(Imperator(Party), Scopes::Party),
(Imperator(Religion), Scopes::Religion),
(Imperator(Culture), Scopes::Culture),
(Imperator(CharacterJob), Scopes::Job),
(Imperator(CultureGroup), Scopes::CultureGroup),
(Imperator(CountryCulture), Scopes::CountryCulture),
(Imperator(Area), Scopes::Area),
(Imperator(State), Scopes::State),
(Imperator(SubUnit), Scopes::SubUnit),
(Imperator(Governorship), Scopes::Governorship),
(Imperator(Region), Scopes::Region),
(Imperator(Deity), Scopes::Deity),
(Imperator(GreatWork), Scopes::GreatWork),
(Imperator(Treasure), Scopes::Treasure),
(Imperator(War), Scopes::War),
(Imperator(Legion), Scopes::Legion),
(Imperator(LevyTemplate), Scopes::LevyTemplate),
];