added convert support (#12)
* added taiko conversion * finished converts * made clippy happy * optimized allocations for patterns * taiko convert fixes * added mode methods for osu calculators * from CRLF back to LF * updated changelog * updated readme * undo normal hitsound change * added edge_sounds to changelog
This commit is contained in:
+17
-5
@@ -20,7 +20,7 @@ use skill::Skill;
|
||||
use skill_kind::SkillKind;
|
||||
use slider_state::SliderState;
|
||||
|
||||
use crate::{curve::CurveBuffers, Beatmap, Mods, Strains};
|
||||
use crate::{curve::CurveBuffers, AnyStars, Beatmap, GameMode, Mods, Strains};
|
||||
|
||||
use self::skill::Skills;
|
||||
|
||||
@@ -49,10 +49,10 @@ const STACK_DISTANCE: f32 = 3.0;
|
||||
/// ```
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OsuStars<'map> {
|
||||
map: &'map Beatmap,
|
||||
mods: u32,
|
||||
passed_objects: Option<usize>,
|
||||
clock_rate: Option<f64>,
|
||||
pub(crate) map: &'map Beatmap,
|
||||
pub(crate) mods: u32,
|
||||
pub(crate) passed_objects: Option<usize>,
|
||||
pub(crate) clock_rate: Option<f64>,
|
||||
}
|
||||
|
||||
impl<'map> OsuStars<'map> {
|
||||
@@ -67,6 +67,17 @@ impl<'map> OsuStars<'map> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert the map into another mode.
|
||||
#[inline]
|
||||
pub fn mode(self, mode: GameMode) -> AnyStars<'map> {
|
||||
match mode {
|
||||
GameMode::STD => AnyStars::Osu(self),
|
||||
GameMode::TKO => AnyStars::Taiko(self.into()),
|
||||
GameMode::CTB => AnyStars::Catch(self.into()),
|
||||
GameMode::MNA => AnyStars::Mania(self.into()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Specify mods through their bit values.
|
||||
///
|
||||
/// See [https://github.com/ppy/osu-api/wiki#mods](https://github.com/ppy/osu-api/wiki#mods)
|
||||
@@ -578,6 +589,7 @@ impl OsuPerformanceAttributes {
|
||||
}
|
||||
|
||||
impl From<OsuPerformanceAttributes> for OsuDifficultyAttributes {
|
||||
#[inline]
|
||||
fn from(attributes: OsuPerformanceAttributes) -> Self {
|
||||
attributes.difficulty
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ impl OsuObject {
|
||||
pixel_len,
|
||||
repeats,
|
||||
control_points,
|
||||
..
|
||||
} => {
|
||||
attributes.n_sliders += 1;
|
||||
|
||||
|
||||
+19
-6
@@ -1,5 +1,7 @@
|
||||
use super::{OsuDifficultyAttributes, OsuPerformanceAttributes, OsuScoreState};
|
||||
use crate::{Beatmap, DifficultyAttributes, Mods, OsuStars, PerformanceAttributes};
|
||||
use crate::{
|
||||
AnyPP, Beatmap, DifficultyAttributes, GameMode, Mods, OsuStars, PerformanceAttributes,
|
||||
};
|
||||
|
||||
/// Performance calculator on osu!standard maps.
|
||||
///
|
||||
@@ -33,10 +35,10 @@ use crate::{Beatmap, DifficultyAttributes, Mods, OsuStars, PerformanceAttributes
|
||||
#[derive(Clone, Debug)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct OsuPP<'map> {
|
||||
map: &'map Beatmap,
|
||||
attributes: Option<OsuDifficultyAttributes>,
|
||||
mods: u32,
|
||||
acc: Option<f64>,
|
||||
pub(crate) map: &'map Beatmap,
|
||||
pub(crate) attributes: Option<OsuDifficultyAttributes>,
|
||||
pub(crate) mods: u32,
|
||||
pub(crate) acc: Option<f64>,
|
||||
pub(crate) combo: Option<usize>,
|
||||
|
||||
pub(crate) n300: Option<usize>,
|
||||
@@ -44,7 +46,7 @@ pub struct OsuPP<'map> {
|
||||
pub(crate) n50: Option<usize>,
|
||||
pub(crate) n_misses: usize,
|
||||
pub(crate) passed_objects: Option<usize>,
|
||||
clock_rate: Option<f64>,
|
||||
pub(crate) clock_rate: Option<f64>,
|
||||
}
|
||||
|
||||
impl<'map> OsuPP<'map> {
|
||||
@@ -67,6 +69,17 @@ impl<'map> OsuPP<'map> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert the map into another mode.
|
||||
#[inline]
|
||||
pub fn mode(self, mode: GameMode) -> AnyPP<'map> {
|
||||
match mode {
|
||||
GameMode::STD => AnyPP::Osu(self),
|
||||
GameMode::TKO => AnyPP::Taiko(self.into()),
|
||||
GameMode::CTB => AnyPP::Catch(self.into()),
|
||||
GameMode::MNA => AnyPP::Mania(self.into()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Provide the result of a previous difficulty or performance calculation.
|
||||
/// If you already calculated the attributes for the current map-mod combination,
|
||||
/// be sure to put them in here so that they don't have to be recalculated.
|
||||
|
||||
@@ -55,24 +55,29 @@ mod test {
|
||||
TimingPoint {
|
||||
time: 1.0,
|
||||
beat_len: 10.0,
|
||||
kiai: false,
|
||||
},
|
||||
TimingPoint {
|
||||
time: 3.0,
|
||||
beat_len: 20.0,
|
||||
kiai: false,
|
||||
},
|
||||
TimingPoint {
|
||||
time: 4.0,
|
||||
beat_len: 30.0,
|
||||
kiai: false,
|
||||
},
|
||||
],
|
||||
difficulty_points: vec![
|
||||
DifficultyPoint {
|
||||
time: 2.0,
|
||||
speed_multiplier: 15.0,
|
||||
kiai: false,
|
||||
},
|
||||
DifficultyPoint {
|
||||
time: 5.0,
|
||||
speed_multiplier: 45.0,
|
||||
kiai: false,
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
|
||||
Reference in New Issue
Block a user