osu: remove pp builder method for star_function
This commit is contained in:
+6
-22
@@ -30,8 +30,6 @@ pub struct PpCalculator<'m> {
|
|||||||
n100: Option<usize>,
|
n100: Option<usize>,
|
||||||
n50: Option<usize>,
|
n50: Option<usize>,
|
||||||
n_misses: usize,
|
n_misses: usize,
|
||||||
|
|
||||||
stars_func: Option<Box<dyn Fn(&Beatmap, u32) -> Attributes>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'m> PpCalculator<'m> {
|
impl<'m> PpCalculator<'m> {
|
||||||
@@ -48,8 +46,6 @@ impl<'m> PpCalculator<'m> {
|
|||||||
n100: None,
|
n100: None,
|
||||||
n50: None,
|
n50: None,
|
||||||
n_misses: 0,
|
n_misses: 0,
|
||||||
|
|
||||||
stars_func: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,13 +98,6 @@ impl<'m> PpCalculator<'m> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn stars_function(mut self, func: impl Fn(&Beatmap, u32) -> Attributes + 'static) -> Self {
|
|
||||||
self.stars_func.replace(Box::new(func));
|
|
||||||
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate the hit results with respect to the given accuracy between `0` and `100`.
|
/// Generate the hit results with respect to the given accuracy between `0` and `100`.
|
||||||
///
|
///
|
||||||
/// Be sure to set `misses` beforehand!
|
/// Be sure to set `misses` beforehand!
|
||||||
@@ -154,18 +143,13 @@ impl<'m> PpCalculator<'m> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn calculate(mut self) -> PpResult {
|
/// Consume the calculator and calculate the pp.
|
||||||
|
///
|
||||||
|
/// `stars_func` will be used to calculate stars and other necessary attributes if not already given.
|
||||||
|
pub fn calculate(mut self, stars_func: impl FnOnce(&Beatmap, u32) -> Attributes) -> PpResult {
|
||||||
if self.attributes.is_none() {
|
if self.attributes.is_none() {
|
||||||
let stars_func = self
|
let attributes = stars_func(self.map, self.mods);
|
||||||
.stars_func
|
self.attributes.replace(attributes);
|
||||||
.take()
|
|
||||||
.unwrap_or_else(|| Box::new(super::no_sliders_no_leniency::stars));
|
|
||||||
|
|
||||||
let attribtes = stars_func(self.map, self.mods);
|
|
||||||
|
|
||||||
// println!("> stars={}", attribtes.stars);
|
|
||||||
|
|
||||||
self.attributes.replace(attribtes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.acc.is_none() {
|
if self.acc.is_none() {
|
||||||
|
|||||||
@@ -226,8 +226,8 @@ mod tests {
|
|||||||
Err(why) => panic!("Error while parsing map: {}", why),
|
Err(why) => panic!("Error while parsing map: {}", why),
|
||||||
};
|
};
|
||||||
|
|
||||||
let calculator = PpCalculator::new(&map).mods(0).stars_function(stars);
|
let calculator = PpCalculator::new(&map).mods(0);
|
||||||
let result = calculator.calculate();
|
let result = calculator.calculate(stars);
|
||||||
|
|
||||||
println!("PP: {}", result.pp);
|
println!("PP: {}", result.pp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,8 +229,8 @@ mod tests {
|
|||||||
Err(why) => panic!("Error while parsing map: {}", why),
|
Err(why) => panic!("Error while parsing map: {}", why),
|
||||||
};
|
};
|
||||||
|
|
||||||
let calculator = PpCalculator::new(&map).mods(0).stars_function(stars);
|
let calculator = PpCalculator::new(&map).mods(0);
|
||||||
let result = calculator.calculate();
|
let result = calculator.calculate(stars);
|
||||||
|
|
||||||
println!("PP: {}", result.pp);
|
println!("PP: {}", result.pp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,14 +315,13 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let calculator = PpCalculator::new(&map)
|
let calculator = PpCalculator::new(&map)
|
||||||
.stars_function(stars)
|
|
||||||
// .misses(2)
|
// .misses(2)
|
||||||
// .accuracy(96.78)
|
// .accuracy(96.78)
|
||||||
// .combo(100)
|
// .combo(100)
|
||||||
// .n100(0)
|
// .n100(0)
|
||||||
.mods(0);
|
.mods(0);
|
||||||
|
|
||||||
let result = calculator.calculate();
|
let result = calculator.calculate(stars);
|
||||||
|
|
||||||
println!("Stars: {}", result.attributes.stars);
|
println!("Stars: {}", result.attributes.stars);
|
||||||
println!("PP: {}", result.pp);
|
println!("PP: {}", result.pp);
|
||||||
|
|||||||
Reference in New Issue
Block a user