Skip to main content

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