pub struct FactionEconomy {
pub current_tick: u64,
pub factions: HashMap<FactionId, Faction>,
pub trade_routes: HashMap<TradeRouteId, TradeRoute>,
pub tribute_agreements: HashMap<TributeAgreementId, TributeAgreement>,
pub espionage_ops: HashMap<EspionageOperationId, EspionageOperation>,
pub espionage_reports: Vec<EspionageReport>,
pub wealth_ranking: Option<WealthRanking>,
/* private fields */
}Expand description
Manages all factions, their trade routes, tribute, reparations, espionage operations, and wealth rankings.
Fields§
§current_tick: u64§factions: HashMap<FactionId, Faction>§trade_routes: HashMap<TradeRouteId, TradeRoute>§tribute_agreements: HashMap<TributeAgreementId, TributeAgreement>§espionage_ops: HashMap<EspionageOperationId, EspionageOperation>§espionage_reports: Vec<EspionageReport>§wealth_ranking: Option<WealthRanking>Implementations§
Source§impl FactionEconomy
impl FactionEconomy
pub fn new() -> Self
pub fn add_faction(&mut self, name: &str, starting_gold: f64) -> FactionId
pub fn faction(&self, id: FactionId) -> Option<&Faction>
pub fn faction_mut(&mut self, id: FactionId) -> Option<&mut Faction>
Sourcepub fn declare_war(&mut self, faction_a: FactionId, faction_b: FactionId)
pub fn declare_war(&mut self, faction_a: FactionId, faction_b: FactionId)
Declare war between two factions (disables existing trade routes between them).
Sourcepub fn end_war(&mut self, faction_a: FactionId, faction_b: FactionId)
pub fn end_war(&mut self, faction_a: FactionId, faction_b: FactionId)
End war between two factions.
pub fn add_trade_route( &mut self, from: FactionId, to: FactionId, base_volume: f64, export_share: f64, import_share: f64, ) -> TradeRouteId
pub fn disrupt_route(&mut self, id: TradeRouteId, severity: f64)
pub fn close_route(&mut self, id: TradeRouteId)
pub fn reopen_route(&mut self, id: TradeRouteId)
pub fn invest_infrastructure(&mut self, id: TradeRouteId, amount: f64)
pub fn impose_embargo( &mut self, imposing: FactionId, target: FactionId, extra_tariff: f64, blocks_trade: bool, asset_freeze: bool, reason: &str, )
pub fn lift_embargo(&mut self, imposing: FactionId, target: FactionId)
pub fn impose_reparations( &mut self, payer: FactionId, receiver: FactionId, total: f64, installment: f64, )
pub fn add_tribute( &mut self, payer: FactionId, receiver: FactionId, amount_per_tick: f64, duration: Option<u64>, coercion_level: f64, rebellion_chance: f64, ) -> TributeAgreementId
Sourcepub fn launch_espionage(
&mut self,
instigator: FactionId,
target: FactionId,
objective: EspionageObjective,
success_probability: f64,
duration_ticks: u64,
) -> EspionageOperationId
pub fn launch_espionage( &mut self, instigator: FactionId, target: FactionId, objective: EspionageObjective, success_probability: f64, duration_ticks: u64, ) -> EspionageOperationId
Launch an espionage operation. It completes after duration_ticks.
pub fn compute_wealth_ranking(&mut self)
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Advance the faction economy by one tick.
- Ticks all trade routes and distributes income.
- Processes reparation installments.
- Processes tribute payments.
- Collects trade taxes.
- Decays disinformation penalties.
- Resolves completed espionage operations.
- Recomputes wealth rankings.
Sourcepub fn routes_for_faction(&self, faction: FactionId) -> Vec<&TradeRoute>
pub fn routes_for_faction(&self, faction: FactionId) -> Vec<&TradeRoute>
All trade routes involving a specific faction.
Sourcepub fn global_gdp(&self) -> f64
pub fn global_gdp(&self) -> f64
Total GDP proxy across all factions.
Sourcepub fn dominant_faction(&self) -> Option<FactionId>
pub fn dominant_faction(&self) -> Option<FactionId>
Dominant faction (highest gold).
Sourcepub fn active_embargoes(&self, faction: FactionId) -> Vec<&EmbargoPenalty>
pub fn active_embargoes(&self, faction: FactionId) -> Vec<&EmbargoPenalty>
Active embargoes imposed by a faction.
Sourcepub fn reports_for(&self, faction: FactionId) -> Vec<&EspionageReport>
pub fn reports_for(&self, faction: FactionId) -> Vec<&EspionageReport>
Espionage reports involving a faction (as instigator or target).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FactionEconomy
impl RefUnwindSafe for FactionEconomy
impl Send for FactionEconomy
impl Sync for FactionEconomy
impl Unpin for FactionEconomy
impl UnsafeUnpin for FactionEconomy
impl UnwindSafe for FactionEconomy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more