use crate::ROOT;
use std::ops::RangeInclusive;
#[derive(Clone)]
pub struct Drop {
pub path: Option<&'static str>,
pub depth: i16,
pub luck: f32,
pub stack: RangeInclusive<u32>,
pub modify: bool,
}
impl Default for Drop {
fn default() -> Self {
Self {
path: ROOT,
depth: 1,
luck: 1.0,
stack: 1..=1,
modify: false,
}
}
}
pub struct DropBuilder {
pub path: Option<&'static str>,
pub depth: i16,
pub luck: f32,
pub stack: RangeInclusive<u32>,
pub modify: bool,
}
impl Default for DropBuilder {
fn default() -> Self {
Self::new()
}
}
impl DropBuilder {
pub fn new() -> DropBuilder {
DropBuilder {
path: ROOT,
depth: 1,
luck: f32::MAX,
stack: 1..=1,
modify: false,
}
}
pub fn path(mut self, path: &'static str) -> DropBuilder {
self.path = Some(path);
self
}
pub fn luck(mut self, luck: f32) -> DropBuilder {
self.luck = luck;
self
}
pub fn depth(mut self, depth: i16) -> DropBuilder {
self.depth = depth;
self
}
pub fn anydepth(mut self) -> DropBuilder {
self.depth = i16::MAX;
self
}
pub fn stack(mut self, stack: RangeInclusive<u32>) -> DropBuilder {
self.stack = stack;
self
}
pub fn modify(mut self) -> DropBuilder {
self.modify = true;
self
}
pub fn build(&self) -> Drop {
Drop {
path: self.path,
depth: self.depth,
luck: self.luck,
stack: self.stack.clone(),
modify: self.modify,
}
}
}