Skip to main content

World

Struct World 

Source
pub struct World { /* private fields */ }
Expand description

The anvil-game.world service.

Implementations§

Source§

impl World

Source

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.

Source

pub fn c_api(&self) -> Table<AnvilGameWorldService>

The C table, for what this crate does not wrap.

Source

pub fn player(&self) -> Result<Option<Tag>>

The country the game treats as the player’s (the observed one in observe mode).

Source

pub fn province_limit(&self) -> i32

Valid province IDs are 1..limit; 0 where a call is not allowed.

Source

pub fn province(&self, id: i32) -> Result<Province>

A province.

Source

pub fn province_name(&self, id: i32) -> Result<String>

The name the game displays (it follows the owner’s culture).

Source

pub fn province_cores(&self, id: i32) -> Result<Vec<Tag>>

The tags with a core on the province.

Source

pub fn country(&self, tag: Tag) -> Result<Country>

A country (the tag ignores case).

Source

pub fn country_provinces(&self, tag: Tag) -> Result<Vec<i32>>

The IDs of the provinces a country owns, in the game’s order.

Source

pub fn war_ids(&self) -> Result<Vec<u64>>

The ids of the running wars.

Source

pub fn war(&self, id: u64) -> Result<War>

A running war.

Source

pub fn war_name(&self, id: u64) -> Result<String>

A war’s name as the game shows it.

Source

pub fn war_side(&self, id: u64, side: Side) -> Result<Vec<Tag>>

The countries on one side of a war now.

Source

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.

Source

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).

Source

pub fn province_modifier(&self, province: i32, id: ModifierId) -> Result<Milli>

A province’s own modifier (not its owner’s values).

Source

pub fn country_units(&self, tag: Tag) -> Result<Vec<u64>>

The ids of a country’s armies and navies, in the game’s order.

Source

pub fn unit(&self, tag: Tag, id: u64) -> Result<Unit>

A unit by its country and id.

Source

pub fn unit_name(&self, tag: Tag, id: u64) -> Result<String>

The name the game shows for a unit (“1st Army”).

Source

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.

Source

pub fn selected_units(&self) -> Result<Vec<UnitRef>>

The armies and navies the player has selected, in the game’s order.

Source

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.

Source

pub fn monarch_name(&self, tag: Tag, kind: MonarchKind) -> Result<String>

Their name as the game keeps it; empty in an interregnum.

Source

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).

Source

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.

Source

pub fn flag_name(&self, id: FlagId) -> Result<String>

A flag’s name.

Source

pub fn country_flags(&self, tag: Tag) -> Result<Vec<Flag>>

A country’s flags, with the date each was set.

Source

pub fn province_flags(&self, province: i32) -> Result<Vec<Flag>>

A province’s flags as has_province_flag sees them, its permanent ones included.

Source

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.

Source

pub fn global_flags(&self) -> Result<Vec<Flag>>

The global flags.

Source

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).

Source

pub fn province_variable(&self, province: i32, name: &str) -> Result<Milli>

A province’s variable by its name.

Source

pub fn country_variable_names(&self, tag: Tag) -> Result<Vec<String>>

The names of a country’s variables, in the game’s order.

Source

pub fn province_variable_names(&self, province: i32) -> Result<Vec<String>>

The names of a province’s variables, in the game’s order.

Source

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.

Source

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).

Source

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).

Source

pub fn pending_event_title(&self, pending_id: i32) -> Result<String>

The localisation key of its title, not the translated text.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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.

Source

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.

Source

pub fn country_rivals(&self, tag: Tag) -> Result<Vec<Tag>>

The countries tag has chosen as rivals, in the game’s order.

Source

pub fn country_overlord(&self, tag: Tag) -> Result<Tag>

Its overlord; NotFound also for a country without one.

Source

pub fn country_subjects(&self, tag: Tag) -> Result<Vec<Tag>>

Its direct subjects, in the game’s order.

Source

pub fn player_tags(&self) -> Result<PlayerTags>

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.

Source

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).

Source

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).

Source

pub fn region_key(&self, region: i32) -> Result<String>

The region’s script key, such as baltic_sea_region (anvil-game 1.25.0).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Trait Implementations§

Source§

impl Clone for World

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for World

Source§

impl Debug for World

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for World

§

impl Freeze for World

§

impl Move for World

§

impl RefUnwindSafe for World

§

impl Send for World

§

impl Sync for World

§

impl Unpin for World

§

impl UnsafeUnpin for World

§

impl UnwindSafe for World

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.