DifficultyProcessor

Struct DifficultyProcessor 

Source
pub struct DifficultyProcessor {
    pub map: Qua,
    pub overall_difficulty: f32,
    pub qss_pattern_flags: QssPatternFlags,
    pub strain_constants: StrainConstantsKeys,
    pub average_note_density: f32,
    pub strain_solver_data: Vec<StrainSolverData>,
    pub vibro_inaccuracy_confidence: f32,
    pub roll_inaccuracy_confidence: f32,
}
Expand description

Handles Difficulty Solving + Data

Fields§

§map: Qua

Current map for difficulty calculation

§overall_difficulty: f32

Overall Difficulty of a map

§qss_pattern_flags: QssPatternFlags

Used to display prominent patterns of a map in the client

§strain_constants: StrainConstantsKeys

Constants used for solving

§average_note_density: f32

Average note density of the map

§strain_solver_data: Vec<StrainSolverData>

Hit objects in the map used for solving difficulty

§vibro_inaccuracy_confidence: f32

Value of confidence that there’s vibro manipulation in the calculated map

§roll_inaccuracy_confidence: f32

Value of confidence that there’s roll manipulation in the calculated map

Implementations§

Source§

impl DifficultyProcessor

Source

pub fn new(map: Qua, _constants: StrainConstants, _mods: ModIdentifier) -> Self

Constructor

Examples found in repository?
examples/basic_usage.rs (line 19)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    println!("Parsing .qua file...");
5    
6    // Parse the .qua file
7    let qua = Qua::from_file("assets/171402.qua")?;
8    
9    println!("Map: {} - {}", qua.metadata.title, qua.metadata.artist);
10    println!("Creator: {}", qua.metadata.creator);
11    println!("Difficulty: {}", qua.metadata.difficulty_name);
12    println!("Mode: {:?}", qua.metadata.mode);
13    println!("Hit Objects: {}", qua.hit_objects.len());
14    println!("Timing Points: {}", qua.timing_points.len());
15    
16    // Calculate difficulty
17    println!("\nCalculating difficulty...");
18    let constants = StrainConstants::new(None);
19    let mut processor = DifficultyProcessor::new(qua, constants, ModIdentifier::NONE);
20    processor.calculate_difficulty(ModIdentifier::NONE);
21    
22    println!("Overall Difficulty: {:.2}", processor.overall_difficulty);
23    println!("Average Note Density: {:.2}", processor.average_note_density);
24    println!("Map Length: {:.2}", processor.map.length());
25    println!("Hit Objects Count: {}", processor.map.hit_objects.len());
26    println!("Timing Points Count: {}", processor.map.timing_points.len());
27    
28    Ok(())
29}
Source

pub fn calculate_difficulty(&mut self, mods: ModIdentifier)

Calculate difficulty of a map with given mods

Examples found in repository?
examples/basic_usage.rs (line 20)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    println!("Parsing .qua file...");
5    
6    // Parse the .qua file
7    let qua = Qua::from_file("assets/171402.qua")?;
8    
9    println!("Map: {} - {}", qua.metadata.title, qua.metadata.artist);
10    println!("Creator: {}", qua.metadata.creator);
11    println!("Difficulty: {}", qua.metadata.difficulty_name);
12    println!("Mode: {:?}", qua.metadata.mode);
13    println!("Hit Objects: {}", qua.hit_objects.len());
14    println!("Timing Points: {}", qua.timing_points.len());
15    
16    // Calculate difficulty
17    println!("\nCalculating difficulty...");
18    let constants = StrainConstants::new(None);
19    let mut processor = DifficultyProcessor::new(qua, constants, ModIdentifier::NONE);
20    processor.calculate_difficulty(ModIdentifier::NONE);
21    
22    println!("Overall Difficulty: {:.2}", processor.overall_difficulty);
23    println!("Average Note Density: {:.2}", processor.average_note_density);
24    println!("Map Length: {:.2}", processor.map.length());
25    println!("Hit Objects Count: {}", processor.map.hit_objects.len());
26    println!("Timing Points Count: {}", processor.map.timing_points.len());
27    
28    Ok(())
29}

Trait Implementations§

Source§

impl Clone for DifficultyProcessor

Source§

fn clone(&self) -> DifficultyProcessor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DifficultyProcessor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.