added ScoreState::total_hits
This commit is contained in:
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
## Upcoming
|
## Upcoming
|
||||||
|
|
||||||
Nothing as of now
|
- __Additions:__
|
||||||
|
- Added the method `ScoreState::total_hits`
|
||||||
|
|
||||||
# v0.9.2 (2022-11-08)
|
# v0.9.2 (2022-11-08)
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ pub enum GradualDifficultyAttributes<'map> {
|
|||||||
|
|
||||||
impl<'map> GradualDifficultyAttributes<'map> {
|
impl<'map> GradualDifficultyAttributes<'map> {
|
||||||
/// Create a new gradual difficulty calculator for maps of any mode.
|
/// Create a new gradual difficulty calculator for maps of any mode.
|
||||||
|
#[inline]
|
||||||
pub fn new(map: &'map Beatmap, mods: u32) -> Self {
|
pub fn new(map: &'map Beatmap, mods: u32) -> Self {
|
||||||
match map.mode {
|
match map.mode {
|
||||||
GameMode::Osu => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)),
|
GameMode::Osu => Self::Osu(OsuGradualDifficultyAttributes::new(map, mods)),
|
||||||
@@ -115,9 +116,27 @@ pub struct ScoreState {
|
|||||||
|
|
||||||
impl ScoreState {
|
impl ScoreState {
|
||||||
/// Create a new empty score state.
|
/// Create a new empty score state.
|
||||||
|
#[inline]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the total amount of hits by adding everything up based on the mode.
|
||||||
|
#[inline]
|
||||||
|
pub fn total_hits(&self, mode: GameMode) -> usize {
|
||||||
|
let mut amount = self.n300 + self.n100 + self.n_misses;
|
||||||
|
|
||||||
|
if mode != GameMode::Taiko {
|
||||||
|
amount += self.n50;
|
||||||
|
|
||||||
|
if mode != GameMode::Osu {
|
||||||
|
amount += self.n_katu;
|
||||||
|
amount += (mode != GameMode::Catch) as usize * self.n_geki;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
amount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ScoreState> for OsuScoreState {
|
impl From<ScoreState> for OsuScoreState {
|
||||||
@@ -282,6 +301,7 @@ pub enum GradualPerformanceAttributes<'map> {
|
|||||||
|
|
||||||
impl<'map> GradualPerformanceAttributes<'map> {
|
impl<'map> GradualPerformanceAttributes<'map> {
|
||||||
/// Create a new gradual performance calculator for maps of any mode.
|
/// Create a new gradual performance calculator for maps of any mode.
|
||||||
|
#[inline]
|
||||||
pub fn new(map: &'map Beatmap, mods: u32) -> Self {
|
pub fn new(map: &'map Beatmap, mods: u32) -> Self {
|
||||||
match map.mode {
|
match map.mode {
|
||||||
GameMode::Osu => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)),
|
GameMode::Osu => Self::Osu(OsuGradualPerformanceAttributes::new(map, mods)),
|
||||||
@@ -293,6 +313,7 @@ impl<'map> GradualPerformanceAttributes<'map> {
|
|||||||
|
|
||||||
/// Process the next hit object and calculate the
|
/// Process the next hit object and calculate the
|
||||||
/// performance attributes for the resulting score.
|
/// performance attributes for the resulting score.
|
||||||
|
#[inline]
|
||||||
pub fn process_next_object(&mut self, state: ScoreState) -> Option<PerformanceAttributes> {
|
pub fn process_next_object(&mut self, state: ScoreState) -> Option<PerformanceAttributes> {
|
||||||
self.process_next_n_objects(state, 1)
|
self.process_next_n_objects(state, 1)
|
||||||
}
|
}
|
||||||
@@ -303,6 +324,7 @@ impl<'map> GradualPerformanceAttributes<'map> {
|
|||||||
/// If `n` is 0 it will be considered as 1.
|
/// If `n` is 0 it will be considered as 1.
|
||||||
/// If there are still objects to be processed but `n` is larger than the amount
|
/// If there are still objects to be processed but `n` is larger than the amount
|
||||||
/// of remaining objects, `n` will be considered as the amount of remaining objects.
|
/// of remaining objects, `n` will be considered as the amount of remaining objects.
|
||||||
|
#[inline]
|
||||||
pub fn process_next_n_objects(
|
pub fn process_next_n_objects(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: ScoreState,
|
state: ScoreState,
|
||||||
|
|||||||
Reference in New Issue
Block a user