mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-18 16:28:55 +00:00
Update rosu-pp and rosu-v2
This commit is contained in:
parent
803d718c7a
commit
a4fab5438b
5 changed files with 47 additions and 53 deletions
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -1807,10 +1807,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "3c55926c8f0fed1db12fbe96f7a6083a2c4186443dd32532ab34e6902467a4f3"
|
||||
|
||||
[[package]]
|
||||
name = "rosu-mods"
|
||||
version = "0.1.0"
|
||||
name = "rosu-map"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d69daf02885f7477085403a6eada6215f44333c7b54355ea1c4e276a02263bde"
|
||||
checksum = "21de4f8c5cd2738e1c9a2ed477aad2579dacd5acf3845d80738fcec160d0bd8a"
|
||||
|
||||
[[package]]
|
||||
name = "rosu-mods"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a0fb1475e860c987673e8abc1df5d23f22c4e1ae62e9459e656cff4d82f603b"
|
||||
dependencies = [
|
||||
"paste",
|
||||
"serde",
|
||||
|
@ -1819,17 +1825,16 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rosu-pp"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "002a6b12cedcb185f4051f0b3d0466e0b61ff414a9ca8375f09be581c0e70f06"
|
||||
source = "git+https://github.com/MaxOhn/rosu-pp?branch=main#9f45d9594d08ba79d3c1c73ec43aef2fd7b54c0d"
|
||||
dependencies = [
|
||||
"rosu-map",
|
||||
"rosu-map 0.2.0",
|
||||
"rosu-mods",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rosu-v2"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/MaxOhn/rosu-v2?branch=lazer#04744c606962f21824d7398f1c15c34fe7fa9eef"
|
||||
source = "git+https://github.com/MaxOhn/rosu-v2?branch=lazer#4552ffa6e4e8d375c4a6f0a4cc2d21c4f61a129f"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"dashmap 6.0.1",
|
||||
|
@ -3310,7 +3315,7 @@ dependencies = [
|
|||
"rand",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"rosu-map",
|
||||
"rosu-map 0.1.1",
|
||||
"rosu-pp",
|
||||
"rosu-v2",
|
||||
"serde",
|
||||
|
|
|
@ -14,7 +14,7 @@ dashmap = "5.3.4"
|
|||
lazy_static = "1.4.0"
|
||||
regex = "1.5.6"
|
||||
reqwest = "0.11.10"
|
||||
rosu-pp = "1.1"
|
||||
rosu-pp = { git = "https://github.com/MaxOhn/rosu-pp", branch = "main" }
|
||||
rosu-v2 = { git = "https://github.com/MaxOhn/rosu-v2", branch = "lazer" }
|
||||
rosu-map = "0.1"
|
||||
time = "0.3"
|
||||
|
|
|
@ -23,13 +23,13 @@ pub struct ToPrint<'a> {
|
|||
lazy_static! {
|
||||
// Beatmap(set) hooks
|
||||
static ref OLD_LINK_REGEX: Regex = Regex::new(
|
||||
r"(?:https?://)?osu\.ppy\.sh/(?P<link_type>s|b|beatmaps)/(?P<id>\d+)(?:[\&\?]m=(?P<mode>[0123]))?(?:\+(?P<mods>[A-Z]+))?"
|
||||
r"(?:https?://)?osu\.ppy\.sh/(?P<link_type>s|b|beatmaps)/(?P<id>\d+)(?:[\&\?]m=(?P<mode>[0123]))?(?:\+(?P<mods>\S+\b))?"
|
||||
).unwrap();
|
||||
static ref NEW_LINK_REGEX: Regex = Regex::new(
|
||||
r"(?:https?://)?osu\.ppy\.sh/beatmapsets/(?P<set_id>\d+)/?(?:\#(?P<mode>osu|taiko|fruits|mania)(?:/(?P<beatmap_id>\d+)|/?))?(?:\+(?P<mods>[A-Z]+))?"
|
||||
r"(?:https?://)?osu\.ppy\.sh/beatmapsets/(?P<set_id>\d+)/?(?:\#(?P<mode>osu|taiko|fruits|mania)(?:/(?P<beatmap_id>\d+)|/?))?(?:\+(?P<mods>\S+\b))?"
|
||||
).unwrap();
|
||||
static ref SHORT_LINK_REGEX: Regex = Regex::new(
|
||||
r"(?:^|\s|\W)(?P<main>/b/(?P<id>\d+)(?:/(?P<mode>osu|taiko|fruits|mania))?(?:\+(?P<mods>[A-Z]+))?)"
|
||||
r"(?:^|\s|\W)(?P<main>/b/(?P<id>\d+)(?:/(?P<mode>osu|taiko|fruits|mania))?(?:\+(?P<mods>\S+\b))?)"
|
||||
).unwrap();
|
||||
|
||||
// Score hook
|
||||
|
|
|
@ -424,7 +424,7 @@ impl Beatmap {
|
|||
Some(mode) if mode != self.mode => format!("/{}", mode.as_str_new_site()),
|
||||
_ => "".to_owned(),
|
||||
},
|
||||
mods.strip_lazer(override_mode.unwrap_or(Mode::Std))
|
||||
mods
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ lazy_static::lazy_static! {
|
|||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct UnparsedMods {
|
||||
mods: Cow<'static, str>,
|
||||
clock: Option<f32>,
|
||||
clock: Option<f64>,
|
||||
}
|
||||
|
||||
impl FromStr for UnparsedMods {
|
||||
|
@ -47,7 +47,7 @@ impl FromStr for UnparsedMods {
|
|||
mods: mods.map(|v| v.into()).unwrap_or("".into()),
|
||||
clock: ms
|
||||
.name("clock")
|
||||
.map(|v| v.as_str().parse::<f32>().unwrap())
|
||||
.map(|v| v.as_str().parse::<_>().unwrap())
|
||||
.filter(|v| *v > 0.0),
|
||||
})
|
||||
}
|
||||
|
@ -149,13 +149,8 @@ pub struct Stats {
|
|||
}
|
||||
|
||||
impl Stats {
|
||||
pub fn from_f32(ar: Option<f32>, od: Option<f32>, hp: Option<f32>, cs: Option<f32>) -> Self {
|
||||
Self {
|
||||
ar: ar.map(|v| v as f64),
|
||||
od: od.map(|v| v as f64),
|
||||
hp: hp.map(|v| v as f64),
|
||||
cs: cs.map(|v| v as f64),
|
||||
}
|
||||
pub fn from_option(ar: Option<f64>, od: Option<f64>, hp: Option<f64>, cs: Option<f64>) -> Self {
|
||||
Self { ar, od, hp, cs }
|
||||
}
|
||||
|
||||
pub fn has_any(&self) -> bool {
|
||||
|
@ -168,26 +163,20 @@ impl Mods {
|
|||
inner: GameMods::new(),
|
||||
};
|
||||
|
||||
pub fn strip_lazer(&self, mode: Mode) -> Self {
|
||||
let mut m = self.clone();
|
||||
m.inner.insert(Self::classic_mod_of(mode));
|
||||
m
|
||||
}
|
||||
|
||||
fn classic_mod_of(mode: Mode) -> rosu::GameMod {
|
||||
match mode {
|
||||
Mode::Std => rosu::GameMod::ClassicOsu(rosu::generated_mods::ClassicOsu::default()),
|
||||
Mode::Taiko => {
|
||||
rosu::GameMod::ClassicTaiko(rosu::generated_mods::ClassicTaiko::default())
|
||||
}
|
||||
Mode::Catch => {
|
||||
rosu::GameMod::ClassicCatch(rosu::generated_mods::ClassicCatch::default())
|
||||
}
|
||||
Mode::Mania => {
|
||||
rosu::GameMod::ClassicMania(rosu::generated_mods::ClassicMania::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
// fn classic_mod_of(mode: Mode) -> rosu::GameMod {
|
||||
// match mode {
|
||||
// Mode::Std => rosu::GameMod::ClassicOsu(rosu::generated_mods::ClassicOsu::default()),
|
||||
// Mode::Taiko => {
|
||||
// rosu::GameMod::ClassicTaiko(rosu::generated_mods::ClassicTaiko::default())
|
||||
// }
|
||||
// Mode::Catch => {
|
||||
// rosu::GameMod::ClassicCatch(rosu::generated_mods::ClassicCatch::default())
|
||||
// }
|
||||
// Mode::Mania => {
|
||||
// rosu::GameMod::ClassicMania(rosu::generated_mods::ClassicMania::default())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn overrides(&self) -> Stats {
|
||||
use rosu_v2::prelude::GameMod::*;
|
||||
|
@ -195,23 +184,23 @@ impl Mods {
|
|||
.iter()
|
||||
.find_map(|m| {
|
||||
Some(match m {
|
||||
DifficultyAdjustOsu(da) => Stats::from_f32(
|
||||
DifficultyAdjustOsu(da) => Stats::from_option(
|
||||
da.approach_rate,
|
||||
da.overall_difficulty,
|
||||
da.drain_rate,
|
||||
da.circle_size,
|
||||
),
|
||||
DifficultyAdjustTaiko(da) => {
|
||||
Stats::from_f32(None, da.overall_difficulty, da.drain_rate, None)
|
||||
Stats::from_option(None, da.overall_difficulty, da.drain_rate, None)
|
||||
}
|
||||
DifficultyAdjustCatch(da) => Stats::from_f32(
|
||||
DifficultyAdjustCatch(da) => Stats::from_option(
|
||||
da.approach_rate,
|
||||
da.overall_difficulty,
|
||||
da.drain_rate,
|
||||
da.circle_size,
|
||||
),
|
||||
DifficultyAdjustMania(da) => {
|
||||
Stats::from_f32(None, da.overall_difficulty, da.drain_rate, None)
|
||||
Stats::from_option(None, da.overall_difficulty, da.drain_rate, None)
|
||||
}
|
||||
_ => return None,
|
||||
})
|
||||
|
@ -329,7 +318,7 @@ impl Mods {
|
|||
use rosu::GameMod::*;
|
||||
fn fmt_speed_change(
|
||||
mod_name: &str,
|
||||
speed_change: &Option<f32>,
|
||||
speed_change: &Option<f64>,
|
||||
adjust_pitch: &Option<bool>,
|
||||
) -> Option<String> {
|
||||
if speed_change.is_none() && adjust_pitch.is_none() {
|
||||
|
@ -350,10 +339,10 @@ impl Mods {
|
|||
Some(s)
|
||||
}
|
||||
fn fmt_diff_adj(
|
||||
ar: Option<f32>,
|
||||
od: Option<f32>,
|
||||
hp: Option<f32>,
|
||||
cs: Option<f32>,
|
||||
ar: Option<f64>,
|
||||
od: Option<f64>,
|
||||
hp: Option<f64>,
|
||||
cs: Option<f64>,
|
||||
) -> Option<String> {
|
||||
let stats = [("AR", ar), ("OD", od), ("HP", hp), ("CS", cs)];
|
||||
let mut output = String::with_capacity(4 * (2 + 3 + 4) + 3 * 2);
|
||||
|
@ -423,11 +412,11 @@ impl Mods {
|
|||
}
|
||||
let intermode =
|
||||
GameModsIntermode::try_from_acronyms(s).ok_or_else(|| error!("Invalid mods: {}", s))?;
|
||||
let mut inner = intermode
|
||||
let inner = intermode
|
||||
.try_with_mode(mode.into())
|
||||
.ok_or_else(|| error!("Invalid mods for `{}`: {}", mode, intermode))?;
|
||||
// Always add classic mod to `inner`
|
||||
inner.insert(Self::classic_mod_of(mode));
|
||||
// inner.insert(Self::classic_mod_of(mode));
|
||||
if !inner.is_valid() {
|
||||
return Err(error!("Incompatible mods found: {}", inner));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue