pub struct MarketBoard {
pub auction_house: AuctionHouse,
pub history: HashMap<String, MarketHistory>,
pub trade_windows: Vec<TradeWindow>,
/* private fields */
}Expand description
Combines the AuctionHouse with a direct trade system and per-item history.
Fields§
§auction_house: AuctionHouse§history: HashMap<String, MarketHistory>§trade_windows: Vec<TradeWindow>Implementations§
Source§impl MarketBoard
impl MarketBoard
pub fn new() -> Self
Sourcepub fn record_sale(&mut self, item_id: &str, time: f32, price_copper: u64)
pub fn record_sale(&mut self, item_id: &str, time: f32, price_copper: u64)
Record a completed sale in the market history.
Sourcepub fn history_for(&self, item_id: &str) -> Option<&MarketHistory>
pub fn history_for(&self, item_id: &str) -> Option<&MarketHistory>
Get market history for an item.
Sourcepub fn open_trade(&mut self, player_a: &str, player_b: &str) -> u64
pub fn open_trade(&mut self, player_a: &str, player_b: &str) -> u64
Open a trade window between two players.
Sourcepub fn get_trade_mut(&mut self, trade_id: u64) -> Option<&mut TradeWindow>
pub fn get_trade_mut(&mut self, trade_id: u64) -> Option<&mut TradeWindow>
Get a mutable reference to a trade window by id.
Sourcepub fn get_trade(&self, trade_id: u64) -> Option<&TradeWindow>
pub fn get_trade(&self, trade_id: u64) -> Option<&TradeWindow>
Get an immutable reference to a trade window by id.
Sourcepub fn cancel_trade(&mut self, trade_id: u64)
pub fn cancel_trade(&mut self, trade_id: u64)
Cancel and remove a trade window.
Sourcepub fn tick(&mut self, current_time: f32)
pub fn tick(&mut self, current_time: f32)
Tick the market board — expires auctions, resolves trades.
Sourcepub fn post_listing(
&mut self,
seller_id: &str,
item_id: &str,
quantity: u32,
quality: u8,
buyout_price: Option<Currency>,
min_bid: Currency,
duration_secs: f32,
current_time: f32,
seller_currency: &mut Currency,
) -> Result<u64, String>
pub fn post_listing( &mut self, seller_id: &str, item_id: &str, quantity: u32, quality: u8, buyout_price: Option<Currency>, min_bid: Currency, duration_secs: f32, current_time: f32, seller_currency: &mut Currency, ) -> Result<u64, String>
Post a listing on the auction house with history tracking.
Trait Implementations§
Source§impl Clone for MarketBoard
impl Clone for MarketBoard
Source§fn clone(&self) -> MarketBoard
fn clone(&self) -> MarketBoard
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MarketBoard
impl Debug for MarketBoard
Auto Trait Implementations§
impl Freeze for MarketBoard
impl RefUnwindSafe for MarketBoard
impl Send for MarketBoard
impl Sync for MarketBoard
impl Unpin for MarketBoard
impl UnsafeUnpin for MarketBoard
impl UnwindSafe for MarketBoard
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.