tiger_lib/imperator/tables/
iterators.rs

1use std::sync::LazyLock;
2
3use crate::everything::Everything;
4use crate::helpers::TigerHashMap;
5use crate::lowercase::Lowercase;
6use crate::scopes::Scopes;
7use crate::token::Token;
8
9#[inline]
10pub fn iterator(
11    name_lc: &Lowercase,
12    _name: &Token,
13    _data: &Everything,
14) -> Option<(Scopes, Scopes)> {
15    ITERATOR_MAP.get(name_lc.as_str()).copied()
16}
17
18static ITERATOR_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, Scopes)>> = LazyLock::new(|| {
19    let mut hash = TigerHashMap::default();
20    for (from, s, to) in ITERATOR.iter().copied() {
21        hash.insert(s, (from, to));
22    }
23    hash
24});
25
26/// LAST UPDATED VERSION 2.0.4
27/// See `effects.log` from the game data dumps
28/// These are the list iterators. Every entry represents
29/// a every_, ordered_, random_, and any_ version.
30const ITERATOR: &[(Scopes, &str, Scopes)] = &[
31    (Scopes::State, "state_province", Scopes::Province),
32    (Scopes::Character, "character_treasure", Scopes::Treasure),
33    (Scopes::Character, "character_unit", Scopes::Unit),
34    (Scopes::Character, "child", Scopes::Character),
35    (Scopes::Character, "friend", Scopes::Character),
36    (Scopes::Character, "governor_state", Scopes::State),
37    (Scopes::Character, "holdings", Scopes::Province),
38    (Scopes::Character, "parent", Scopes::Character),
39    (Scopes::Character, "rival", Scopes::Character),
40    (Scopes::Character, "sibling", Scopes::Character),
41    (Scopes::Character, "support_as_heir", Scopes::Character),
42    (Scopes::Governorship, "governorship_state", Scopes::State),
43    (Scopes::Country, "allied_country", Scopes::Country),
44    (Scopes::Country, "army", Scopes::Unit),
45    (Scopes::Country, "available_deity", Scopes::Deity),
46    (Scopes::Country, "character", Scopes::Character),
47    (Scopes::Country, "commander", Scopes::Character),
48    (Scopes::Country, "countries_at_war_with", Scopes::Country),
49    (Scopes::Country, "country_culture", Scopes::CountryCulture),
50    (Scopes::Country, "country_state", Scopes::State),
51    (Scopes::Country, "country_sub_unit", Scopes::SubUnit),
52    (Scopes::Country, "country_treasure", Scopes::Treasure),
53    (Scopes::Country, "current_war", Scopes::War),
54    (Scopes::Country, "family", Scopes::Family),
55    (Scopes::Country, "governorships", Scopes::Governorship),
56    (Scopes::Country, "integrated_culture", Scopes::CountryCulture),
57    (Scopes::Country, "legion", Scopes::Legion),
58    (Scopes::Country, "navy", Scopes::Unit),
59    (Scopes::Country, "neighbour_country", Scopes::Country),
60    (Scopes::Country, "owned_holy_site", Scopes::Province),
61    (Scopes::Country, "owned_province", Scopes::Province),
62    (Scopes::Country, "pantheon_deity", Scopes::Deity),
63    (Scopes::Country, "party", Scopes::Party),
64    (Scopes::Country, "subject", Scopes::Country),
65    (Scopes::Country, "successor", Scopes::Character),
66    (Scopes::Country, "unit", Scopes::Unit),
67    (Scopes::Party, "party_member", Scopes::Character),
68    (Scopes::Legion, "legion_commander", Scopes::Character),
69    (Scopes::Legion, "legion_unit", Scopes::Unit),
70    (Scopes::Region, "neighbor_region", Scopes::Region),
71    (Scopes::Region, "region_area", Scopes::Area),
72    (Scopes::Region, "region_governorship", Scopes::Governorship),
73    (Scopes::Region, "region_province", Scopes::Province),
74    (Scopes::Region, "region_province_including_unownable", Scopes::Province),
75    (Scopes::Region, "region_state", Scopes::State),
76    (Scopes::Area, "area_including_unownable_province", Scopes::Province),
77    (Scopes::Area, "area_province", Scopes::Province),
78    (Scopes::Area, "area_state", Scopes::State),
79    (Scopes::Area, "neighbor_area", Scopes::Area),
80    (Scopes::Unit, "sub_unit", Scopes::SubUnit),
81    (Scopes::Family, "family_member", Scopes::Character),
82    (Scopes::War, "war_attacker", Scopes::Country),
83    (Scopes::War, "war_defender", Scopes::Country),
84    (Scopes::War, "war_participant", Scopes::Country),
85    (Scopes::Province, "great_work_in_province", Scopes::GreatWork),
86    (Scopes::Province, "neighbor_province", Scopes::Province),
87    (Scopes::Province, "pops_in_province", Scopes::Pop),
88    (Scopes::Province, "province_treasure", Scopes::Treasure),
89    (Scopes::Province, "unit_in_province", Scopes::Unit),
90    (Scopes::None, "active_war", Scopes::War),
91    (Scopes::None, "area", Scopes::Area),
92    (Scopes::None, "country", Scopes::Country),
93    (Scopes::None, "deity", Scopes::Deity),
94    (Scopes::None, "ended_war", Scopes::War),
95    (Scopes::None, "holy_site", Scopes::Province),
96    (Scopes::None, "living_character", Scopes::Character),
97    (Scopes::None, "ownable_province", Scopes::Province),
98    (Scopes::None, "province", Scopes::Province),
99    (Scopes::None, "region", Scopes::Region),
100    (Scopes::None, "sea_and_river_zone", Scopes::Province),
101    (Scopes::None, "in_list", Scopes::all()),
102    (Scopes::None, "in_global_list", Scopes::all()),
103];
104
105pub fn iterator_removed(name: &str) -> Option<(&'static str, &'static str)> {
106    for (removed_name, version, explanation) in ITERATOR_REMOVED.iter().copied() {
107        if name == removed_name {
108            return Some((version, explanation));
109        }
110    }
111    None
112}
113
114/// LAST UPDATED VERSION 2.0.4
115/// Every entry represents a every_, ordered_, random_, and any_ version.
116const ITERATOR_REMOVED: &[(&str, &str, &str)] = &[];