Merge pull request #431 from poco0317/FIXIES/nps
Fix nps counter and add a max nps counter
This commit is contained in:
commit
2c6a0faa9f
@ -1649,6 +1649,8 @@ class PlayState extends MusicBeatState
|
|||||||
private var paused:Bool = false;
|
private var paused:Bool = false;
|
||||||
var startedCountdown:Bool = false;
|
var startedCountdown:Bool = false;
|
||||||
var canPause:Bool = true;
|
var canPause:Bool = true;
|
||||||
|
var nps:Int = 0;
|
||||||
|
var maxNPS:Int = 0;
|
||||||
|
|
||||||
public static var songRate = 1.5;
|
public static var songRate = 1.5;
|
||||||
|
|
||||||
@ -1717,20 +1719,24 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
if (currentFrames == FlxG.save.data.fpsCap)
|
// reverse iterate to remove oldest notes first and not invalidate the iteration
|
||||||
|
// stop iteration as soon as a note is not removed
|
||||||
|
// all notes should be kept in the correct order and this is optimal, safe to do every frame/update
|
||||||
{
|
{
|
||||||
for(i in 0...notesHitArray.length)
|
var balls = notesHitArray.length-1;
|
||||||
|
while (balls >= 0)
|
||||||
{
|
{
|
||||||
var cock:Date = notesHitArray[i];
|
var cock:Date = notesHitArray[balls];
|
||||||
if (cock != null)
|
if (cock != null && cock.getTime() + 1000 < Date.now().getTime())
|
||||||
if (cock.getTime() + 2000 < Date.now().getTime())
|
notesHitArray.remove(cock);
|
||||||
notesHitArray.remove(cock);
|
else
|
||||||
|
balls = 0;
|
||||||
|
balls--;
|
||||||
}
|
}
|
||||||
nps = Math.floor(notesHitArray.length / 2);
|
nps = notesHitArray.length;
|
||||||
currentFrames = 0;
|
if (nps > maxNPS)
|
||||||
|
maxNPS = nps;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
currentFrames++;
|
|
||||||
|
|
||||||
if (FlxG.keys.justPressed.NINE)
|
if (FlxG.keys.justPressed.NINE)
|
||||||
{
|
{
|
||||||
@ -1758,7 +1764,7 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,accuracy);
|
scoreTxt.text = Ratings.CalculateRanking(songScore,songScoreDef,nps,maxNPS,accuracy);
|
||||||
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
|
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
|
||||||
{
|
{
|
||||||
persistentUpdate = false;
|
persistentUpdate = false;
|
||||||
@ -3034,8 +3040,6 @@ class PlayState extends MusicBeatState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nps:Int = 0;
|
|
||||||
|
|
||||||
function goodNoteHit(note:Note, resetMashViolation = true):Void
|
function goodNoteHit(note:Note, resetMashViolation = true):Void
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -3046,8 +3050,10 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
note.rating = Ratings.CalculateRating(noteDiff);
|
note.rating = Ratings.CalculateRating(noteDiff);
|
||||||
|
|
||||||
|
// add newest note to front of notesHitArray
|
||||||
|
// the oldest notes are at the end and are removed first
|
||||||
if (!note.isSustainNote)
|
if (!note.isSustainNote)
|
||||||
notesHitArray.push(Date.now());
|
notesHitArray.unshift(Date.now());
|
||||||
|
|
||||||
if (!resetMashViolation && mashViolations >= 1)
|
if (!resetMashViolation && mashViolations >= 1)
|
||||||
mashViolations--;
|
mashViolations--;
|
||||||
|
@ -129,10 +129,10 @@ class Ratings
|
|||||||
return "sick";
|
return "sick";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function CalculateRanking(score:Int,scoreDef:Int,nps:Int,accuracy:Float):String
|
public static function CalculateRanking(score:Int,scoreDef:Int,nps:Int,maxNPS:Int,accuracy:Float):String
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(FlxG.save.data.npsDisplay ? "NPS: " + nps + (!FlxG.save.data.botplay ? " | " : "") : "") + (!FlxG.save.data.botplay ? // NPS Toggle
|
(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
|
"Score:" + (Conductor.safeFrames != 10 ? score + " (" + scoreDef + ")" : "" + score) + // Score
|
||||||
" | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks
|
" | Combo Breaks:" + PlayState.misses + // Misses/Combo Breaks
|
||||||
" | Accuracy:" + (FlxG.save.data.botplay ? "N/A" : HelperFunctions.truncateFloat(accuracy, 2) + " %") + // Accuracy
|
" | Accuracy:" + (FlxG.save.data.botplay ? "N/A" : HelperFunctions.truncateFloat(accuracy, 2) + " %") + // Accuracy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user