diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 4fcc985..91ca64a 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -26,9 +26,11 @@ class FreeplayState extends MusicBeatState var curDifficulty:Int = 1; var scoreText:FlxText; + var comboText:FlxText; var diffText:FlxText; var lerpScore:Int = 0; var intendedScore:Int = 0; + var combo:String = ''; private var grpSongs:FlxTypedGroup; private var curPlaying:Bool = false; @@ -106,6 +108,10 @@ class FreeplayState extends MusicBeatState diffText.font = scoreText.font; add(diffText); + comboText = new FlxText(diffText.x + 100, diffText.y, 0, "", 24); + comboText.font = diffText.font; + add(comboText); + add(scoreText); changeSelection(); @@ -176,6 +182,7 @@ class FreeplayState extends MusicBeatState lerpScore = intendedScore; scoreText.text = "PERSONAL BEST:" + lerpScore; + comboText.text = combo + '\n'; var upP = controls.UP_P; var downP = controls.DOWN_P; @@ -242,6 +249,7 @@ class FreeplayState extends MusicBeatState #if !switch intendedScore = Highscore.getScore(songHighscore, curDifficulty); + combo = Highscore.getCombo(songHighscore, curDifficulty); #end switch (curDifficulty) @@ -283,6 +291,7 @@ class FreeplayState extends MusicBeatState #if !switch intendedScore = Highscore.getScore(songHighscore, curDifficulty); + combo = Highscore.getCombo(songHighscore, curDifficulty); // lerpScore = 0; #end diff --git a/source/Highscore.hx b/source/Highscore.hx index 78a6d30..f08afd9 100644 --- a/source/Highscore.hx +++ b/source/Highscore.hx @@ -2,12 +2,15 @@ package; import flixel.FlxG; +using StringTools; class Highscore { #if (haxe >= "4.0.0") public static var songScores:Map = new Map(); + public static var songCombos:Map = new Map(); #else public static var songScores:Map = new Map(); + public static var songCombos:Map = new Map(); #end @@ -32,6 +35,48 @@ class Highscore }else trace('BotPlay detected. Score saving is disabled.'); } + public static function saveCombo(song:String, combo:String, ?diff:Int = 0):Void + { + var daSong:String = formatSong(song, diff); + var finalCombo:String = combo.split(')')[0].replace('(', ''); + var finalComboInt:Int = 0; + var existingFinalComboInt:Int = 0; + + switch(finalCombo) + { + case 'SDCB': + finalComboInt = 1; + case 'FC': + finalComboInt = 2; + case 'GFC': + finalComboInt = 3; + case 'MFC': + finalComboInt = 4; + } + + if(!FlxG.save.data.botplay) + { + if (songCombos.exists(daSong)) + { + switch(songCombos.get(daSong)) + { + case 'SDCB': + existingFinalComboInt = 1; + case 'FC': + existingFinalComboInt = 2; + case 'GFC': + existingFinalComboInt = 3; + case 'MFC': + existingFinalComboInt = 4; + } + if (existingFinalComboInt < finalComboInt) + setCombo(daSong, finalCombo); + } + else + setCombo(daSong, finalCombo); + } + } + public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void { @@ -64,6 +109,14 @@ class Highscore FlxG.save.flush(); } + static function setCombo(song:String, combo:String):Void + { + // Reminder that I don't need to format this song, it should come formatted! + songCombos.set(song, combo); + FlxG.save.data.songCombos = songCombos; + FlxG.save.flush(); + } + public static function formatSong(song:String, diff:Int):String { var daSong:String = song; @@ -84,6 +137,14 @@ class Highscore return songScores.get(formatSong(song, diff)); } + public static function getCombo(song:String, diff:Int):String + { + if (!songCombos.exists(formatSong(song, diff))) + setCombo(formatSong(song, diff), ''); + + return songCombos.get(formatSong(song, diff)); + } + public static function getWeekScore(week:Int, diff:Int):Int { if (!songScores.exists(formatSong('week' + week, diff))) @@ -98,5 +159,9 @@ class Highscore { songScores = FlxG.save.data.songScores; } + if (FlxG.save.data.songCombos != null) + { + songCombos = FlxG.save.data.songCombos; + } } } \ No newline at end of file diff --git a/source/PlayState.hx b/source/PlayState.hx index c19b57d..f81ec69 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2539,6 +2539,7 @@ class PlayState extends MusicBeatState #if !switch Highscore.saveScore(songHighscore, Math.round(songScore), storyDifficulty); + Highscore.saveCombo(songHighscore, Ratings.GenerateLetterRank(accuracy), storyDifficulty); #end }