diff --git a/source/funkin/Highscore.hx b/source/funkin/Highscore.hx index 44b0e0f74..e2987443d 100644 --- a/source/funkin/Highscore.hx +++ b/source/funkin/Highscore.hx @@ -8,10 +8,32 @@ import flixel.FlxG; class Highscore { /** - * Keeps track of notes hit for the current song / week, + * Keeps track of notes hit for the current song * and how accurate you were with each note (bad, missed, shit, etc.) */ public static var tallies:Tallies = new Tallies(); + + /** + * Keeps track of notes hit for the current WEEK / level + * for use with storymode, or likely any other "playlist" esque option + */ + public static var talliesLevel:Tallies = new Tallies(); + + public static function combineTallies(tally1:Tallies, tally2:Tallies):Tallies + { + var combinedTally:Tallies = new Tallies(); + combinedTally.combo = tally1.combo + tally2.combo; + combinedTally.missed = tally1.missed + tally2.missed; + combinedTally.shit = tally1.shit + tally2.shit; + combinedTally.bad = tally1.bad + tally2.bad; + combinedTally.good = tally1.good + tally2.good; + combinedTally.sick = tally1.sick + tally2.sick; + combinedTally.totalNotes = tally1.totalNotes + tally2.totalNotes; + combinedTally.totalNotesHit = tally1.totalNotesHit + tally2.totalNotesHit; + combinedTally.maxCombo = tally1.maxCombo + tally2.maxCombo; + + return combinedTally; + } } @:forward diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 6e8f22908..04a18fb95 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -2458,8 +2458,6 @@ class PlayState extends MusicBeatSubState health += healthChange; - FlxG.watch.addQuick("COMBO: ", Highscore.tallies.combo); - if (isComboBreak) { // Break the combo, but don't increment tallies.misses. @@ -2625,6 +2623,9 @@ class PlayState extends MusicBeatSubState accuracy: Highscore.tallies.totalNotesHit / currentChart.notes.length, }; + // adds current song data into the tallies for the level (story levels) + Highscore.talliesLevel = Highscore.combineTallies(Highscore.tallies, Highscore.talliesLevel); + if (Save.instance.isSongHighScore(currentSong.id, currentDifficulty, data)) { Save.instance.setSongScore(currentSong.id, currentDifficulty, data); @@ -2893,11 +2894,14 @@ class PlayState extends MusicBeatSubState persistentUpdate = false; vocals.stop(); camHUD.alpha = 1; + + var talliesToUse:Tallies = PlayStatePlaylist.isStoryMode ? Highscore.talliesLevel : Highscore.tallies; + var res:ResultState = new ResultState( { storyMode: PlayStatePlaylist.isStoryMode, title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'), - tallies: Highscore.tallies, + tallies: talliesToUse, }); res.camera = camHUD; openSubState(res); diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index ba1d2ed21..59e1bbdc1 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -519,7 +519,7 @@ class StoryMenuState extends MusicBeatState } } - function selectLevel() + function selectLevel():Void { if (!currentLevel.isUnlocked()) { @@ -554,6 +554,8 @@ class StoryMenuState extends MusicBeatState PlayStatePlaylist.campaignTitle = currentLevel.getTitle(); PlayStatePlaylist.campaignDifficulty = currentDifficultyId; + Highscore.talliesLevel = new funkin.Highscore.Tallies(); + new FlxTimer().start(1, function(tmr:FlxTimer) { FlxTransitionableState.skipNextTransIn = false; FlxTransitionableState.skipNextTransOut = false;