Struct MerchantOffer
#[non_exhaustive]pub struct MerchantOffer {
pub base_cost_a: ItemCost,
pub cost_b: Option<ItemCost>,
pub result: ItemStack,
pub uses: i32,
pub max_uses: i32,
pub reward_exp: bool,
pub special_price_diff: i32,
pub demand: i32,
pub price_multiplier: f32,
pub xp: i32,
}Expand description
A merchant offer copied at an API boundary, not a reference into the game’s trade table.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.base_cost_a: ItemCostUndiscounted first payment.
cost_b: Option<ItemCost>Optional second payment.
result: ItemStackItems received in exchange.
uses: i32Trades already performed since restocking.
max_uses: i32Trades allowed before the offer is out of stock.
reward_exp: boolWhether completing this trade awards experience.
special_price_diff: i32Player-specific price adjustment.
demand: i32Demand accumulated during restocking.
price_multiplier: f32Multiplier for demand and reputation price adjustments.
xp: i32Villager experience awarded by this trade.
Implementations§
§impl MerchantOffer
impl MerchantOffer
pub fn new(
base_cost_a: ItemCost,
cost_b: Option<ItemCost>,
result: ItemStack,
max_uses: i32,
xp: i32,
price_multiplier: f32,
) -> MerchantOffer
pub fn new( base_cost_a: ItemCost, cost_b: Option<ItemCost>, result: ItemStack, max_uses: i32, xp: i32, price_multiplier: f32, ) -> MerchantOffer
Construct an unused offer with explicit payments, output, limits and experience. Discounts and demand begin at zero; completing it rewards experience.
pub fn cost_a_count(&self, host: &dyn Host) -> Option<u32>
pub fn cost_a_count(&self, host: &dyn Host) -> Option<u32>
The adjusted first payment count, or none if its item metadata is unavailable.
pub fn cost_a(&self, host: &dyn Host) -> Option<ItemStack>
pub fn cost_a(&self, host: &dyn Host) -> Option<ItemStack>
First payment with demand and discounts applied.
pub fn out_of_stock(&self) -> bool
pub fn out_of_stock(&self) -> bool
Whether this offer has exhausted its uses.
pub fn update_demand(&mut self)
pub fn update_demand(&mut self)
Apply MerchantOffer.updateDemand to this snapshot.
Trait Implementations§
§impl Clone for MerchantOffer
impl Clone for MerchantOffer
§fn clone(&self) -> MerchantOffer
fn clone(&self) -> MerchantOffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more