From baeaeb77de55de3a7d7cadb4c7496d75f86b5e85 Mon Sep 17 00:00:00 2001 From: MaxOhn Date: Wed, 13 Nov 2024 01:26:52 +0100 Subject: [PATCH] fix: mirror reflection handling --- src/model/mods.rs | 110 +++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/src/model/mods.rs b/src/model/mods.rs index f32a38fc..9b876f77 100644 --- a/src/model/mods.rs +++ b/src/model/mods.rs @@ -96,6 +96,60 @@ impl GameMods { custom_hardrock_offsets(self).unwrap_or_else(|| self.hr()) } + + pub(crate) fn no_slider_head_acc(&self, lazer: bool) -> bool { + match self.inner { + GameModsInner::Lazer(ref mods) => mods + .iter() + .find_map(|m| match m { + GameMod::ClassicOsu(classic) => Some(classic), + _ => None, + }) + .map_or(!lazer, |classic| { + classic.no_slider_head_accuracy.unwrap_or(true) + }), + GameModsInner::Intermode(ref mods) => { + mods.contains(GameModIntermode::Classic) || !lazer + } + GameModsInner::Legacy(_) => !lazer, + } + } + + pub(crate) fn reflection(&self) -> Reflection { + match self.inner { + GameModsInner::Lazer(ref mods) => { + if mods.contains_intermode(GameModIntermode::HardRock) { + return Reflection::Vertical; + } + + mods.iter() + .find_map(|m| match m { + GameMod::MirrorOsu(mirror) => Some(mirror), + _ => None, + }) + .map_or(Reflection::None, |mr| match mr.reflection.as_deref() { + None => Reflection::Horizontal, + Some("1") => Reflection::Vertical, + Some("2") => Reflection::Both, + Some(_) => Reflection::None, + }) + } + GameModsInner::Intermode(ref mods) => { + if mods.contains(GameModIntermode::HardRock) { + Reflection::Vertical + } else { + Reflection::None + } + } + GameModsInner::Legacy(mods) => { + if mods.contains(GameModsLegacy::HardRock) { + Reflection::Vertical + } else { + Reflection::None + } + } + } + } } macro_rules! impl_map_attr { @@ -178,62 +232,6 @@ impl_has_mod! { tc: - Traceable ["Traceable"], } -impl GameMods { - pub(crate) fn no_slider_head_acc(&self, lazer: bool) -> bool { - match self.inner { - GameModsInner::Lazer(ref mods) => mods - .iter() - .find_map(|m| match m { - GameMod::ClassicOsu(classic) => Some(classic), - _ => None, - }) - .map_or(!lazer, |classic| { - classic.no_slider_head_accuracy.unwrap_or(true) - }), - GameModsInner::Intermode(ref mods) => { - mods.contains(GameModIntermode::Classic) || !lazer - } - GameModsInner::Legacy(_) => !lazer, - } - } - - pub(crate) fn reflection(&self) -> Reflection { - match self.inner { - GameModsInner::Lazer(ref mods) => { - if mods.contains_intermode(GameModIntermode::HardRock) { - return Reflection::Vertical; - } - - mods.iter() - .find_map(|m| match m { - GameMod::MirrorOsu(mirror) => Some(mirror), - _ => None, - }) - .map_or(Reflection::None, |mr| match mr.reflection.as_deref() { - Some("Horizontal") | None => Reflection::Horizontal, - Some("Vertical") => Reflection::Vertical, - Some("Both") => Reflection::Both, - Some(_) => Reflection::None, - }) - } - GameModsInner::Intermode(ref mods) => { - if mods.contains(GameModIntermode::HardRock) { - Reflection::Vertical - } else { - Reflection::None - } - } - GameModsInner::Legacy(mods) => { - if mods.contains(GameModsLegacy::HardRock) { - Reflection::Vertical - } else { - Reflection::None - } - } - } - } -} - impl Default for GameMods { fn default() -> Self { Self::DEFAULT