From d0bffe825a6c1834f1c708a7cf4dfa85f2ce8799 Mon Sep 17 00:00:00 2001 From: Jurta <29545237+Jurtaa@users.noreply.github.com> Date: Fri, 21 Nov 2025 11:41:38 +0000 Subject: [PATCH] Save total of each rating to unused hits parameter in SongScore (#831) * Save received ratings to unused hits parameter in SongScore * Adding function to set up keys for the hits map, as to prevent potential null issues --- source/funkin/game/PlayState.hx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 07968a27..cbc168ea 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -332,6 +332,10 @@ class PlayState extends MusicBeatState * The total accuracy amount. */ public var totalAccuracyAmount:Float = 0; + /** + * Tracks how much of each rating was received. + */ + public var hits:Map = []; /** * FunkinText that shows your score. @@ -364,6 +368,11 @@ class PlayState extends MusicBeatState public static var campaignAccuracyTotal:Float = 0; public static var campaignAccuracyCount:Float = 0; + /** + * Number of each rating received for the current week. + */ + public static var campaignHits:Map = []; + /** * Camera zoom at which the game lerps to. */ @@ -680,6 +689,8 @@ class PlayState extends MusicBeatState detailsText = isStoryMode ? ("Story Mode: " + storyWeek.name) : "Freeplay"; + for (rating in [for (i in ratingManager.ratingData) i.name]) hits.set(rating, 0); // Ensure all keys exist as to prevent null errors. + // Checks if cutscene files exists var cutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene'); var endCutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene-end'); @@ -1731,7 +1742,7 @@ class PlayState extends MusicBeatState score: songScore, misses: misses, accuracy: accuracy, - hits: [], + hits: hits, date: Date.now().toString() }, getSongChanges()); #end @@ -1758,6 +1769,7 @@ class PlayState extends MusicBeatState campaignMisses += misses; campaignAccuracyTotal += accuracy; campaignAccuracyCount++; + for (k => v in hits) campaignHits[k] += v; storyPlaylist.shift(); storyVariations.shift(); @@ -1771,7 +1783,7 @@ class PlayState extends MusicBeatState score: campaignScore, misses: campaignMisses, accuracy: campaignAccuracy, - hits: [], + hits: campaignHits, date: Date.now().toString() }); #end @@ -1941,6 +1953,7 @@ class PlayState extends MusicBeatState displayCombo(event); if (event.displayRating) displayRating(event.rating, event); + hits[rating.name] += 1; ratingNum += 1; } } @@ -2178,6 +2191,7 @@ class PlayState extends MusicBeatState campaignMisses = 0; campaignAccuracyTotal = 0; campaignAccuracyCount = 0; + campaignHits = []; chartingMode = coopMode = opponentMode = false; __loadSong(storyPlaylist[0], difficulty, storyVariations[0]); }