Skip to content

Commit

Permalink
After-test debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
captainerd committed May 24, 2024
1 parent 9198375 commit 18ba27c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
22 changes: 17 additions & 5 deletions neothesia/src/scene/menu_scene/iced_menu/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,20 @@ impl Page for StatsPage {

// Populate data into tracks
for (index, stats) in sorted_stats.iter().enumerate() {
let scores = stats.notes_hit + stats.correct_note_times * 10
- (stats.notes_missed + stats.wrong_note_times + stats.notes_missed); // There are many ways to cook
let mut scores = stats.notes_hit + stats.correct_note_times * 10; // There are many ways to cook


// Apply penalties
if stats.notes_missed > 0 {
scores = scores.saturating_sub(stats.notes_missed);
}
if stats.wrong_notes > 0 {
scores = scores.saturating_sub(stats.wrong_notes);
}

// Final bonus addition
scores += stats.correct_note_times;

let datetime: DateTime<Local> = stats.date.into();
let score = (index + 1) as u32;
let trophy_image = if score <= 3 { score } else { 0 };
Expand Down Expand Up @@ -99,7 +111,7 @@ impl Page for StatsPage {
.spacing(10)
.align_items(Alignment::Start),
)
.height(ctx.window_state.logical_size.height as u16 - 400);
.height(ctx.window_state.logical_size.height as u16 - 250);

let mut elements = Vec::new();
let scrollable_element: Element<'_, Event> = scrollable.into();
Expand All @@ -111,8 +123,8 @@ impl Page for StatsPage {
.date("Date")
.place("Place")
.score("Score")
.notes_hits("Hits")
.notes_missed("Missed notes")
.notes_hits("Good Hits")
.notes_missed("Slow Hits")
.wrong_notes("Wrong notes")
.correct_notes_duration("Good Durations")
.header(true);
Expand Down
21 changes: 12 additions & 9 deletions neothesia/src/scene/playing_scene/midi_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl PlayAlong {
.iter()
.position(|item| item.note_id == note_id)
{
if let None = self
/* if let None = self
.user_pressed_recently
.iter_mut()
.find(|item| item.note_id == note_id)
Expand All @@ -335,6 +335,8 @@ impl PlayAlong {
self.user_stats.wrong_notes -= 1;
}
*/

if timestamp
.duration_since(self.required_notes[index].timestamp)
.as_millis()
Expand Down Expand Up @@ -520,15 +522,16 @@ impl PlayAlong {
// Loop through user_stats.note_durations items, compare user_note_dur to file_note_dur
let mut correct_note_times = 0;
let mut wrong_note_times = 0;
// make it relaxed, Lower Bound: 83% of the file's note duration, Upper Bound: 112% of the file's note duration.
for duration in &self.user_stats.note_durations {
// Compare user_note_dur to file_note_dur
let duration_difference =
(duration.user_note_dur as f64 - duration.file_note_dur as f64).abs();
let percentage_difference =
duration_difference / duration.user_note_dur as f64 * 100.0;

// Increment correctNoteTimes if it is close to 90%, otherwise increment wrongNoteTimes
if percentage_difference <= 10.0 {
// Calculate the lower and upper bounds for a "correct" duration
let lower_bound = duration.file_note_dur as f64 * 0.83;
let upper_bound = duration.file_note_dur as f64 * 1.12;

// Increment correctNoteTimes if it is within the bounds, otherwise increment wrongNoteTimes
if (duration.user_note_dur as f64) >= lower_bound
&& (duration.user_note_dur as f64) <= upper_bound
{
correct_note_times += 1;
} else {
wrong_note_times += 1;
Expand Down

0 comments on commit 18ba27c

Please sign in to comment.