Skip to content

Commit

Permalink
fix: mirror reflection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn committed Nov 13, 2024
1 parent 11095ad commit baeaeb7
Showing 1 changed file with 54 additions and 56 deletions.
110 changes: 54 additions & 56 deletions src/model/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit baeaeb7

Please sign in to comment.