added convert support with rosu-pp update
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
## Upcoming
|
||||
- Updated to [PyO3 v0.16](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md#0165---2022-05-15) from v0.15
|
||||
- Updated to [rosu-pp v0.6](https://github.com/MaxOhn/rosu-pp/blob/main/CHANGELOG.md#v060-2022-07-05)
|
||||
- Added the class `GameMode` to serve as enum e.g. `GameMode.Taiko`
|
||||
- `ScoreParams` now have an additional field `mode: Optional[GameMode]` which can be used to convert to other modes
|
||||
|
||||
# v0.5.2 (2022-06-14)
|
||||
- Bumped patch version of dependencies, including a [rosu-pp](https://github.com/MaxOhn/rosu-pp/blob/main/CHANGELOG.md#v052-2022-06-14) update
|
||||
|
||||
Generated
+3
-3
@@ -170,13 +170,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rosu-pp"
|
||||
version = "0.5.2"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5c816e053b2305929c9416953b2a0c42e01a98072a2e06334ab4209826b6c62"
|
||||
checksum = "92439367271f2657f29f9e2bd1dc08d413a7d820139840001fe57a1b21500bfb"
|
||||
|
||||
[[package]]
|
||||
name = "rosu-pp-py"
|
||||
version = "0.4.0"
|
||||
version = "0.6.0"
|
||||
dependencies = [
|
||||
"pyo3",
|
||||
"rosu-pp",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rosu-pp-py"
|
||||
version = "0.4.0"
|
||||
version = "0.6.0"
|
||||
description = "osu! difficulty and pp calculation for all modes"
|
||||
authors = ["Max Ohn <ohn.m@hotmail.de>"]
|
||||
license = "MIT"
|
||||
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
pyo3 = { version = "0.16", features = ["macros", "extension-module"] }
|
||||
rosu-pp = { version = "0.5" }
|
||||
rosu-pp = { version = "0.6" }
|
||||
|
||||
[profile.release]
|
||||
lto = "fat"
|
||||
|
||||
@@ -22,6 +22,8 @@ calculator.set_od(9.2)
|
||||
```
|
||||
2) Next, you need to create `ScoreParams`. It has the following fields:
|
||||
```
|
||||
mode: Optional[GameMode],
|
||||
specify for scores on convert maps, default to the map's native mode
|
||||
mods: Optional[int],
|
||||
bit value for mods, defaults to 0 (NM) see https://github.com/ppy/osu-api/wiki#mods
|
||||
acc: Optional[float],
|
||||
@@ -66,6 +68,7 @@ calculator = Calculator('./maps/1980365.osu')
|
||||
|
||||
params1 = ScoreParams(
|
||||
mods = 8 + 16, # HDHR
|
||||
mode = GameMode.Catch,
|
||||
acc = 97.89,
|
||||
nMisses = 13,
|
||||
combo = 1388,
|
||||
|
||||
+24
-24
@@ -1,24 +1,24 @@
|
||||
[build-system]
|
||||
requires = ["maturin>=0.12,<0.13", "setuptools", "setuptools-rust", "wheel"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[project]
|
||||
name = "rosu-pp-py"
|
||||
version = "0.5.2"
|
||||
requires-python = ">=3.6"
|
||||
description = "osu! difficulty and pp calculation for all modes"
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Rust",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
]
|
||||
packages = [{ include = "rosu_pp_py" }]
|
||||
authors = [{ name = "Max Ohn", email = "ohn.m@hotmail.de" }]
|
||||
readme = "README.md"
|
||||
license = { file = "LICENSE" }
|
||||
repository = "https://github.com/MaxOhn/rosu-pp-py"
|
||||
keywords = ["osu", "pp", "stars", "performance", "difficulty"]
|
||||
[build-system]
|
||||
requires = ["maturin>=0.12,<0.13", "setuptools", "setuptools-rust", "wheel"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[project]
|
||||
name = "rosu-pp-py"
|
||||
version = "0.5.2"
|
||||
requires-python = ">=3.7"
|
||||
description = "osu! difficulty and pp calculation for all modes"
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Rust",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
]
|
||||
packages = [{ include = "rosu_pp_py" }]
|
||||
authors = [{ name = "Max Ohn", email = "ohn.m@hotmail.de" }]
|
||||
readme = "README.md"
|
||||
license = { file = "LICENSE" }
|
||||
repository = "https://github.com/MaxOhn/rosu-pp-py"
|
||||
keywords = ["osu", "pp", "stars", "performance", "difficulty"]
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
from typing import Iterable, List, Union
|
||||
from enum import Enum
|
||||
|
||||
class GameMode(Enum):
|
||||
Osu = 0
|
||||
Taiko = 1
|
||||
Catch = 2
|
||||
Mania = 3
|
||||
|
||||
class ScoreParams:
|
||||
"""
|
||||
@@ -7,6 +14,9 @@ class ScoreParams:
|
||||
|
||||
## Attributes
|
||||
|
||||
`mode`: Optional[GameMode]
|
||||
Mode to convert the map. Only does something if the original map is osu!standard and
|
||||
the specified mode is taiko, catch, or mania. Defaults to the map's native mode.
|
||||
`mods`: Optional[int]
|
||||
Bit value for mods, defaults to 0 (NM) see [https://github.com/ppy/osu-api/wiki#mods](https://github.com/ppy/osu-api/wiki#mods)
|
||||
`acc`: Optional[float]
|
||||
|
||||
+35
-4
@@ -12,9 +12,10 @@ use pyo3::{
|
||||
types::{PyDict, PyIterator},
|
||||
};
|
||||
use rosu_pp::{
|
||||
catch::CatchPerformanceAttributes, mania::ManiaPerformanceAttributes,
|
||||
osu::OsuPerformanceAttributes, taiko::TaikoPerformanceAttributes, AnyPP, Beatmap,
|
||||
BeatmapAttributes, BeatmapExt, PerformanceAttributes,
|
||||
beatmap::BeatmapAttributes, catch::CatchPerformanceAttributes,
|
||||
mania::ManiaPerformanceAttributes, osu::OsuPerformanceAttributes,
|
||||
taiko::TaikoPerformanceAttributes, AnyPP, Beatmap, BeatmapExt, GameMode as RosuGameMode,
|
||||
PerformanceAttributes,
|
||||
};
|
||||
|
||||
#[pyclass]
|
||||
@@ -147,9 +148,32 @@ impl Calculator {
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[repr(u8)]
|
||||
enum GameMode {
|
||||
Osu,
|
||||
Taiko,
|
||||
Catch,
|
||||
Mania,
|
||||
}
|
||||
|
||||
impl From<GameMode> for RosuGameMode {
|
||||
fn from(mode: GameMode) -> Self {
|
||||
match mode {
|
||||
GameMode::Osu => RosuGameMode::STD,
|
||||
GameMode::Taiko => RosuGameMode::TKO,
|
||||
GameMode::Catch => RosuGameMode::CTB,
|
||||
GameMode::Mania => RosuGameMode::MNA,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
#[derive(Clone, Default, PartialEq)]
|
||||
struct ScoreParams {
|
||||
#[pyo3(get, set)]
|
||||
mode: Option<GameMode>,
|
||||
#[pyo3(get, set)]
|
||||
mods: u32,
|
||||
#[pyo3(get, set)]
|
||||
@@ -386,6 +410,7 @@ impl ScoreParams {
|
||||
|
||||
fn apply(self, mut calculator: AnyPP) -> AnyPP {
|
||||
let ScoreParams {
|
||||
mode,
|
||||
mods,
|
||||
n300,
|
||||
n100,
|
||||
@@ -399,6 +424,10 @@ impl ScoreParams {
|
||||
clock_rate,
|
||||
} = self;
|
||||
|
||||
if let Some(mode) = mode {
|
||||
calculator = calculator.mode(mode.into());
|
||||
}
|
||||
|
||||
if let Some(n300) = n300 {
|
||||
calculator = calculator.n300(n300);
|
||||
}
|
||||
@@ -454,6 +483,7 @@ impl ScoreParams {
|
||||
for (key, value) in dict.iter() {
|
||||
if let Ok(key) = key.extract() {
|
||||
match key {
|
||||
"mode" => params.mode = Some(value.extract()?),
|
||||
"mods" => params.mods = value.extract()?,
|
||||
"n300" => params.n300 = value.extract()?,
|
||||
"n100" => params.n100 = value.extract()?,
|
||||
@@ -467,7 +497,7 @@ impl ScoreParams {
|
||||
"clockRate" => params.clock_rate = value.extract()?,
|
||||
_ => {
|
||||
return Err(PyTypeError::new_err(format!(
|
||||
"got an unexpected keyword argument '{}'; expected 'mods', 'n300', 'n100', \
|
||||
"got an unexpected keyword argument '{}'; expected 'mode', 'mods', 'n300', 'n100', \
|
||||
'n50', 'nMisses', 'nKatu', 'acc', 'combo', 'score', 'passedObjects', 'clockRate'",
|
||||
key,
|
||||
)))
|
||||
@@ -680,6 +710,7 @@ impl Display for ScoreParams {
|
||||
|
||||
#[pymodule]
|
||||
fn rosu_pp_py(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<GameMode>()?;
|
||||
m.add_class::<ScoreParams>()?;
|
||||
m.add_class::<Calculator>()?;
|
||||
m.add_class::<CalculateResult>()?;
|
||||
|
||||
Reference in New Issue
Block a user