Skip to content

Commit d0bffe8

Browse files
authored
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
1 parent be27447 commit d0bffe8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

source/funkin/game/PlayState.hx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ class PlayState extends MusicBeatState
332332
* The total accuracy amount.
333333
*/
334334
public var totalAccuracyAmount:Float = 0;
335+
/**
336+
* Tracks how much of each rating was received.
337+
*/
338+
public var hits:Map<String, Int> = [];
335339

336340
/**
337341
* FunkinText that shows your score.
@@ -364,6 +368,11 @@ class PlayState extends MusicBeatState
364368
public static var campaignAccuracyTotal:Float = 0;
365369
public static var campaignAccuracyCount:Float = 0;
366370

371+
/**
372+
* Number of each rating received for the current week.
373+
*/
374+
public static var campaignHits:Map<String, Int> = [];
375+
367376
/**
368377
* Camera zoom at which the game lerps to.
369378
*/
@@ -680,6 +689,8 @@ class PlayState extends MusicBeatState
680689

681690
detailsText = isStoryMode ? ("Story Mode: " + storyWeek.name) : "Freeplay";
682691

692+
for (rating in [for (i in ratingManager.ratingData) i.name]) hits.set(rating, 0); // Ensure all keys exist as to prevent null errors.
693+
683694
// Checks if cutscene files exists
684695
var cutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene');
685696
var endCutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene-end');
@@ -1731,7 +1742,7 @@ class PlayState extends MusicBeatState
17311742
score: songScore,
17321743
misses: misses,
17331744
accuracy: accuracy,
1734-
hits: [],
1745+
hits: hits,
17351746
date: Date.now().toString()
17361747
}, getSongChanges());
17371748
#end
@@ -1758,6 +1769,7 @@ class PlayState extends MusicBeatState
17581769
campaignMisses += misses;
17591770
campaignAccuracyTotal += accuracy;
17601771
campaignAccuracyCount++;
1772+
for (k => v in hits) campaignHits[k] += v;
17611773
storyPlaylist.shift();
17621774
storyVariations.shift();
17631775

@@ -1771,7 +1783,7 @@ class PlayState extends MusicBeatState
17711783
score: campaignScore,
17721784
misses: campaignMisses,
17731785
accuracy: campaignAccuracy,
1774-
hits: [],
1786+
hits: campaignHits,
17751787
date: Date.now().toString()
17761788
});
17771789
#end
@@ -1941,6 +1953,7 @@ class PlayState extends MusicBeatState
19411953
displayCombo(event);
19421954
if (event.displayRating)
19431955
displayRating(event.rating, event);
1956+
hits[rating.name] += 1;
19441957
ratingNum += 1;
19451958
}
19461959
}
@@ -2178,6 +2191,7 @@ class PlayState extends MusicBeatState
21782191
campaignMisses = 0;
21792192
campaignAccuracyTotal = 0;
21802193
campaignAccuracyCount = 0;
2194+
campaignHits = [];
21812195
chartingMode = coopMode = opponentMode = false;
21822196
__loadSong(storyPlaylist[0], difficulty, storyVariations[0]);
21832197
}

0 commit comments

Comments
 (0)