pub struct World { /* private fields */ }Expand description
The anvil-game.world service.
Implementations§
Source§impl World
impl World
Sourcepub fn get(host: &Host) -> Option<Self>
pub fn get(host: &Host) -> Option<Self>
The service; None without anvil-game 1.11.0 or on a game build whose
symbols for it are declared absent.
Sourcepub fn c_api(&self) -> Table<AnvilGameWorldService>
pub fn c_api(&self) -> Table<AnvilGameWorldService>
The C table, for what this crate does not wrap.
Sourcepub fn player(&self) -> Result<Option<Tag>>
pub fn player(&self) -> Result<Option<Tag>>
The country the game treats as the player’s (the observed one in observe mode).
Sourcepub fn province_limit(&self) -> i32
pub fn province_limit(&self) -> i32
Valid province IDs are 1..limit; 0 where a call is not allowed.
Sourcepub fn province_name(&self, id: i32) -> Result<String>
pub fn province_name(&self, id: i32) -> Result<String>
The name the game displays (it follows the owner’s culture).
Sourcepub fn province_cores(&self, id: i32) -> Result<Vec<Tag>>
pub fn province_cores(&self, id: i32) -> Result<Vec<Tag>>
The tags with a core on the province.
Sourcepub fn country_provinces(&self, tag: Tag) -> Result<Vec<i32>>
pub fn country_provinces(&self, tag: Tag) -> Result<Vec<i32>>
The IDs of the provinces a country owns, in the game’s order.
Sourcepub fn war_side(&self, id: u64, side: Side) -> Result<Vec<Tag>>
pub fn war_side(&self, id: u64, side: Side) -> Result<Vec<Tag>>
The countries on one side of a war now.
Sourcepub fn modifier_id(&self, key: &str) -> Result<ModifierId>
pub fn modifier_id(&self, key: &str) -> Result<ModifierId>
The id of a modifier from its script key (land_morale,
local_tax_modifier), case included. It holds as long as the game
runs: ask once, as this walks every definition.
Sourcepub fn country_modifier(&self, tag: Tag, id: ModifierId) -> Result<Milli>
pub fn country_modifier(&self, tag: Tag, id: ModifierId) -> Result<Milli>
A country’s modifier as the game uses it (a yes-or-no one is 1000 or 0).
Sourcepub fn province_modifier(&self, province: i32, id: ModifierId) -> Result<Milli>
pub fn province_modifier(&self, province: i32, id: ModifierId) -> Result<Milli>
A province’s own modifier (not its owner’s values).
Sourcepub fn country_units(&self, tag: Tag) -> Result<Vec<u64>>
pub fn country_units(&self, tag: Tag) -> Result<Vec<u64>>
The ids of a country’s armies and navies, in the game’s order.
Sourcepub fn unit_name(&self, tag: Tag, id: u64) -> Result<String>
pub fn unit_name(&self, tag: Tag, id: u64) -> Result<String>
The name the game shows for a unit (“1st Army”).
Sourcepub fn unit_leader_name(&self, tag: Tag, id: u64) -> Result<String>
pub fn unit_leader_name(&self, tag: Tag, id: u64) -> Result<String>
A unit’s leader’s name; NotFound also for a unit without one.
Sourcepub fn selected_units(&self) -> Result<Vec<UnitRef>>
pub fn selected_units(&self) -> Result<Vec<UnitRef>>
The armies and navies the player has selected, in the game’s order.
Sourcepub fn monarch(&self, tag: Tag, kind: MonarchKind) -> Result<Monarch>
pub fn monarch(&self, tag: Tag, kind: MonarchKind) -> Result<Monarch>
A country’s ruler, heir or consort. NotFound when it has none: the
game then holds a placeholder that every such country shares, and the
service never reads it. A country no longer on the map keeps its last
ruler: check Country::province_count when that matters.
Sourcepub fn monarch_name(&self, tag: Tag, kind: MonarchKind) -> Result<String>
pub fn monarch_name(&self, tag: Tag, kind: MonarchKind) -> Result<String>
Their name as the game keeps it; empty in an interregnum.
Sourcepub fn monarch_dynasty(&self, tag: Tag, kind: MonarchKind) -> Result<String>
pub fn monarch_dynasty(&self, tag: Tag, kind: MonarchKind) -> Result<String>
Their dynasty as the game shows it (a regency council shows the heir’s).
Sourcepub fn flag_id(&self, name: &str) -> Result<FlagId>
pub fn flag_id(&self, name: &str) -> Result<FlagId>
The id of a flag from its name, case included. It holds as long as the
game runs: ask once. NotFound for a name nothing has set yet in this
run of the game.
Sourcepub fn country_flags(&self, tag: Tag) -> Result<Vec<Flag>>
pub fn country_flags(&self, tag: Tag) -> Result<Vec<Flag>>
A country’s flags, with the date each was set.
Sourcepub fn province_flags(&self, province: i32) -> Result<Vec<Flag>>
pub fn province_flags(&self, province: i32) -> Result<Vec<Flag>>
A province’s flags as has_province_flag sees them, its permanent ones included.
Sourcepub fn monarch_flags(&self, tag: Tag, kind: MonarchKind) -> Result<Vec<Flag>>
pub fn monarch_flags(&self, tag: Tag, kind: MonarchKind) -> Result<Vec<Flag>>
A ruler’s, heir’s or consort’s flags; NotFound as for World::monarch.
Sourcepub fn global_flags(&self) -> Result<Vec<Flag>>
pub fn global_flags(&self) -> Result<Vec<Flag>>
The global flags.
Sourcepub fn country_variable(&self, tag: Tag, name: &str) -> Result<Milli>
pub fn country_variable(&self, tag: Tag, name: &str) -> Result<Milli>
A country’s variable by its name, case included. NotFound when it
has none of that name (the game’s triggers take that as 0).
Sourcepub fn province_variable(&self, province: i32, name: &str) -> Result<Milli>
pub fn province_variable(&self, province: i32, name: &str) -> Result<Milli>
A province’s variable by its name.
Sourcepub fn country_variable_names(&self, tag: Tag) -> Result<Vec<String>>
pub fn country_variable_names(&self, tag: Tag) -> Result<Vec<String>>
The names of a country’s variables, in the game’s order.
Sourcepub fn province_variable_names(&self, province: i32) -> Result<Vec<String>>
pub fn province_variable_names(&self, province: i32) -> Result<Vec<String>>
The names of a province’s variables, in the game’s order.
Sourcepub fn pending_events(&self, tag: Option<Tag>) -> Result<Vec<i32>>
pub fn pending_events(&self, tag: Option<Tag>) -> Result<Vec<i32>>
The ids of the events waiting for a country’s choice, in the game’s
order; None for the player’s own country (NotFound in observe
mode). An entry counts once it was in the game’s list at two outer
frames in a row, which leaves out an AI’s choices and hidden events.
Key on the id: the same event can wait twice.
Sourcepub fn pending_event(&self, pending_id: i32) -> Result<PendingEvent>
pub fn pending_event(&self, pending_id: i32) -> Result<PendingEvent>
A waiting event; NotFound for an id that is not waiting (or not yet counted).
Sourcepub fn pending_event_key(&self, pending_id: i32) -> Result<String>
pub fn pending_event_key(&self, pending_id: i32) -> Result<String>
The waiting event’s key as the game’s files name it (flavor_tur.203).
Sourcepub fn pending_event_title(&self, pending_id: i32) -> Result<String>
pub fn pending_event_title(&self, pending_id: i32) -> Result<String>
The localisation key of its title, not the translated text.
Sourcepub fn country_statistics(
&self,
tag: Tag,
kind: StatisticKind,
) -> Result<Vec<StatisticPoint>>
pub fn country_statistics( &self, tag: Tag, kind: StatisticKind, ) -> Result<Vec<StatisticPoint>>
A country’s yearly series of the game’s graphs, oldest first. It
changes only at game::YEAR. NotFound for a tag
without a series (none has one before its first year end).
Sourcepub fn country_timed_modifiers(&self, tag: Tag) -> Result<Vec<TimedModifier>>
pub fn country_timed_modifiers(&self, tag: Tag) -> Result<Vec<TimedModifier>>
A country’s timed modifiers, in the game’s order, each with its key. Call it on the main thread, as every read: the list and the keys come from two calls of the service in the same frame.
Sourcepub fn province_timed_modifiers(
&self,
province: i32,
) -> Result<Vec<TimedModifier>>
pub fn province_timed_modifiers( &self, province: i32, ) -> Result<Vec<TimedModifier>>
A province’s timed modifiers, in the game’s order, each with its key.
Sourcepub fn province_view(&self) -> Result<i32>
pub fn province_view(&self) -> Result<i32>
The province the game’s province view shows while that window is
open; NotFound while none is open.
Sourcepub fn selected_province(&self) -> Result<i32>
pub fn selected_province(&self) -> Result<i32>
The province last selected on the map; 0 while none has been selected in this session (anvil-game 1.24.0).
Sourcepub fn province_at(&self, x: i32, y: i32) -> Result<i32>
pub fn province_at(&self, x: i32, y: i32) -> Result<i32>
The province under the point (x, y) of the game window’s client
area, in pixels, as the game’s hover finds it; 0 off the map
(anvil-game 1.24.0).
Sourcepub fn unit_at(&self, x: i32, y: i32) -> Result<UnitRef>
pub fn unit_at(&self, x: i32, y: i32) -> Result<UnitRef>
The army or navy the map picks at the same point, as the game’s
cursor does; NotFound when it picks no unit there (anvil-game 1.24.0).
Sourcepub fn province_triggered_modifiers(&self, province: i32) -> Result<Vec<String>>
pub fn province_triggered_modifiers(&self, province: i32) -> Result<Vec<String>>
The keys of the province triggered modifiers a province has been given
(add_province_triggered_modifier), in the game’s order, whether or
not their triggers hold now. With
province_timed_modifiers they are
every key has_province_modifier looks for (anvil-game 1.25.0).
Sourcepub fn country_relations(
&self,
tag: Tag,
kind: RelationKind,
) -> Result<Vec<Relation>>
pub fn country_relations( &self, tag: Tag, kind: RelationKind, ) -> Result<Vec<Relation>>
A country’s relations of one kind, in the game’s order (anvil-game 1.22.0).
Sourcepub fn subject_type(&self, overlord: Tag, subject: Tag) -> Result<String>
pub fn subject_type(&self, overlord: Tag, subject: Tag) -> Result<String>
The key of subject’s subject type under overlord (vassal,
march); NotFound when it is not overlord’s subject.
Sourcepub fn diplomacy_status(&self, from: Tag, to: Tag) -> Result<DiplomacyStatus>
pub fn diplomacy_status(&self, from: Tag, to: Tag) -> Result<DiplomacyStatus>
What from keeps about to, with its opinion from the game’s cache.
NotFound for a country that owns no province now and while the cache
has no entry for to yet; InvalidArgument for the same country twice.
Sourcepub fn country_rivals(&self, tag: Tag) -> Result<Vec<Tag>>
pub fn country_rivals(&self, tag: Tag) -> Result<Vec<Tag>>
The countries tag has chosen as rivals, in the game’s order.
Sourcepub fn country_overlord(&self, tag: Tag) -> Result<Tag>
pub fn country_overlord(&self, tag: Tag) -> Result<Tag>
Its overlord; NotFound also for a country without one.
Sourcepub fn country_subjects(&self, tag: Tag) -> Result<Vec<Tag>>
pub fn country_subjects(&self, tag: Tag) -> Result<Vec<Tag>>
Its direct subjects, in the game’s order.
What World::player answers and the two tags it is chosen from, read
at once (anvil-game 1.23.0). In a normal game tag and own are the
player’s country and observed is as the game stores it: usually None,
but it can hold a tag left over; in observe mode own is the
observer’s pseudo-country and tag the observed country while there is
one.
Sourcepub fn exploration_regions(
&self,
fleet: &UnitRef,
list: ExplorationList,
) -> Result<Vec<i32>>
pub fn exploration_regions( &self, fleet: &UnitRef, list: ExplorationList, ) -> Result<Vec<i32>>
The regions the fleet may explore, as the game’s naval exploration
dialog lists them: each region once, in the game’s order. It calls the
dialog’s own function and changes nothing; InvalidArgument for an
army (anvil-game 1.25.0).
Sourcepub fn region_name(&self, region: i32) -> Result<String>
pub fn region_name(&self, region: i32) -> Result<String>
The region’s name as the game shows it, in the game’s language (anvil-game 1.25.0).
Sourcepub fn region_key(&self, region: i32) -> Result<String>
pub fn region_key(&self, region: i32) -> Result<String>
The region’s script key, such as baltic_sea_region (anvil-game 1.25.0).
Sourcepub fn province_religion(&self, province: i32) -> Result<String>
pub fn province_religion(&self, province: i32) -> Result<String>
The script key of a province’s religion, such as orthodox;
NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_culture(&self, province: i32) -> Result<String>
pub fn province_culture(&self, province: i32) -> Result<String>
The script key of a province’s culture, such as russian; NotFound
when it has none (anvil-game 1.26.0).
Sourcepub fn province_trade_goods(&self, province: i32) -> Result<String>
pub fn province_trade_goods(&self, province: i32) -> Result<String>
The script key of a province’s trade goods, such as grain;
NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn country_religion(&self, tag: Tag) -> Result<String>
pub fn country_religion(&self, tag: Tag) -> Result<String>
The script key of a country’s state religion; NotFound when it has
none (anvil-game 1.26.0).
Sourcepub fn country_culture(&self, tag: Tag) -> Result<String>
pub fn country_culture(&self, tag: Tag) -> Result<String>
The script key of a country’s primary culture; NotFound when it has
none (anvil-game 1.26.0).
Sourcepub fn province_religion_group(&self, province: i32) -> Result<String>
pub fn province_religion_group(&self, province: i32) -> Result<String>
The script key of the group of a province’s religion, such as
christian; NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_culture_group(&self, province: i32) -> Result<String>
pub fn province_culture_group(&self, province: i32) -> Result<String>
The script key of the group of a province’s culture, such as
east_slavic; NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_area(&self, province: i32) -> Result<String>
pub fn province_area(&self, province: i32) -> Result<String>
The script key of a province’s area, such as uppland_area;
NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_region(&self, province: i32) -> Result<String>
pub fn province_region(&self, province: i32) -> Result<String>
The script key of a province’s region, such as scandinavia_region;
NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_superregion(&self, province: i32) -> Result<String>
pub fn province_superregion(&self, province: i32) -> Result<String>
The script key of a province’s superregion, such as
europe_superregion; NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_continent(&self, province: i32) -> Result<String>
pub fn province_continent(&self, province: i32) -> Result<String>
The script key of a province’s continent, such as europe;
NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn province_trade_node(&self, province: i32) -> Result<String>
pub fn province_trade_node(&self, province: i32) -> Result<String>
The script key of a province’s trade node, such as baltic_sea;
NotFound when it has none (anvil-game 1.26.0).
Sourcepub fn country_religion_group(&self, tag: Tag) -> Result<String>
pub fn country_religion_group(&self, tag: Tag) -> Result<String>
The script key of the group of a country’s state religion; NotFound
when it has none (anvil-game 1.26.0).
Sourcepub fn country_culture_group(&self, tag: Tag) -> Result<String>
pub fn country_culture_group(&self, tag: Tag) -> Result<String>
The script key of the group of a country’s primary culture; NotFound
when it has none (anvil-game 1.26.0).