pub struct ShopInventory {
pub shop_id: String,
pub shop_name: String,
pub faction_id: String,
pub region_id: String,
pub tax_system: TaxSystem,
/* private fields */
}Expand description
A merchant’s shop with items, buying, selling, and restocking.
Fields§
§shop_id: String§shop_name: String§faction_id: String§region_id: StringRegion the shop is in (for tax purposes).
tax_system: TaxSystemImplementations§
Source§impl ShopInventory
impl ShopInventory
pub fn new( shop_id: impl Into<String>, shop_name: impl Into<String>, faction_id: impl Into<String>, region_id: impl Into<String>, ) -> Self
Sourcepub fn buy(
&mut self,
item_id: &str,
qty: u32,
player_currency: &mut Currency,
player_rep: f32,
) -> Result<Currency, String>
pub fn buy( &mut self, item_id: &str, qty: u32, player_currency: &mut Currency, player_rep: f32, ) -> Result<Currency, String>
Player buys qty units of item_id from the shop.
player_currency is modified in place.
Returns Ok(total_cost) or Err with a description.
Trait Implementations§
Source§impl Clone for ShopInventory
impl Clone for ShopInventory
Auto Trait Implementations§
impl Freeze for ShopInventory
impl RefUnwindSafe for ShopInventory
impl Send for ShopInventory
impl Sync for ShopInventory
impl Unpin for ShopInventory
impl UnsafeUnpin for ShopInventory
impl UnwindSafe for ShopInventory
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.