Skip to main content

MarketSystem

Struct MarketSystem 

Source
pub struct MarketSystem<H: MarketHook> { /* private fields */ }
Expand description

Market system (orchestrates market updates)

This system coordinates between service (pure logic), state (mutable data), and hooks (game-specific customization).

Implementations§

Source§

impl<H: MarketHook> MarketSystem<H>

Source

pub fn new(hook: H) -> Self

Create a new market system with hook

Source

pub async fn update_prices( &self, state: &mut MarketState, config: &MarketConfig, ) -> Vec<PriceChange>

Update all market prices

This performs a full market update:

  1. Calculate new prices from supply/demand
  2. Apply equilibrium drift
  3. Detect trends
  4. Call hooks
§Arguments
  • state - Mutable market state
  • config - Market configuration
§Returns

Vector of price changes that occurred

Source

pub async fn apply_event( &self, event: MarketEvent, state: &mut MarketState, config: &MarketConfig, )

Apply a market event

§Arguments
  • event - Market event to apply
  • state - Mutable market state
  • config - Market configuration
Source

pub fn get_items_by_trend( state: &MarketState, trend: MarketTrend, ) -> Vec<ItemId>

Get items with specific trend

§Arguments
  • state - Market state
  • trend - Trend to filter by
§Returns

Vector of item IDs matching the trend

Source

pub fn set_demand_supply( state: &mut MarketState, item_id: &ItemId, demand: Option<f32>, supply: Option<f32>, )

Manually set demand/supply for an item

§Arguments
  • state - Mutable market state
  • item_id - Item to update
  • demand - New demand value (None = unchanged)
  • supply - New supply value (None = unchanged)
Source

pub fn get_market_summary(state: &MarketState) -> (f32, usize, usize)

Get market summary statistics

§Arguments
  • state - Market state
§Returns

Tuple of (average_price, total_items, volatile_items_count)

Auto Trait Implementations§

§

impl<H> Freeze for MarketSystem<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for MarketSystem<H>
where H: RefUnwindSafe,

§

impl<H> Send for MarketSystem<H>

§

impl<H> Sync for MarketSystem<H>

§

impl<H> Unpin for MarketSystem<H>
where H: Unpin,

§

impl<H> UnsafeUnpin for MarketSystem<H>
where H: UnsafeUnpin,

§

impl<H> UnwindSafe for MarketSystem<H>
where H: UnwindSafe,

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> Component for T
where T: Send + Sync + 'static,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> RuntimeResourceEntry for T
where T: 'static + Send + Sync,

Source§

fn insert(self: Box<T>, ctx: &mut ResourceContext)

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V