renamed method
This commit is contained in:
@@ -43,7 +43,7 @@ impl DifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn pp<'a>(self) -> Performance<'a> {
|
pub fn performance<'a>(self) -> Performance<'a> {
|
||||||
self.into()
|
self.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,10 +275,10 @@ impl<A: AttributeProvider> From<A> for Performance<'_> {
|
|||||||
fn from(attrs: A) -> Self {
|
fn from(attrs: A) -> Self {
|
||||||
fn inner(attrs: DifficultyAttributes) -> Performance<'static> {
|
fn inner(attrs: DifficultyAttributes) -> Performance<'static> {
|
||||||
match attrs {
|
match attrs {
|
||||||
DifficultyAttributes::Osu(attrs) => Performance::Osu(attrs.pp()),
|
DifficultyAttributes::Osu(attrs) => Performance::Osu(attrs.performance()),
|
||||||
DifficultyAttributes::Taiko(attrs) => Performance::Taiko(attrs.pp()),
|
DifficultyAttributes::Taiko(attrs) => Performance::Taiko(attrs.performance()),
|
||||||
DifficultyAttributes::Catch(attrs) => Performance::Catch(attrs.pp()),
|
DifficultyAttributes::Catch(attrs) => Performance::Catch(attrs.performance()),
|
||||||
DifficultyAttributes::Mania(attrs) => Performance::Mania(attrs.pp()),
|
DifficultyAttributes::Mania(attrs) => Performance::Mania(attrs.performance()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ impl CatchDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn pp<'a>(self) -> CatchPerformance<'a> {
|
pub fn performance<'a>(self) -> CatchPerformance<'a> {
|
||||||
self.into()
|
self.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+72
@@ -1,3 +1,75 @@
|
|||||||
|
//! Library to calculate difficulty and performance attributes for all [osu!] gamemodes.
|
||||||
|
//!
|
||||||
|
//! ## Description
|
||||||
|
//!
|
||||||
|
//! A large part of `rosu-pp` is a port of [osu!lazer]'s difficulty and performance calculation
|
||||||
|
//! with emphasis on a precise translation to rust for the most accurate results.
|
||||||
|
//!
|
||||||
|
//! Last commits of the ported code:
|
||||||
|
//! - [osu!lazer]: `7342fb7f51b34533a42bffda89c3d6c569cc69ce` (2022-10-11)
|
||||||
|
//! - [osu!tools]: `146d5916937161ef65906aa97f85d367035f3712` (2022-10-08)
|
||||||
|
//!
|
||||||
|
//! Posts of the latest gamemode updates:
|
||||||
|
//! - osu: <https://osu.ppy.sh/home/news/2022-09-30-changes-to-osu-sr-and-pp>
|
||||||
|
//! - taiko: <https://osu.ppy.sh/home/news/2022-09-28-changes-to-osu-taiko-sr-and-pp>
|
||||||
|
//! - catch: TODO
|
||||||
|
//! - mania: <https://osu.ppy.sh/home/news/2022-10-09-changes-to-osu-mania-sr-and-pp>
|
||||||
|
//!
|
||||||
|
//! ## Usage
|
||||||
|
//!
|
||||||
|
//! ```
|
||||||
|
//! // Decode the map
|
||||||
|
//! let map = rosu_pp::Beatmap::from_path("./resources/2785319.osu").unwrap();
|
||||||
|
//!
|
||||||
|
//! // Calculate difficulty attributes
|
||||||
|
//! let diff_attrs = map.difficulty()
|
||||||
|
//! .mods(8 + 16) // HDHR
|
||||||
|
//! .calculate();
|
||||||
|
//!
|
||||||
|
//! let stars = diff_attrs.stars();
|
||||||
|
//!
|
||||||
|
//! // Calculate performance attributes
|
||||||
|
//! let perf_attrs = map.performance()
|
||||||
|
//! // To speed up the calculation significantly, we can re-use the previous
|
||||||
|
//! // attributes.
|
||||||
|
//! // **Note** that this should only be done if the map, mode, mods, and
|
||||||
|
//! // amount of passed objects stay the same. Otherwise, the resulting
|
||||||
|
//! // attributes will be incorrect.
|
||||||
|
//! .attributes(diff_attrs)
|
||||||
|
//! .mods(24) // HDHR, same as before
|
||||||
|
//! .combo(789)
|
||||||
|
//! .accuracy(99.2)
|
||||||
|
//! .misses(2)
|
||||||
|
//! .calculate();
|
||||||
|
//!
|
||||||
|
//! let pp = perf_attrs.pp();
|
||||||
|
//!
|
||||||
|
//! // Again, we re-use the previous attributes for maximum efficiency.
|
||||||
|
//! // This time we do it directly instead of through the map.
|
||||||
|
//! let max_pp = perf_attrs.performance()
|
||||||
|
//! .mods(24) // Still the same
|
||||||
|
//! .calculate()
|
||||||
|
//! .pp();
|
||||||
|
//!
|
||||||
|
//! println!("Stars: {stars} | PP: {pp}/{max_pp}");
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! ## Gradual calculation
|
||||||
|
//!
|
||||||
|
//! TODO
|
||||||
|
//!
|
||||||
|
//! ## Features
|
||||||
|
//!
|
||||||
|
//! | Flag | Description | Dependencies
|
||||||
|
//! | - | - | -
|
||||||
|
//! | `default` | No features |
|
||||||
|
//! | `tracing` | Any error encountered during beatmap decoding will be logged through `tracing::error`. If this features is not enabled, errors will be ignored. | [`tracing`]
|
||||||
|
//!
|
||||||
|
//! [osu!]: https://osu.ppy.sh/home
|
||||||
|
//! [osu!lazer]: https://github.com/ppy/osu
|
||||||
|
//! [osu!tools]: https://github.com/ppy/osu-tools
|
||||||
|
//! [`tracing`]: https://docs.rs/tracing
|
||||||
|
|
||||||
#![deny(rustdoc::broken_intra_doc_links)]
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
#![warn(clippy::missing_const_for_fn, clippy::pedantic)]
|
#![warn(clippy::missing_const_for_fn, clippy::pedantic)]
|
||||||
#![allow(
|
#![allow(
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ impl ManiaDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn pp<'a>(self) -> ManiaPerformance<'a> {
|
pub fn performance<'a>(self) -> ManiaPerformance<'a> {
|
||||||
self.into()
|
self.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use rosu_map::{
|
|||||||
LATEST_FORMAT_VERSION,
|
LATEST_FORMAT_VERSION,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{Performance, Difficulty};
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
attributes::{BeatmapAttributes, BeatmapAttributesBuilder, HitWindows},
|
attributes::{BeatmapAttributes, BeatmapAttributesBuilder, HitWindows},
|
||||||
converted::Converted,
|
converted::Converted,
|
||||||
@@ -68,6 +70,16 @@ impl Beatmap {
|
|||||||
rosu_map::from_bytes(bytes)
|
rosu_map::from_bytes(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new difficulty calculator for this [`Beatmap`].
|
||||||
|
pub fn difficulty(&self) -> Difficulty<'_> {
|
||||||
|
Difficulty::new(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new performance calculator for this [`Beatmap`].
|
||||||
|
pub fn performance(&self) -> Performance<'_> {
|
||||||
|
Performance::new(self)
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds the [`TimingPoint`] that is active at the given time.
|
/// Finds the [`TimingPoint`] that is active at the given time.
|
||||||
pub(crate) fn timing_point_at(&self, time: f64) -> Option<&TimingPoint> {
|
pub(crate) fn timing_point_at(&self, time: f64) -> Option<&TimingPoint> {
|
||||||
timing_point_at(&self.timing_points, time)
|
timing_point_at(&self.timing_points, time)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ impl OsuDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn pp<'a>(self) -> OsuPerformance<'a> {
|
pub fn performance<'a>(self) -> OsuPerformance<'a> {
|
||||||
self.into()
|
self.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ impl TaikoDifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a builder for performance calculation.
|
/// Returns a builder for performance calculation.
|
||||||
pub fn pp<'a>(self) -> TaikoPerformance<'a> {
|
pub fn performance<'a>(self) -> TaikoPerformance<'a> {
|
||||||
self.into()
|
self.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user