pub struct CraftingCalculator;Expand description
Computes actual output values given player stats.
Implementations§
Source§impl CraftingCalculator
impl CraftingCalculator
Sourcepub fn calculate_quality(base: u8, skill_level: u32, tool_bonus: u32) -> u8
pub fn calculate_quality(base: u8, skill_level: u32, tool_bonus: u32) -> u8
Compute the actual output quality (0–255) from base quality, skill, and tool bonus.
Formula: clamp(base + skill_bonus + tool_bonus, 0, 255) where skill_bonus = skill_level * 0.4 (capped at +80)
Sourcepub fn calculate_quantity(base: u32, skill_level: u32, luck: f32) -> u32
pub fn calculate_quantity(base: u32, skill_level: u32, luck: f32) -> u32
Compute the actual output quantity from base quantity, skill level, and luck.
Uses linear interpolation a + t * (b - a) where a = base, b = base * 2,
t is derived from skill_level and luck.
Sourcepub fn calculate_duration(base: f32, skill_level: u32, tool_speed: f32) -> f32
pub fn calculate_duration(base: f32, skill_level: u32, tool_speed: f32) -> f32
Compute the actual crafting duration (seconds) from base duration, skill, and tool speed.
Higher skill and tool speed reduce the duration (capped at 10% of base).
Sourcepub fn evaluate_chance(result: &CraftResult, skill_level: u32, rng: f32) -> bool
pub fn evaluate_chance(result: &CraftResult, skill_level: u32, rng: f32) -> bool
Evaluate whether a probabilistic CraftResult fires given skill and rng value (0..1).
Sourcepub fn calculate_experience(base_xp: u32, quality: u8) -> u32
pub fn calculate_experience(base_xp: u32, quality: u8) -> u32
Compute XP gained for completing a recipe, boosted by quality.
Trait Implementations§
Source§impl Clone for CraftingCalculator
impl Clone for CraftingCalculator
Source§fn clone(&self) -> CraftingCalculator
fn clone(&self) -> CraftingCalculator
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 moreAuto Trait Implementations§
impl Freeze for CraftingCalculator
impl RefUnwindSafe for CraftingCalculator
impl Send for CraftingCalculator
impl Sync for CraftingCalculator
impl Unpin for CraftingCalculator
impl UnsafeUnpin for CraftingCalculator
impl UnwindSafe for CraftingCalculator
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.