pub struct TradeWindow {
pub trade_id: u64,
pub player_a_id: u64,
pub player_b_id: u64,
pub player_a_items: Vec<ItemInstance>,
pub player_b_items: Vec<ItemInstance>,
pub player_a_gold: u64,
pub player_b_gold: u64,
pub player_a_confirmed: bool,
pub player_b_confirmed: bool,
pub state: TradeState,
}Fields§
§trade_id: u64§player_a_id: u64§player_b_id: u64§player_a_items: Vec<ItemInstance>§player_b_items: Vec<ItemInstance>§player_a_gold: u64§player_b_gold: u64§player_a_confirmed: bool§player_b_confirmed: bool§state: TradeStateImplementations§
Source§impl TradeWindow
impl TradeWindow
pub fn new(trade_id: u64, player_a: u64, player_b: u64) -> Self
pub fn add_item_a(&mut self, item: ItemInstance, def: &ItemDefinition) -> bool
pub fn add_item_b(&mut self, item: ItemInstance, def: &ItemDefinition) -> bool
pub fn set_gold_a(&mut self, gold: u64)
pub fn set_gold_b(&mut self, gold: u64)
pub fn confirm(&mut self, player_id: u64)
pub fn complete(&mut self) -> bool
pub fn cancel(&mut self)
pub fn value_a(&self, defs: &HashMap<u64, ItemDefinition>) -> u64
pub fn value_b(&self, defs: &HashMap<u64, ItemDefinition>) -> u64
pub fn value_ratio(&self, defs: &HashMap<u64, ItemDefinition>) -> f32
pub fn is_fair_trade( &self, defs: &HashMap<u64, ItemDefinition>, tolerance: f32, ) -> bool
Trait Implementations§
Source§impl Clone for TradeWindow
impl Clone for TradeWindow
Auto Trait Implementations§
impl Freeze for TradeWindow
impl RefUnwindSafe for TradeWindow
impl Send for TradeWindow
impl Sync for TradeWindow
impl Unpin for TradeWindow
impl UnsafeUnpin for TradeWindow
impl UnwindSafe for TradeWindow
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> 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.