tiger_lib/vic3/tables/
targets.rs

1use std::sync::LazyLock;
2
3use crate::helpers::TigerHashMap;
4use crate::scopes::{ArgumentValue, Scopes};
5
6#[inline]
7pub fn scope_to_scope(name: &str) -> Option<(Scopes, Scopes)> {
8    SCOPE_TO_SCOPE_MAP.get(name).copied()
9}
10
11static SCOPE_TO_SCOPE_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, Scopes)>> =
12    LazyLock::new(|| {
13        let mut hash = TigerHashMap::default();
14        for (from, s, to) in SCOPE_TO_SCOPE.iter().copied() {
15            hash.insert(s, (from, to));
16        }
17        hash
18    });
19
20/// LAST UPDATED VIC3 VERSION 1.12.2
21/// See `event_targets.log` from the game data dumps
22/// These are scope transitions that can be chained like `root.joined_faction.faction_leader`
23const SCOPE_TO_SCOPE: &[(Scopes, &str, Scopes)] = &[
24    (Scopes::Treaty.union(Scopes::TreatyOptions), "amended_treaty", Scopes::Treaty),
25    (Scopes::Country, "army_size", Scopes::Value),
26    (Scopes::Country, "army_size_including_conscripts", Scopes::Value),
27    (Scopes::Country, "army_size_including_raised_conscripts", Scopes::Value),
28    (Scopes::Amendment, "attached_law", Scopes::Law),
29    (Scopes::Battle, "attacker_side", Scopes::BattleSide),
30    (Scopes::War, "attacker_warleader", Scopes::Country),
31    (Scopes::Country.union(Scopes::State), "average_expected_sol", Scopes::Value),
32    (Scopes::Character.union(Scopes::InterestGroup), "average_progressiveness", Scopes::Value),
33    (Scopes::Country.union(Scopes::State), "average_sol", Scopes::Value),
34    (Scopes::Goods, "base_price", Scopes::Value),
35    (Scopes::BattleSide, "battle", Scopes::Battle),
36    (Scopes::Treaty.union(Scopes::TreatyOptions), "binding_period", Scopes::Value),
37    (Scopes::NewCombatUnit, "building", Scopes::Building),
38    (Scopes::Country, "building_levels", Scopes::Value),
39    (Scopes::Country, "cached_ai_coastal_population", Scopes::Value),
40    (Scopes::Country, "cached_ai_incorporated_coastal_population", Scopes::Value),
41    (Scopes::Country, "cached_ai_incorporated_population", Scopes::Value),
42    (Scopes::Country, "cached_ai_overseas_subject_population", Scopes::Value),
43    (Scopes::Country, "cached_ai_subject_population", Scopes::Value),
44    (Scopes::Country, "cached_ai_total_population", Scopes::Value),
45    (Scopes::Country, "cached_ai_unincorporated_coastal_population", Scopes::Value),
46    (Scopes::Country, "cached_ai_unincorporated_population", Scopes::Value),
47    (Scopes::Country, "capital", Scopes::State),
48    (Scopes::PoliticalMovement, "civil_war", Scopes::CivilWar),
49    (Scopes::Country, "civil_war_origin_country", Scopes::Country),
50    (Scopes::Country, "colonial_growth_per_colony", Scopes::Value),
51    (Scopes::Province, "combat_width", Scopes::Value),
52    (Scopes::Character, "command_limit_num_units", Scopes::Value),
53    (Scopes::Character, "commander_military_formation", Scopes::MilitaryFormation),
54    (Scopes::Province.union(Scopes::State), "controller", Scopes::Country),
55    (Scopes::MilitaryFormation, "country", Scopes::Country),
56    (Scopes::Country, "country_definition", Scopes::CountryDefinition),
57    (Scopes::Country, "credit", Scopes::Value),
58    (
59        Scopes::Character
60            .union(Scopes::NewCombatUnit)
61            .union(Scopes::PoliticalMovement)
62            .union(Scopes::Pop),
63        "culture",
64        Scopes::Culture,
65    ),
66    (Scopes::MilitaryFormation, "current_hq", Scopes::Hq),
67    (Scopes::Law, "currently_active_law_in_group", Scopes::Law),
68    (Scopes::Country, "currently_enacting_law", Scopes::Law),
69    (Scopes::Battle, "defender_side", Scopes::BattleSide),
70    (Scopes::War, "defender_warleader", Scopes::Country),
71    (Scopes::NewCombatUnit, "defense", Scopes::Value),
72    (Scopes::NewCombatUnit, "demoralized", Scopes::Value),
73    (Scopes::DiplomaticPact, "diplomatic_pact_other_country(", Scopes::Country),
74    (Scopes::War, "diplomatic_play", Scopes::DiplomaticPlay),
75    (Scopes::Treaty, "enforced_on_country", Scopes::Country),
76    (Scopes::Treaty, "enforcer_country", Scopes::Country),
77    (Scopes::Company, "executive", Scopes::Character),
78    (
79        Scopes::DiplomaticPact
80            .union(Scopes::TreatyArticle)
81            .union(Scopes::TreatyOptions)
82            .union(Scopes::TreatyArticleOptions)
83            .union(Scopes::Treaty),
84        "first_country",
85        Scopes::Country,
86    ),
87    (
88        Scopes::Battle
89            .union(Scopes::Character)
90            .union(Scopes::Province)
91            .union(Scopes::Invasion)
92            .union(Scopes::MilitaryFormation),
93        "front",
94        Scopes::Front,
95    ),
96    (Scopes::Front, "front_length", Scopes::Value),
97    (Scopes::Country.union(Scopes::State), "gdp", Scopes::Value),
98    (Scopes::None, "global_gdp", Scopes::Value),
99    (Scopes::JournalEntry, "goal_value", Scopes::Value),
100    (Scopes::MarketGoods.union(Scopes::StateGoods), "goods", Scopes::Goods),
101    (Scopes::Country.union(Scopes::PoliticalMovement), "government_size", Scopes::Value),
102    (Scopes::Building.union(Scopes::BuildingType), "group", Scopes::BuildingGroup),
103    (Scopes::Country, "heir", Scopes::Character),
104    (Scopes::MilitaryFormation, "highest_ranked_commander", Scopes::Character),
105    (Scopes::Character.union(Scopes::Pop), "home_country", Scopes::Country),
106    (Scopes::MilitaryFormation, "home_hq", Scopes::Hq),
107    (Scopes::PowerBloc, "identity", Scopes::PowerBlocIdentity),
108    (Scopes::Character, "ideology", Scopes::Ideology),
109    (Scopes::Country, "imposed_law", Scopes::Law),
110    (Scopes::Country.union(Scopes::Law), "imposer_of_law", Scopes::Country),
111    (Scopes::Country, "income", Scopes::Value),
112    (Scopes::Country, "income_transfer_expenses", Scopes::Value),
113    (Scopes::Country, "income_transfer_relative_expenses", Scopes::Value),
114    (Scopes::Country, "infamy", Scopes::Value),
115    (Scopes::DiplomaticPlay, "initiator", Scopes::Country),
116    (
117        Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions),
118        "input_building_type",
119        Scopes::BuildingType,
120    ),
121    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "input_company", Scopes::Company),
122    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "input_country", Scopes::Country),
123    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "input_goods", Scopes::Goods),
124    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "input_law", Scopes::LawType),
125    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "input_quantity", Scopes::Value),
126    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "input_state", Scopes::State),
127    (
128        Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions),
129        "input_strategic_region",
130        Scopes::StrategicRegion,
131    ),
132    (Scopes::Character, "interest_group", Scopes::InterestGroup),
133    (Scopes::Character, "interest_group_type", Scopes::InterestGroupType),
134    (Scopes::Front, "invasion", Scopes::Invasion),
135    (Scopes::Invasion, "invasion_attacker", Scopes::Country),
136    (Scopes::Invasion, "invasion_defender", Scopes::Country),
137    (Scopes::Institution, "investment", Scopes::Value),
138    (Scopes::Institution, "investment_max", Scopes::Value),
139    (Scopes::Country, "investment_pool_income", Scopes::Value),
140    (Scopes::None, "is_setup", Scopes::Value),
141    (Scopes::None, "je_tutorial", Scopes::JournalEntry),
142    (Scopes::Province.union(Scopes::State), "land_controller_hq", Scopes::Hq),
143    (Scopes::Province.union(Scopes::State), "land_hq", Scopes::Hq),
144    (Scopes::MarketGoods, "largest_exporting_market", Scopes::Market),
145    (Scopes::MarketGoods, "largest_importing_market", Scopes::Market),
146    (Scopes::Law, "law_type", Scopes::LawType),
147    (Scopes::InterestGroup, "leader", Scopes::Character),
148    (Scopes::Country, "legitimacy", Scopes::Value),
149    (Scopes::Building, "level", Scopes::Value),
150    (Scopes::Building, "level_after_queued_constructions", Scopes::Value),
151    (Scopes::NewCombatUnit, "manpower", Scopes::Value),
152    (
153        Scopes::Country
154            .union(Scopes::Building)
155            .union(Scopes::Market)
156            .union(Scopes::MarketGoods)
157            .union(Scopes::Province)
158            .union(Scopes::State)
159            .union(Scopes::StateGoods)
160            .union(Scopes::StateRegion),
161        "market",
162        Scopes::Market,
163    ),
164    (Scopes::Country, "market_capital", Scopes::State),
165    (Scopes::MarketGoods, "market_export_cap", Scopes::Value),
166    (Scopes::MarketGoods, "market_import_cap", Scopes::Value),
167    (Scopes::State, "mass_migration_culture", Scopes::Culture),
168    (Scopes::Country.union(Scopes::State), "migration_pull", Scopes::Value),
169    (Scopes::Country, "military_expenses", Scopes::Value),
170    (Scopes::Country, "military_expenses_share", Scopes::Value),
171    (Scopes::NewCombatUnit, "mobilization", Scopes::Value),
172    (Scopes::Party, "momentum", Scopes::Value),
173    (Scopes::NewCombatUnit, "morale", Scopes::Value),
174    (Scopes::PoliticalMovement, "most_desired_law", Scopes::LawType),
175    (Scopes::Culture, "national_awakening_state_region", Scopes::StateRegion),
176    (Scopes::Province, "naval_controller_hq", Scopes::Hq),
177    (Scopes::Province, "naval_hq", Scopes::Hq),
178    (Scopes::Country, "navy_size", Scopes::Value),
179    (Scopes::None, "no", Scopes::Bool),
180    (Scopes::None, "NO", Scopes::Bool),
181    (Scopes::Country, "num_active_declared_interests", Scopes::Value),
182    (Scopes::Country, "num_active_interests", Scopes::Value),
183    (Scopes::Country, "num_active_natural_interests", Scopes::Value),
184    (Scopes::Country, "num_active_plays", Scopes::Value),
185    (Scopes::Country, "num_admirals", Scopes::Value),
186    (Scopes::Country, "num_alliances", Scopes::Value),
187    (Scopes::Character, "num_battalions", Scopes::Value),
188    (Scopes::Country, "num_characters", Scopes::Value),
189    (Scopes::Country, "num_colony_projects", Scopes::Value),
190    (Scopes::MilitaryFormation, "num_commanderless_units", Scopes::Value),
191    (Scopes::Country, "num_commanders", Scopes::Value),
192    (Scopes::Country, "num_convoys_available", Scopes::Value),
193    (Scopes::Country, "num_convoys_required", Scopes::Value),
194    (Scopes::Country, "num_declared_interests", Scopes::Value),
195    (Scopes::Country, "num_defensive_pacts", Scopes::Value),
196    (Scopes::Hq, "num_garrison_units", Scopes::Value),
197    (Scopes::Country, "num_generals", Scopes::Value),
198    (Scopes::Country, "num_income_transfer_pacts", Scopes::Value),
199    (Scopes::Country, "num_income_transfer_treaty_articles", Scopes::Value),
200    (Scopes::Country, "num_income_transfers", Scopes::Value),
201    (Scopes::Country, "num_incorporated_states", Scopes::Value),
202    (Scopes::Country, "num_interests", Scopes::Value),
203    (Scopes::PowerBloc, "num_mandates", Scopes::Value),
204    (Scopes::Character, "num_mobilized_battalions", Scopes::Value),
205    (Scopes::Country, "num_natural_interests", Scopes::Value),
206    (Scopes::Country, "num_obligations_earned", Scopes::Value),
207    (Scopes::Country, "num_pending_events", Scopes::Value),
208    (Scopes::Country, "num_politicians", Scopes::Value),
209    (Scopes::Country, "num_positive_relations", Scopes::Value),
210    (Scopes::Front.union(Scopes::State).union(Scopes::StateRegion), "num_provinces", Scopes::Value),
211    (Scopes::Country, "num_queued_constructions", Scopes::Value),
212    (Scopes::Country, "num_queued_government_constructions", Scopes::Value),
213    (Scopes::Country, "num_queued_private_constructions", Scopes::Value),
214    (Scopes::Country, "num_rivals", Scopes::Value),
215    (Scopes::Country, "num_ruling_igs", Scopes::Value),
216    (Scopes::Country, "num_states", Scopes::Value),
217    (Scopes::Country, "num_unincorporated_states", Scopes::Value),
218    (Scopes::Character.union(Scopes::MilitaryFormation), "num_units", Scopes::Value),
219    (Scopes::Character.union(Scopes::MilitaryFormation), "num_units_in_battle", Scopes::Value),
220    (Scopes::Character.union(Scopes::MilitaryFormation), "num_units_not_in_battle", Scopes::Value),
221    (Scopes::Character, "num_units_share", Scopes::Value),
222    (Scopes::State, "num_world_market_hub_trade_center_levels", Scopes::Value),
223    (Scopes::NewCombatUnit, "offense", Scopes::Value),
224    (Scopes::Character, "opposing_commander", Scopes::Character),
225    (Scopes::BattleSide, "opposite_battle_side", Scopes::BattleSide),
226    (Scopes::Country, "overlord", Scopes::Country),
227    (
228        Scopes::Country
229            .union(Scopes::Building)
230            .union(Scopes::Character)
231            .union(Scopes::NewCombatUnit)
232            .union(Scopes::Company)
233            .union(Scopes::Decree)
234            .union(Scopes::Institution)
235            .union(Scopes::InterestMarker)
236            .union(Scopes::InterestGroup)
237            .union(Scopes::JournalEntry)
238            .union(Scopes::Law)
239            .union(Scopes::Market)
240            .union(Scopes::MarketGoods)
241            .union(Scopes::Pop)
242            .union(Scopes::Province)
243            .union(Scopes::State)
244            .union(Scopes::MilitaryFormation)
245            .union(Scopes::PoliticalMovement),
246        "owner",
247        Scopes::Country,
248    ),
249    (Scopes::Country, "owning_company", Scopes::Company),
250    (Scopes::Amendment, "parent_law_type", Scopes::LawType),
251    (Scopes::Market, "participants", Scopes::Value),
252    (Scopes::InterestGroup, "party", Scopes::Party),
253    (Scopes::None, "player", Scopes::Country), // TODO "do not use this outside tutorial"
254    (Scopes::DiplomaticRelations, "player_owed_obligation_days_left", Scopes::Value),
255    (Scopes::Character.union(Scopes::CivilWar), "political_movement", Scopes::PoliticalMovement),
256    (Scopes::Pop, "pop_weight_modifier_scale", Scopes::Value),
257    (Scopes::Character, "popularity", Scopes::Value),
258    (Scopes::State, "population_below_expected_sol", Scopes::Value),
259    (Scopes::Country, "power_bloc", Scopes::PowerBloc),
260    (Scopes::PowerBloc, "power_bloc_leader", Scopes::Country),
261    (Scopes::PowerBloc, "power_struggle_contender", Scopes::Country),
262    (Scopes::Country, "principal", Scopes::Value),
263    (Scopes::Company, "prosperity", Scopes::Value),
264    (Scopes::BattleSide, "province", Scopes::Province),
265    (
266        Scopes::Building
267            .union(Scopes::DiplomaticPlay)
268            .union(Scopes::Hq)
269            .union(Scopes::InterestMarker)
270            .union(Scopes::Province)
271            .union(Scopes::State)
272            .union(Scopes::StateRegion),
273        "region",
274        Scopes::StrategicRegion,
275    ),
276    (
277        Scopes::Country
278            .union(Scopes::Character)
279            .union(Scopes::CountryDefinition)
280            .union(Scopes::PoliticalMovement)
281            .union(Scopes::Pop),
282        "religion",
283        Scopes::Religion,
284    ),
285    (Scopes::TreatyOptions.union(Scopes::Treaty), "remaining_binding_period", Scopes::Value),
286    (Scopes::BuildingType, "required_construction", Scopes::Value),
287    (Scopes::Country, "ruler", Scopes::Character),
288    (Scopes::DiplomaticRelations, "scope_relations", Scopes::Value),
289    (Scopes::DiplomaticRelations, "scope_tension", Scopes::Value),
290    (
291        Scopes::DiplomaticPact
292            .union(Scopes::TreatyArticle)
293            .union(Scopes::TreatyOptions)
294            .union(Scopes::TreatyArticleOptions)
295            .union(Scopes::Treaty),
296        "second_country",
297        Scopes::Country,
298    ),
299    (
300        Scopes::MilitaryFormation.union(Scopes::TreatyArticle),
301        "shipping_lane",
302        Scopes::ShippingLanes,
303    ),
304    (Scopes::BuildingType, "slaves_role", Scopes::PopType),
305    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "source_country", Scopes::Country),
306    (Scopes::Amendment, "sponsor", Scopes::InterestGroup),
307    (
308        Scopes::Building.union(Scopes::Market).union(Scopes::Pop).union(Scopes::Province),
309        "state",
310        Scopes::State,
311    ),
312    (Scopes::State, "state_region", Scopes::StateRegion),
313    (
314        Scopes::DiplomaticPlay
315            .union(Scopes::DiplomaticCatalyst)
316            .union(Scopes::PoliticalLobby)
317            .union(Scopes::JournalEntry),
318        "target",
319        Scopes::all(),
320    ), // TODO: scope type?
321    (Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions), "target_country", Scopes::Country),
322    (Scopes::Country, "technology_being_researched", Scopes::Technology),
323    (Scopes::Country, "techs_researched", Scopes::Value),
324    (Scopes::BattleSide.union(Scopes::State), "theater", Scopes::Theater),
325    (Scopes::Country, "top_overlord", Scopes::Country),
326    (Scopes::Country, "total_export_value", Scopes::Value),
327    (Scopes::Country, "total_import_value", Scopes::Value),
328    (Scopes::Country, "total_trade_value", Scopes::Value),
329    (Scopes::Market, "trade_center", Scopes::State),
330    (Scopes::Building, "training_rate", Scopes::Value),
331    (Scopes::TreatyArticle, "treaty", Scopes::Treaty),
332    (Scopes::MarketGoods, "treaty_exports", Scopes::Value),
333    (Scopes::MarketGoods, "treaty_imports", Scopes::Value),
334    // The input and output scopes for this are special cased
335    (
336        Scopes::Building
337            .union(Scopes::Company)
338            .union(Scopes::DiplomaticPlay)
339            .union(Scopes::DiplomaticCatalyst)
340            .union(Scopes::PoliticalLobby)
341            .union(Scopes::Institution)
342            .union(Scopes::InterestGroup)
343            .union(Scopes::Law)
344            .union(Scopes::PoliticalMovement)
345            .union(Scopes::HarvestCondition)
346            .union(Scopes::Amendment),
347        "type",
348        Scopes::BuildingType
349            .union(Scopes::CompanyType)
350            .union(Scopes::DiplomaticPlayType)
351            .union(Scopes::DiplomaticCatalystType)
352            .union(Scopes::PoliticalLobbyType)
353            .union(Scopes::InstitutionType)
354            .union(Scopes::InterestGroupType)
355            .union(Scopes::LawType)
356            .union(Scopes::PoliticalMovementType)
357            .union(Scopes::HarvestConditionType)
358            .union(Scopes::AmendmentType),
359    ),
360    (Scopes::DiplomaticPlay, "war", Scopes::War),
361    (Scopes::Company, "weekly_prosperity_change", Scopes::Value),
362    (Scopes::Pop, "workplace", Scopes::Building),
363    (Scopes::State, "world_market_hub", Scopes::State),
364    (Scopes::None, "yes", Scopes::Bool),
365    (Scopes::None, "YES", Scopes::Bool),
366];
367
368#[inline]
369pub fn scope_prefix(name: &str) -> Option<(Scopes, Scopes, ArgumentValue)> {
370    SCOPE_PREFIX_MAP.get(name).copied()
371}
372
373static SCOPE_PREFIX_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, Scopes, ArgumentValue)>> =
374    LazyLock::new(|| {
375        let mut hash = TigerHashMap::default();
376        for (from, s, to, argument) in SCOPE_PREFIX.iter().copied() {
377            hash.insert(s, (from, to, argument));
378        }
379        hash
380    });
381
382/// LAST UPDATED VIC3 VERSION 1.10.0
383/// See `event_targets.log` from the game data dumps
384/// These are absolute scopes (like character:100000) and scope transitions that require
385/// a key (like `root.cp:councillor_steward`)
386const SCOPE_PREFIX: &[(Scopes, &str, Scopes, ArgumentValue)] = {
387    use crate::item::Item;
388    use ArgumentValue::*;
389    &[
390        (Scopes::Country, "active_law", Scopes::Law, Item(Item::LawGroup)),
391        (Scopes::Country, "ai_army_comparison", Scopes::Value, Scope(Scopes::Country)),
392        (Scopes::StrategicRegion, "ai_colonization_value", Scopes::Value, Scope(Scopes::Country)),
393        (Scopes::Country, "ai_gdp_comparison", Scopes::Value, Scope(Scopes::Country)),
394        (Scopes::Country, "ai_ideological_opinion", Scopes::Value, Scope(Scopes::Country)),
395        (Scopes::Country, "ai_navy_comparison", Scopes::Value, Scope(Scopes::Country)),
396        (Scopes::State, "ai_state_value", Scopes::Value, Scope(Scopes::Country)),
397        (Scopes::Country, "ai_subject_value", Scopes::Value, Scope(Scopes::Country)),
398        (Scopes::Country, "ai_transit_rights_value", Scopes::Value, Scope(Scopes::Country)),
399        (Scopes::MarketGoods, "ai_treaty_export_value", Scopes::Value, Scope(Scopes::Country)),
400        (Scopes::Country, "ai_treaty_fairness", Scopes::Value, Scope(Scopes::Country)),
401        (Scopes::MarketGoods, "ai_treaty_import_value", Scopes::Value, Scope(Scopes::Country)),
402        (Scopes::State, "ai_treaty_port_value", Scopes::Value, Scope(Scopes::Country)),
403        (Scopes::MarketGoods, "ai_treaty_trade_value", Scopes::Value, Scope(Scopes::Country)),
404        (Scopes::Country, "ai_treaty_value", Scopes::Value, Scope(Scopes::Country)),
405        (Scopes::None, "amendment_type", Scopes::AmendmentType, Item(Item::Amendment)),
406        (Scopes::None, "array_define", Scopes::Value, UncheckedValue),
407        (Scopes::Front, "average_defense", Scopes::Value, Scope(Scopes::Country)),
408        (Scopes::Front, "average_offense", Scopes::Value, Scope(Scopes::Country)),
409        (Scopes::State, "b", Scopes::Building, Item(Item::BuildingType)),
410        (Scopes::None, "bg", Scopes::BuildingGroup, Item(Item::BuildingGroup)),
411        (Scopes::None, "bt", Scopes::BuildingType, Item(Item::BuildingType)),
412        (Scopes::None, "c", Scopes::Country, Item(Item::Country)),
413        (
414            Scopes::None,
415            "catalyst_type",
416            Scopes::DiplomaticCatalystType,
417            Item(Item::DiplomaticCatalyst),
418        ),
419        (Scopes::None, "cd", Scopes::CountryDefinition, Item(Item::Country)),
420        (Scopes::Country, "company", Scopes::Company, Item(Item::CompanyType)),
421        (Scopes::None, "company_type", Scopes::CompanyType, Item(Item::CompanyType)),
422        (Scopes::None, "cu", Scopes::Culture, Item(Item::Culture)),
423        (Scopes::State, "decree_cost", Scopes::Value, Item(Item::Decree)),
424        (Scopes::None, "define", Scopes::Value, Item(Item::Define)),
425        (Scopes::None, "flag", Scopes::Flag, UncheckedValue),
426        (Scopes::None, "g", Scopes::Goods, Item(Item::Goods)),
427        (Scopes::Country, "get_ruler_for", Scopes::Character, Item(Item::TransferOfPower)),
428        // TODO: figure out how this one works
429        (Scopes::None, "global_productivity", Scopes::Value, Scope(Scopes::Value)),
430        (Scopes::None, "global_var", Scopes::all(), UncheckedValue),
431        (
432            Scopes::None,
433            "harvest_condition_type",
434            Scopes::HarvestConditionType,
435            Item(Item::HarvestConditionType),
436        ),
437        (Scopes::None, "i", Scopes::Ideology, Item(Item::Ideology)),
438        (Scopes::None, "identity", Scopes::PowerBlocIdentity, Item(Item::PowerBlocIdentity)),
439        (Scopes::None, "ideology", Scopes::Ideology, Item(Item::Ideology)), // TODO difference with i:
440        (
441            Scopes::Country.union(Scopes::PoliticalMovement),
442            "ig",
443            Scopes::InterestGroup,
444            Item(Item::InterestGroup),
445        ),
446        (Scopes::None, "ig_trait", Scopes::InterestGroupTrait, Item(Item::InterestGroupTrait)),
447        (Scopes::None, "ig_type", Scopes::InterestGroupType, Item(Item::InterestGroup)),
448        (Scopes::None, "infamy_threshold", Scopes::Value, Item(Item::InfamyThreshold)),
449        (
450            Scopes::TreatyArticle.union(Scopes::TreatyArticleOptions),
451            "input_market_goods",
452            Scopes::MarketGoods,
453            Scope(Scopes::Country),
454        ),
455        (Scopes::Country, "institution", Scopes::Institution, Item(Item::Institution)),
456        (Scopes::Country, "je", Scopes::JournalEntry, Item(Item::JournalEntry)),
457        (Scopes::None, "law_type", Scopes::LawType, Item(Item::LawType)),
458        (Scopes::None, "list_size", Scopes::Value, UncheckedValue),
459        (Scopes::Country, "lobby_foreign_anti_clout", Scopes::Value, Scope(Scopes::Country)),
460        (Scopes::Country, "lobby_foreign_pro_clout", Scopes::Value, Scope(Scopes::Country)),
461        (
462            Scopes::Country,
463            "lobby_in_government_foreign_anti_clout",
464            Scopes::Value,
465            Scope(Scopes::Country),
466        ),
467        (
468            Scopes::Country,
469            "lobby_in_government_foreign_pro_clout",
470            Scopes::Value,
471            Scope(Scopes::Country),
472        ),
473        (Scopes::InterestGroup, "lobby_join_weight", Scopes::Value, Scope(Scopes::PoliticalLobby)),
474        (Scopes::None, "lobby_type", Scopes::PoliticalLobbyType, Item(Item::PoliticalLobby)),
475        (Scopes::Country, "lobby_war_opposition", Scopes::Value, Scope(Scopes::Country)),
476        (Scopes::Country, "lobby_war_support", Scopes::Value, Scope(Scopes::Country)),
477        (Scopes::None, "local_var", Scopes::all(), UncheckedValue),
478        (Scopes::Market, "mg", Scopes::MarketGoods, Item(Item::Goods)),
479        (
480            Scopes::None,
481            "mobilization_option",
482            Scopes::MobilizationOption,
483            Item(Item::MobilizationOption),
484        ),
485        (
486            Scopes::Country
487                .union(Scopes::BattleSide)
488                .union(Scopes::Building)
489                .union(Scopes::Character)
490                .union(Scopes::InterestGroup)
491                .union(Scopes::Market)
492                .union(Scopes::PowerBloc)
493                .union(Scopes::State),
494            "modifier",
495            Scopes::Value.union(Scopes::Bool),
496            Modif,
497        ),
498        (
499            Scopes::None,
500            "movement_type",
501            Scopes::PoliticalMovementType,
502            Item(Item::PoliticalMovement),
503        ),
504        (Scopes::Country, "mutual_trade_value_with_country", Scopes::Value, Scope(Scopes::Country)),
505        (Scopes::State, "nf", Scopes::Decree, Item(Item::Decree)),
506        (
507            Scopes::Country,
508            "num_alliances_and_defensive_pacts_with_allies",
509            Scopes::Value,
510            Scope(Scopes::Country),
511        ),
512        (
513            Scopes::Country,
514            "num_alliances_and_defensive_pacts_with_rivals",
515            Scopes::Value,
516            Scope(Scopes::Country),
517        ),
518        (Scopes::Front, "num_defending_battalions", Scopes::Value, Scope(Scopes::Country)),
519        (Scopes::Country, "num_pending_events", Scopes::Value, Item(Item::EventCategory)),
520        (Scopes::Country, "num_shared_rivals", Scopes::Value, Scope(Scopes::Country)),
521        (Scopes::Front, "num_total_battalions", Scopes::Value, Scope(Scopes::Country)),
522        (Scopes::Province, "num_units", Scopes::Value, Scope(Scopes::Country)),
523        (Scopes::Province, "num_units_in_battle", Scopes::Value, Scope(Scopes::Country)),
524        (Scopes::Province, "num_units_not_in_battle", Scopes::Value, Scope(Scopes::Country)),
525        (Scopes::None, "p", Scopes::Province, Item(Item::Province)),
526        (Scopes::None, "play_type", Scopes::DiplomaticPlayType, Item(Item::DiplomaticPlay)),
527        (Scopes::None, "pop_type", Scopes::PopType, Item(Item::PopType)),
528        (Scopes::None, "principle", Scopes::PowerBlocPrinciple, Item(Item::Principle)),
529        (
530            Scopes::None,
531            "principle_group",
532            Scopes::PowerBlocPrincipleGroup,
533            Item(Item::PrincipleGroup),
534        ),
535        (Scopes::Country, "py", Scopes::Party, Item(Item::Party)),
536        (Scopes::None, "rank_value", Scopes::Value, Item(Item::CountryRank)),
537        (Scopes::StateRegion, "region_state", Scopes::State, Item(Item::Country)), // undocumented
538        (Scopes::None, "rel", Scopes::Religion, Item(Item::Religion)),
539        (Scopes::Country, "relations", Scopes::Value, Scope(Scopes::Country)),
540        (Scopes::Country, "relations_change_rate", Scopes::Value, Scope(Scopes::Country)),
541        (Scopes::None, "relations_threshold", Scopes::Value, Item(Item::RelationsThreshold)),
542        (Scopes::None, "s", Scopes::StateRegion, Item(Item::StateRegion)),
543        (Scopes::None, "scope", Scopes::all(), UncheckedValue),
544        (Scopes::State, "sg", Scopes::StateGoods, Item(Item::Goods)),
545        (Scopes::None, "sr", Scopes::StrategicRegion, Item(Item::StrategicRegion)),
546        (Scopes::Country, "tension", Scopes::Value, Scope(Scopes::Country)),
547        (Scopes::None, "tension_threshold", Scopes::Value, UncheckedValue),
548        (Scopes::None, "unit_type", Scopes::CombatUnitType, Item(Item::CombatUnit)),
549        (Scopes::all(), "var", Scopes::all(), UncheckedValue),
550    ]
551};
552
553pub fn scope_to_scope_removed(name: &str) -> Option<(&'static str, &'static str)> {
554    for (removed_name, version, explanation) in SCOPE_TO_SCOPE_REMOVED.iter().copied() {
555        if name == removed_name {
556            return Some((version, explanation));
557        }
558    }
559    None
560}
561
562const SCOPE_TO_SCOPE_REMOVED: &[(&str, &str, &str)] = &[
563    ("num_commanded_units", "1.6", ""),
564    ("num_enemy_units", "1.6", ""),
565    ("supply", "1.6", ""),
566    ("active_diplomatic_play", "1.7", ""),
567    ("actor_market", "1.9", "replaced by world market system"),
568    ("commander", "1.9", ""),
569    ("exporter", "1.9", "replaced by world market system"),
570    ("importer", "1.9", "replaced by world market system"),
571    ("naval_invasion_attacker", "1.9", "replaced with `invasion_attacker`"),
572    ("naval_invasion_defender", "1.9", "replaced with `invasion_defender`"),
573    ("num_export_trade_routes", "1.9", "replaced by world market system"),
574    ("num_import_trade_routes", "1.9", "replaced by world market system"),
575    ("num_mutual_trade_route_levels_with_country", "1.9", "replaced by world market system"),
576    ("num_trade_routes", "1.9", "replaced by world market system"),
577    ("num_treaty_ports", "1.9", "replaced by world market system"),
578    ("target_market", "1.9", "replaced by world market system"),
579    ("expenses", "1.12", ""),
580    ("fixed_expenses", "1.12", ""),
581];