[][src]Struct rosu::model::GameMods

pub struct GameMods { /* fields omitted */ }

Enum for all game modifications. Implemented as bitflags.

Example

use rosu::model::GameMods;
use std::str::FromStr;

let nomod = GameMods::default();
assert_eq!(nomod, GameMods::NoMod);

// Bitwise creating, or from u32
let hdhr_1 = GameMods::HardRock | GameMods::Hidden;
let hdhr_2 = GameMods::from_bits(8 + 16).unwrap();
assert_eq!(hdhr_1, hdhr_2);

// contains, intersects, and a few more methods from bitflags
let ezhdpf = GameMods::Easy | GameMods::Hidden | GameMods::Perfect;
assert!(!ezhdpf.contains(GameMods::HardRock));
let hdpf = GameMods::Hidden | GameMods::Perfect;
assert!(ezhdpf.intersects(hdpf));

// Try converting from &str
let hdhrdt = GameMods::from_str("dthdhr").unwrap();
assert_eq!(hdhrdt.bits(), 8 + 16 + 64);
// Implements fmt::Display
assert_eq!(hdhrdt.to_string(), "HDHRDT".to_string());

// Iterator
let mut mod_iter = GameMods::from_bits(536871512).unwrap().iter();
assert_eq!(mod_iter.next(), Some(GameMods::Hidden));
assert_eq!(mod_iter.next(), Some(GameMods::HardRock));
assert_eq!(mod_iter.next(), Some(GameMods::NightCore));
assert_eq!(mod_iter.next(), Some(GameMods::ScoreV2));
assert_eq!(mod_iter.next(), None);

Implementations

impl GameMods[src]

pub const NoMod: GameMods[src]

pub const NoFail: GameMods[src]

pub const Easy: GameMods[src]

pub const TouchDevice: GameMods[src]

pub const Hidden: GameMods[src]

pub const HardRock: GameMods[src]

pub const SuddenDeath: GameMods[src]

pub const DoubleTime: GameMods[src]

pub const Relax: GameMods[src]

pub const HalfTime: GameMods[src]

pub const NightCore: GameMods[src]

pub const Flashlight: GameMods[src]

pub const SpunOut: GameMods[src]

pub const Perfect: GameMods[src]

pub const FadeIn: GameMods[src]

pub const ScoreV2: GameMods[src]

pub const Mirror: GameMods[src]

pub const Key1: GameMods[src]

pub const Key2: GameMods[src]

pub const Key3: GameMods[src]

pub const Key4: GameMods[src]

pub const Key5: GameMods[src]

pub const Key6: GameMods[src]

pub const Key7: GameMods[src]

pub const Key8: GameMods[src]

pub const Key9: GameMods[src]

pub const KeyCoop: GameMods[src]

pub const Autoplay: GameMods[src]

pub const Autopilot: GameMods[src]

pub const Cinema: GameMods[src]

pub const Random: GameMods[src]

pub const Target: GameMods[src]

pub const fn empty() -> GameMods[src]

Returns an empty set of flags

pub const fn all() -> GameMods[src]

Returns the set containing all flags.

pub const fn bits(&self) -> u32[src]

Returns the raw value of the flags currently stored.

pub fn from_bits(bits: u32) -> Option<GameMods>[src]

Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.

pub const fn from_bits_truncate(bits: u32) -> GameMods[src]

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

pub const unsafe fn from_bits_unchecked(bits: u32) -> GameMods[src]

Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).

pub const fn is_empty(&self) -> bool[src]

Returns true if no flags are currently stored.

pub const fn is_all(&self) -> bool[src]

Returns true if all flags are currently set.

pub const fn intersects(&self, other: GameMods) -> bool[src]

Returns true if there are flags common to both self and other.

pub const fn contains(&self, other: GameMods) -> bool[src]

Returns true all of the flags in other are contained within self.

pub fn insert(&mut self, other: GameMods)[src]

Inserts the specified flags in-place.

pub fn remove(&mut self, other: GameMods)[src]

Removes the specified flags in-place.

pub fn toggle(&mut self, other: GameMods)[src]

Toggles the specified flags in-place.

pub fn set(&mut self, other: GameMods, value: bool)[src]

Inserts or removes the specified flags depending on the passed value.

impl GameMods[src]

pub fn has_key_mod(self) -> Option<GameMods>[src]

Method that checks whether GameMods contains one of osu!mania's key mods.

Examples

use rosu::model::GameMods;

let mods = GameMods::Hidden | GameMods::Key4;
assert_eq!(mods.has_key_mod(), Some(GameMods::Key4));
assert_eq!(GameMods::Hidden.has_key_mod(), None);

pub fn score_multiplier(self, mode: GameMode) -> f32[src]

Calculate the multiplier of the mods which will influence a Score's playscore

Example

use rosu::model::{GameMods, GameMode};

let ezhd = GameMods::from_bits(2 + 8).unwrap();
assert_eq!(ezhd.score_multiplier(GameMode::STD), 0.53);
assert_eq!(ezhd.score_multiplier(GameMode::MNA), 0.5);

pub fn increases_score(self, mode: GameMode) -> bool[src]

Check if a Score's playscore will be increased

Example

use rosu::model::{GameMods, GameMode};

let hrso = GameMods::HardRock | GameMods::SpunOut;
assert!(!hrso.increases_score(GameMode::STD));
assert!(GameMods::DoubleTime.increases_score(GameMode::TKO));

pub fn decreases_score(self, mode: GameMode) -> bool[src]

Check if a Score's playscore will be decreased

Example

use rosu::model::{GameMods, GameMode};

let hrso = GameMods::HardRock | GameMods::SpunOut;
assert!(hrso.decreases_score(GameMode::STD));
assert!(!GameMods::DoubleTime.decreases_score(GameMode::TKO));

pub fn changes_stars(self, mode: GameMode) -> bool[src]

Check if a Beatmap's star rating for the given GameMode will be influenced.

Example

use rosu::model::{GameMode, GameMods};

let hdhr = GameMods::Hidden | GameMods::HardRock;
assert!(hdhr.changes_stars(GameMode::STD));
assert!(!hdhr.changes_stars(GameMode::MNA));
let nc = GameMods::NightCore;
assert!(nc.changes_stars(GameMode::MNA));

pub fn iter(self) -> IntoIter[src]

Returns an iterator. Alias of into_iter.

Example

use rosu::model::GameMods;

let mods = GameMods::from_bits(8 + 16 + 64 + 128).unwrap();
let mut mod_iter = mods.iter();
assert_eq!(mod_iter.next(), Some(GameMods::Hidden));
assert_eq!(mod_iter.next(), Some(GameMods::HardRock));
assert_eq!(mod_iter.next(), Some(GameMods::DoubleTime));
assert_eq!(mod_iter.next(), Some(GameMods::Relax));
assert_eq!(mod_iter.next(), None);

pub fn len(self) -> usize[src]

Returns the amount of contained mods.

Example

use rosu::model::GameMods;

assert_eq!(GameMods::NoMod.len(), 0);
let mods = GameMods::from_bits(8 + 16 + 64 + 128).unwrap();
assert_eq!(mods.len(), 4);

Trait Implementations

impl Binary for GameMods[src]

impl BitAnd<GameMods> for GameMods[src]

type Output = GameMods

The resulting type after applying the & operator.

pub fn bitand(self, other: GameMods) -> GameMods[src]

Returns the intersection between the two sets of flags.

impl BitAndAssign<GameMods> for GameMods[src]

pub fn bitand_assign(&mut self, other: GameMods)[src]

Disables all flags disabled in the set.

impl BitOr<GameMods> for GameMods[src]

type Output = GameMods

The resulting type after applying the | operator.

pub fn bitor(self, other: GameMods) -> GameMods[src]

Returns the union of the two sets of flags.

impl BitOrAssign<GameMods> for GameMods[src]

pub fn bitor_assign(&mut self, other: GameMods)[src]

Adds the set of flags.

impl BitXor<GameMods> for GameMods[src]

type Output = GameMods

The resulting type after applying the ^ operator.

pub fn bitxor(self, other: GameMods) -> GameMods[src]

Returns the left flags, but with all the right flags toggled.

impl BitXorAssign<GameMods> for GameMods[src]

pub fn bitxor_assign(&mut self, other: GameMods)[src]

Toggles the set of flags.

impl Clone for GameMods[src]

impl Copy for GameMods[src]

impl Debug for GameMods[src]

impl Default for GameMods[src]

impl<'de> Deserialize<'de> for GameMods[src]

impl Display for GameMods[src]

impl Eq for GameMods[src]

impl Extend<GameMods> for GameMods[src]

impl FromIterator<GameMods> for GameMods[src]

impl FromStr for GameMods[src]

type Err = OsuError

The associated error which can be returned from parsing.

impl Hash for GameMods[src]

impl Into<u32> for GameMods[src]

impl IntoIterator for GameMods[src]

type Item = GameMods

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

impl LowerHex for GameMods[src]

impl Not for GameMods[src]

type Output = GameMods

The resulting type after applying the ! operator.

pub fn not(self) -> GameMods[src]

Returns the complement of this set of flags.

impl Octal for GameMods[src]

impl Ord for GameMods[src]

impl PartialEq<GameMods> for GameMods[src]

impl PartialOrd<GameMods> for GameMods[src]

impl Serialize for GameMods[src]

impl StructuralEq for GameMods[src]

impl StructuralPartialEq for GameMods[src]

impl Sub<GameMods> for GameMods[src]

type Output = GameMods

The resulting type after applying the - operator.

pub fn sub(self, other: GameMods) -> GameMods[src]

Returns the set difference of the two sets of flags.

impl SubAssign<GameMods> for GameMods[src]

pub fn sub_assign(&mut self, other: GameMods)[src]

Disables all flags enabled in the set.

impl TryFrom<u32> for GameMods[src]

type Error = OsuError

The type returned in the event of a conversion error.

impl UpperHex for GameMods[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.