From cc32c8571d9e5006c0ec2499711d4465bc42d63b Mon Sep 17 00:00:00 2001 From: Lucky56 <55949451+Lucky-56@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:51:39 +0200 Subject: [PATCH 1/5] still gotta fix this --- source/PlayState.hx | 4 +--- source/Ratings.hx | 14 ++++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index f791cb3..ab4e979 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1851,9 +1851,7 @@ class PlayState extends MusicBeatState super.update(elapsed); - scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,maxNPS,accuracy); - if (!FlxG.save.data.accuracyDisplay) - scoreTxt.text = "Score: " + songScore; + scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,maxNPS,accuracy); if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause) { diff --git a/source/Ratings.hx b/source/Ratings.hx index 615d3ba..45dca20 100644 --- a/source/Ratings.hx +++ b/source/Ratings.hx @@ -131,11 +131,13 @@ class Ratings public static function CalculateRanking(score:Int,scoreDef:Int,nps:Int,maxNPS:Int,accuracy:Float):String { - return - (FlxG.save.data.npsDisplay ? "NPS: " + nps + " (Max " + maxNPS + ")" + (!FlxG.save.data.botplay ? " | " : "") : "") + (!FlxG.save.data.botplay ? // NPS Toggle - "Score:" + (Conductor.safeFrames != 10 ? score + " (" + scoreDef + ")" : "" + score) + // Score - " | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks - " | Accuracy:" + (FlxG.save.data.botplay ? "N/A" : HelperFunctions.truncateFloat(accuracy, 2) + " %") + // Accuracy - " | " + GenerateLetterRank(accuracy) : ""); // Letter Rank + return + (FlxG.save.data.npsDisplay ? // NPS Toggle + "NPS: " + nps + " (Max " + maxNPS + ")" + (!FlxG.save.data.botplay ? " | " : "") : "") + // NPS + (!FlxG.save.data.botplay ? "Score:" + (Conductor.safeFrames != 10 ? score + " (" + scoreDef + ")" : "" + score) + // Score + (FlxG.save.data.accuracyDisplay ? // Accuracy Toggle + " | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks + " | Accuracy:" + (FlxG.save.data.botplay ? "N/A" : HelperFunctions.truncateFloat(accuracy, 2) + " %") + // Accuracy + " | " + GenerateLetterRank(accuracy) : "") : ""); // Letter Rank } } From 255afc3ac8662510cf7ba95982f0f8f758bf6f31 Mon Sep 17 00:00:00 2001 From: Detoria <44783518+theDetourist@users.noreply.github.com> Date: Thu, 17 Jun 2021 07:16:54 -0300 Subject: [PATCH 2/5] yeh --- source/OptionsMenu.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 03cf31c..f405e97 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -145,7 +145,6 @@ class OptionsMenu extends MusicBeatState if (isCat) { - if (currentSelectedCat.getOptions()[curSelected].getAccept()) { if (FlxG.keys.pressed.SHIFT) @@ -165,7 +164,6 @@ class OptionsMenu extends MusicBeatState } else { - if (FlxG.keys.pressed.SHIFT) { if (FlxG.keys.justPressed.RIGHT) @@ -178,7 +176,7 @@ class OptionsMenu extends MusicBeatState else if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset -= 0.1; - + versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } if (currentSelectedCat.getOptions()[curSelected].getAccept()) versionShit.text = currentSelectedCat.getOptions()[curSelected].getValue() + " - Description - " + currentDescription; @@ -198,6 +196,8 @@ class OptionsMenu extends MusicBeatState FlxG.save.data.offset += 0.1; else if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset -= 0.1; + + versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } From cf06003918cc2fe0d991dc3aa080f8938bfe963b Mon Sep 17 00:00:00 2001 From: Detoria <44783518+theDetourist@users.noreply.github.com> Date: Thu, 17 Jun 2021 08:17:38 -0300 Subject: [PATCH 3/5] yeh pt.2 --- source/OptionsMenu.hx | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index f405e97..3e91002 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -129,14 +129,17 @@ class OptionsMenu extends MusicBeatState isCat = false; grpControls.clear(); for (i in 0...options.length) - { - var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, options[i].getName(), true, false); - controlLabel.isMenuItem = true; - controlLabel.targetY = i; - grpControls.add(controlLabel); - // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! - } + { + var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, options[i].getName(), true, false); + controlLabel.isMenuItem = true; + controlLabel.targetY = i; + grpControls.add(controlLabel); + // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! + } + curSelected = 0; + + changeSelection(curSelected); } if (controls.UP_P) changeSelection(-1); @@ -186,18 +189,18 @@ class OptionsMenu extends MusicBeatState else { if (FlxG.keys.pressed.SHIFT) - { - if (FlxG.keys.justPressed.RIGHT) - FlxG.save.data.offset += 0.1; - else if (FlxG.keys.justPressed.LEFT) - FlxG.save.data.offset -= 0.1; - } - else if (FlxG.keys.pressed.RIGHT) + { + if (FlxG.keys.justPressed.RIGHT) FlxG.save.data.offset += 0.1; - else if (FlxG.keys.pressed.LEFT) + else if (FlxG.keys.justPressed.LEFT) FlxG.save.data.offset -= 0.1; - - versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; + } + else if (FlxG.keys.pressed.RIGHT) + FlxG.save.data.offset += 0.1; + else if (FlxG.keys.pressed.LEFT) + FlxG.save.data.offset -= 0.1; + + versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } @@ -230,6 +233,8 @@ class OptionsMenu extends MusicBeatState } curSelected = 0; } + + changeSelection(curSelected); } } FlxG.save.flush(); From af627cc241acde363ec1cc3c9a7b197106af6e8d Mon Sep 17 00:00:00 2001 From: Lucky56 <55949451+Lucky-56@users.noreply.github.com> Date: Thu, 17 Jun 2021 23:19:34 +0200 Subject: [PATCH 4/5] the acquired combo will now be saved and seen in freeplay --- source/FreeplayState.hx | 9 ++++++ source/Highscore.hx | 65 +++++++++++++++++++++++++++++++++++++++++ source/PlayState.hx | 1 + 3 files changed, 75 insertions(+) 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 } From 3b3fedd9813801e09c7132df2a47c714fd318fb0 Mon Sep 17 00:00:00 2001 From: Lucky56 <55949451+Lucky-56@users.noreply.github.com> Date: Fri, 18 Jun 2021 00:04:32 +0200 Subject: [PATCH 5/5] code cleanup --- source/Highscore.hx | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/source/Highscore.hx b/source/Highscore.hx index f08afd9..96d2ab6 100644 --- a/source/Highscore.hx +++ b/source/Highscore.hx @@ -39,37 +39,12 @@ class Highscore { 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) + if (getComboInt(songCombos.get(daSong)) < getComboInt(finalCombo)) setCombo(daSong, finalCombo); } else @@ -129,6 +104,23 @@ class Highscore return daSong; } + static function getComboInt(combo:String):Int + { + switch(combo) + { + case 'SDCB': + return 1; + case 'FC': + return 2; + case 'GFC': + return 3; + case 'MFC': + return 4; + default: + return 0; + } + } + public static function getScore(song:String, diff:Int):Int { if (!songScores.exists(formatSong(song, diff)))