pub struct Lootr<'a> { /* private fields */ }
Implementations§
Source§impl<'a> Lootr<'a>
impl<'a> Lootr<'a>
Sourcepub fn self_count(&self) -> usize
pub fn self_count(&self) -> usize
Return this lootbag items count (at this level)
Sourcepub fn add(&mut self, item: Item<'a>) -> &mut Self
pub fn add(&mut self, item: Item<'a>) -> &mut Self
Add an item at this level
Returns the current lootbag
Sourcepub fn add_in(&mut self, item: Item<'a>, path: &'a str) -> &mut Self
pub fn add_in(&mut self, item: Item<'a>, path: &'a str) -> &mut Self
Add an item in the given branch
Returns the current lootbag
Sourcepub fn branch_mut(&mut self, path: &'a str) -> Option<&mut Lootr<'a>>
pub fn branch_mut(&mut self, path: &'a str) -> Option<&mut Lootr<'a>>
Returns the branch at the given path.
Sourcepub fn branch(&self, path: &'a str) -> Option<&Lootr<'a>>
pub fn branch(&self, path: &'a str) -> Option<&Lootr<'a>>
Returns the branch at the given path.
If the branch does not exit yet, None
is returned
Sourcepub fn add_branch(&mut self, path: &'a str, branch: Lootr<'a>) -> &mut Self
pub fn add_branch(&mut self, path: &'a str, branch: Lootr<'a>) -> &mut Self
Add a branch, return self (the owner)
Sourcepub fn add_modifier(&mut self, modifier: Modifier) -> &mut Self
pub fn add_modifier(&mut self, modifier: Modifier) -> &mut Self
Add a modifier
Sourcepub fn roll(
&self,
catalog_path: Option<&'a str>,
nesting: i16,
threshold: f32,
) -> Option<&Item<'_>>
pub fn roll( &self, catalog_path: Option<&'a str>, nesting: i16, threshold: f32, ) -> Option<&Item<'_>>
Pick a random item from the specified branch
Returns Some(Item)
or None
Sourcepub fn roll_seeded<R>(
&self,
catalog_path: Option<&'a str>,
nesting: i16,
threshold: f32,
rng: &mut R,
) -> Option<&Item<'a>>
pub fn roll_seeded<R>( &self, catalog_path: Option<&'a str>, nesting: i16, threshold: f32, rng: &mut R, ) -> Option<&Item<'a>>
Pick a random item from the specified branch, given a PRNG
Returns Some(Item)
or None
Sourcepub fn roll_any(&self) -> Option<&Item<'_>>
pub fn roll_any(&self) -> Option<&Item<'_>>
Pick a random item anywhere in that branch
Returns Some(Item)
or None
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Lootr<'a>
impl<'a> RefUnwindSafe for Lootr<'a>
impl<'a> Send for Lootr<'a>
impl<'a> Sync for Lootr<'a>
impl<'a> Unpin for Lootr<'a>
impl<'a> UnwindSafe for Lootr<'a>
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