renamed methods on BeatmapAttributesBuilder
This commit is contained in:
@@ -58,23 +58,9 @@ impl BeatmapAttributesBuilder {
|
|||||||
const TAIKO_MAX: f64 = 20.0;
|
const TAIKO_MAX: f64 = 20.0;
|
||||||
|
|
||||||
/// Create a new [`BeatmapAttributesBuilder`].
|
/// Create a new [`BeatmapAttributesBuilder`].
|
||||||
pub const fn new(map: &Beatmap) -> Self {
|
|
||||||
Self {
|
|
||||||
mode: map.mode,
|
|
||||||
ar: ModsDependent::new(map.ar),
|
|
||||||
od: ModsDependent::new(map.od),
|
|
||||||
cs: ModsDependent::new(map.cs),
|
|
||||||
hp: ModsDependent::new(map.hp),
|
|
||||||
mods: 0,
|
|
||||||
clock_rate: None,
|
|
||||||
is_convert: map.is_convert,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new blank [`BeatmapAttributesBuilder`].
|
|
||||||
///
|
///
|
||||||
/// The mode will be `GameMode::Osu` and attributes are set to `5.0`.
|
/// The mode will be `GameMode::Osu` and attributes are set to `5.0`.
|
||||||
pub const fn new_blank() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
mode: GameMode::Osu,
|
mode: GameMode::Osu,
|
||||||
is_convert: false,
|
is_convert: false,
|
||||||
@@ -87,6 +73,20 @@ impl BeatmapAttributesBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new [`BeatmapAttributesBuilder`] from a [`Beatmap`].
|
||||||
|
pub const fn from_map(map: &Beatmap) -> Self {
|
||||||
|
Self {
|
||||||
|
mode: map.mode,
|
||||||
|
ar: ModsDependent::new(map.ar),
|
||||||
|
od: ModsDependent::new(map.od),
|
||||||
|
cs: ModsDependent::new(map.cs),
|
||||||
|
hp: ModsDependent::new(map.hp),
|
||||||
|
mods: 0,
|
||||||
|
clock_rate: None,
|
||||||
|
is_convert: map.is_convert,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Specify the approach rate.
|
/// Specify the approach rate.
|
||||||
///
|
///
|
||||||
/// `with_mods` determines if the given value should be used before
|
/// `with_mods` determines if the given value should be used before
|
||||||
@@ -323,13 +323,13 @@ impl BeatmapAttributesBuilder {
|
|||||||
|
|
||||||
impl From<&Beatmap> for BeatmapAttributesBuilder {
|
impl From<&Beatmap> for BeatmapAttributesBuilder {
|
||||||
fn from(map: &Beatmap) -> Self {
|
fn from(map: &Beatmap) -> Self {
|
||||||
Self::new(map)
|
Self::from_map(map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M> From<&Converted<'_, M>> for BeatmapAttributesBuilder {
|
impl<M> From<&Converted<'_, M>> for BeatmapAttributesBuilder {
|
||||||
fn from(converted: &Converted<'_, M>) -> Self {
|
fn from(converted: &Converted<'_, M>) -> Self {
|
||||||
Self::new(converted)
|
Self::from_map(converted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ fn difficulty_range(difficulty: f64, min: f64, mid: f64, max: f64) -> f64 {
|
|||||||
|
|
||||||
impl Default for BeatmapAttributesBuilder {
|
impl Default for BeatmapAttributesBuilder {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new_blank()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn consider_mods() {
|
fn consider_mods() {
|
||||||
let attrs = BeatmapAttributesBuilder::new_blank()
|
let attrs = BeatmapAttributesBuilder::new()
|
||||||
.ar(8.5, false)
|
.ar(8.5, false)
|
||||||
.mods(64)
|
.mods(64)
|
||||||
.build();
|
.build();
|
||||||
@@ -367,7 +367,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn skip_mods() {
|
fn skip_mods() {
|
||||||
let attrs = BeatmapAttributesBuilder::new_blank()
|
let attrs = BeatmapAttributesBuilder::new()
|
||||||
.ar(8.5, true)
|
.ar(8.5, true)
|
||||||
.mods(64)
|
.mods(64)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl Beatmap {
|
|||||||
/// Returns a [`BeatmapAttributesBuilder`] to calculate modified beatmap
|
/// Returns a [`BeatmapAttributesBuilder`] to calculate modified beatmap
|
||||||
/// attributes.
|
/// attributes.
|
||||||
pub const fn attributes(&self) -> BeatmapAttributesBuilder {
|
pub const fn attributes(&self) -> BeatmapAttributesBuilder {
|
||||||
BeatmapAttributesBuilder::new(self)
|
BeatmapAttributesBuilder::from_map(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The beats per minute of the map.
|
/// The beats per minute of the map.
|
||||||
|
|||||||
Reference in New Issue
Block a user