2022-07-07 01:49:42 +00:00
|
|
|
package funkin.play.scoring;
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
import funkin.save.Save.SaveScoreData;
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
/**
|
|
|
|
* Which system to use when scoring and judging notes.
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
enum abstract ScoringSystem(String)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The scoring system used in versions of the game Week 6 and older.
|
|
|
|
* Scores the player based on judgement, represented by a step function.
|
|
|
|
*/
|
|
|
|
var LEGACY;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The scoring system used in Week 7. It has tighter scoring windows than Legacy.
|
|
|
|
* Scores the player based on judgement, represented by a step function.
|
|
|
|
*/
|
|
|
|
var WEEK7;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Points Based On Timing scoring system, version 1
|
|
|
|
* Scores the player based on the offset based on timing, represented by a sigmoid function.
|
|
|
|
*/
|
|
|
|
var PBOT1;
|
2022-07-07 01:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A static class which holds any functions related to scoring.
|
|
|
|
*/
|
2023-01-23 03:25:45 +00:00
|
|
|
class Scoring
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine the score a note receives under a given scoring system.
|
|
|
|
* @param msTiming The difference between the note's time and when it was hit.
|
|
|
|
* @param scoringSystem The scoring system to use.
|
|
|
|
* @return The score the note receives.
|
|
|
|
*/
|
2023-02-22 01:58:15 +00:00
|
|
|
public static function scoreNote(msTiming:Float, scoringSystem:ScoringSystem = PBOT1):Int
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
return switch (scoringSystem)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
case LEGACY: scoreNoteLEGACY(msTiming);
|
|
|
|
case WEEK7: scoreNoteWEEK7(msTiming);
|
|
|
|
case PBOT1: scoreNotePBOT1(msTiming);
|
2023-01-23 03:25:45 +00:00
|
|
|
default:
|
2024-03-27 05:25:38 +00:00
|
|
|
FlxG.log.error('Unknown scoring system: ${scoringSystem}');
|
2023-02-22 01:58:15 +00:00
|
|
|
0;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine the judgement a note receives under a given scoring system.
|
|
|
|
* @param msTiming The difference between the note's time and when it was hit.
|
2023-02-22 01:58:15 +00:00
|
|
|
* @param scoringSystem The scoring system to use.
|
2023-01-23 03:25:45 +00:00
|
|
|
* @return The judgement the note receives.
|
|
|
|
*/
|
|
|
|
public static function judgeNote(msTiming:Float, scoringSystem:ScoringSystem = PBOT1):String
|
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
return switch (scoringSystem)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
case LEGACY: judgeNoteLEGACY(msTiming);
|
|
|
|
case WEEK7: judgeNoteWEEK7(msTiming);
|
|
|
|
case PBOT1: judgeNotePBOT1(msTiming);
|
2023-01-23 03:25:45 +00:00
|
|
|
default:
|
2024-03-27 05:25:38 +00:00
|
|
|
FlxG.log.error('Unknown scoring system: ${scoringSystem}');
|
2023-02-22 01:58:15 +00:00
|
|
|
'miss';
|
2022-07-07 01:49:42 +00:00
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-02-22 01:58:15 +00:00
|
|
|
* The maximum score a note can receive.
|
|
|
|
*/
|
|
|
|
public static final PBOT1_MAX_SCORE:Int = 500;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The offset of the sigmoid curve for the scoring function.
|
|
|
|
*/
|
|
|
|
public static final PBOT1_SCORING_OFFSET:Float = 54.99;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The slope of the sigmoid curve for the scoring function.
|
|
|
|
*/
|
|
|
|
public static final PBOT1_SCORING_SLOPE:Float = 0.080;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The minimum score a note can receive while still being considered a hit.
|
2023-01-23 03:25:45 +00:00
|
|
|
*/
|
2023-02-22 01:58:15 +00:00
|
|
|
public static final PBOT1_MIN_SCORE:Float = 9.0;
|
2022-07-07 01:49:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
/**
|
2023-02-22 01:58:15 +00:00
|
|
|
* The score a note receives when it is missed.
|
2023-01-23 03:25:45 +00:00
|
|
|
*/
|
2023-02-22 01:58:15 +00:00
|
|
|
public static final PBOT1_MISS_SCORE:Int = 0;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The threshold at which a note hit is considered perfect and always given the max score.
|
2023-02-22 01:58:15 +00:00
|
|
|
*/
|
|
|
|
public static final PBOT1_PERFECT_THRESHOLD:Float = 5.0; // 5ms
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
/**
|
2023-02-22 01:58:15 +00:00
|
|
|
* The threshold at which a note hit is considered missed.
|
|
|
|
* `160ms`
|
|
|
|
*/
|
|
|
|
public static final PBOT1_MISS_THRESHOLD:Float = 160.0;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
/**
|
|
|
|
* The time within which a note is considered to have been hit with the Killer judgement.
|
|
|
|
* `~7.5% of the hit window, or 12.5ms`
|
|
|
|
*/
|
|
|
|
public static final PBOT1_KILLER_THRESHOLD:Float = 12.5;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The time within which a note is considered to have been hit with the Sick judgement.
|
|
|
|
* `~25% of the hit window, or 45ms`
|
|
|
|
*/
|
|
|
|
public static final PBOT1_SICK_THRESHOLD:Float = 45.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The time within which a note is considered to have been hit with the Good judgement.
|
|
|
|
* `~55% of the hit window, or 90ms`
|
|
|
|
*/
|
|
|
|
public static final PBOT1_GOOD_THRESHOLD:Float = 90.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The time within which a note is considered to have been hit with the Bad judgement.
|
|
|
|
* `~85% of the hit window, or 135ms`
|
|
|
|
*/
|
|
|
|
public static final PBOT1_BAD_THRESHOLD:Float = 135.0;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
/**
|
|
|
|
* The time within which a note is considered to have been hit with the Shit judgement.
|
|
|
|
* `100% of the hit window, or 160ms`
|
|
|
|
*/
|
|
|
|
public static final PBOT1_SHIT_THRESHOLD:Float = 160.0;
|
|
|
|
|
|
|
|
static function scoreNotePBOT1(msTiming:Float):Int
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
// Absolute value because otherwise late hits are always given the max score.
|
2023-02-22 01:58:15 +00:00
|
|
|
var absTiming:Float = Math.abs(msTiming);
|
2022-07-07 01:49:42 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
return switch (absTiming)
|
|
|
|
{
|
|
|
|
case(_ > PBOT1_MISS_THRESHOLD) => true:
|
|
|
|
PBOT1_MISS_SCORE;
|
|
|
|
case(_ < PBOT1_PERFECT_THRESHOLD) => true:
|
|
|
|
PBOT1_MAX_SCORE;
|
|
|
|
default:
|
2024-03-27 05:25:38 +00:00
|
|
|
// Fancy equation.
|
2023-02-22 01:58:15 +00:00
|
|
|
var factor:Float = 1.0 - (1.0 / (1.0 + Math.exp(-PBOT1_SCORING_SLOPE * (absTiming - PBOT1_SCORING_OFFSET))));
|
2024-03-27 05:25:38 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
var score:Int = Std.int(PBOT1_MAX_SCORE * factor + PBOT1_MIN_SCORE);
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
score;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
static function judgeNotePBOT1(msTiming:Float):String
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
var absTiming:Float = Math.abs(msTiming);
|
|
|
|
|
|
|
|
return switch (absTiming)
|
|
|
|
{
|
2024-01-16 03:10:42 +00:00
|
|
|
// case(_ < PBOT1_KILLER_THRESHOLD) => true:
|
|
|
|
// 'killer';
|
2023-02-22 01:58:15 +00:00
|
|
|
case(_ < PBOT1_SICK_THRESHOLD) => true:
|
|
|
|
'sick';
|
|
|
|
case(_ < PBOT1_GOOD_THRESHOLD) => true:
|
|
|
|
'good';
|
|
|
|
case(_ < PBOT1_BAD_THRESHOLD) => true:
|
|
|
|
'bad';
|
|
|
|
case(_ < PBOT1_SHIT_THRESHOLD) => true:
|
|
|
|
'shit';
|
|
|
|
default:
|
2024-03-27 05:25:38 +00:00
|
|
|
FlxG.log.warn('Missed note: Bad timing ($absTiming < $PBOT1_SHIT_THRESHOLD)');
|
2023-02-22 01:58:15 +00:00
|
|
|
'miss';
|
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The window of time in which a note is considered to be hit, on the Funkin Legacy scoring system.
|
|
|
|
* Currently equal to 10 frames at 60fps, or ~166ms.
|
|
|
|
*/
|
2023-02-22 01:58:15 +00:00
|
|
|
public static final LEGACY_HIT_WINDOW:Float = (10 / 60) * 1000; // 166.67 ms hit window (10 frames at 60fps)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The threshold at which a note is considered a "Sick" hit rather than another judgement.
|
|
|
|
* Represented as a percentage of the total hit window.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_SICK_THRESHOLD:Float = 0.2;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
/**
|
2023-02-22 01:58:15 +00:00
|
|
|
* The threshold at which a note is considered a "Good" hit rather than another judgement.
|
2023-01-23 03:25:45 +00:00
|
|
|
* Represented as a percentage of the total hit window.
|
|
|
|
*/
|
2023-02-22 01:58:15 +00:00
|
|
|
public static final LEGACY_GOOD_THRESHOLD:Float = 0.75;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
/**
|
|
|
|
* The threshold at which a note is considered a "Bad" hit rather than another judgement.
|
|
|
|
* Represented as a percentage of the total hit window.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_BAD_THRESHOLD:Float = 0.9;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
/**
|
|
|
|
* The score a note receives when hit within the Shit threshold, rather than a miss.
|
|
|
|
* Represented as a percentage of the total hit window.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_SHIT_THRESHOLD:Float = 1.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The score a note receives when hit within the Sick threshold.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_SICK_SCORE:Int = 350;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The score a note receives when hit within the Good threshold.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_GOOD_SCORE:Int = 200;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The score a note receives when hit within the Bad threshold.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_BAD_SCORE:Int = 100;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The score a note receives when hit within the Shit threshold.
|
|
|
|
*/
|
|
|
|
public static final LEGACY_SHIT_SCORE:Int = 50;
|
|
|
|
|
|
|
|
static function scoreNoteLEGACY(msTiming:Float):Int
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
var absTiming:Float = Math.abs(msTiming);
|
|
|
|
|
|
|
|
return switch (absTiming)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_SICK_THRESHOLD) => true:
|
|
|
|
LEGACY_SICK_SCORE;
|
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_GOOD_THRESHOLD) => true:
|
|
|
|
LEGACY_GOOD_SCORE;
|
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_BAD_THRESHOLD) => true:
|
|
|
|
LEGACY_BAD_SCORE;
|
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_SHIT_THRESHOLD) => true:
|
|
|
|
LEGACY_SHIT_SCORE;
|
|
|
|
default:
|
|
|
|
0;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
static function judgeNoteLEGACY(msTiming:Float):String
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
var absTiming:Float = Math.abs(msTiming);
|
|
|
|
|
|
|
|
return switch (absTiming)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_SICK_THRESHOLD) => true:
|
|
|
|
'sick';
|
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_GOOD_THRESHOLD) => true:
|
|
|
|
'good';
|
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_BAD_THRESHOLD) => true:
|
|
|
|
'bad';
|
|
|
|
case(_ < LEGACY_HIT_WINDOW * LEGACY_SHIT_THRESHOLD) => true:
|
|
|
|
'shit';
|
|
|
|
default:
|
2024-03-27 05:25:38 +00:00
|
|
|
FlxG.log.warn('Missed note: Bad timing ($absTiming < $LEGACY_SHIT_THRESHOLD)');
|
2023-02-22 01:58:15 +00:00
|
|
|
'miss';
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The window of time in which a note is considered to be hit, on the Funkin Classic scoring system.
|
|
|
|
* Same as L 10 frames at 60fps, or ~166ms.
|
|
|
|
*/
|
2023-02-22 01:58:15 +00:00
|
|
|
public static final WEEK7_HIT_WINDOW:Float = LEGACY_HIT_WINDOW;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
public static final WEEK7_BAD_THRESHOLD:Float = 0.8; // 80% of the hit window, or ~125ms
|
|
|
|
public static final WEEK7_GOOD_THRESHOLD:Float = 0.55; // 55% of the hit window, or ~91ms
|
|
|
|
public static final WEEK7_SICK_THRESHOLD:Float = 0.2; // 20% of the hit window, or ~33ms
|
|
|
|
public static final WEEK7_SHIT_SCORE:Int = 50;
|
|
|
|
public static final WEEK7_BAD_SCORE:Int = 100;
|
|
|
|
public static final WEEK7_GOOD_SCORE:Int = 200;
|
|
|
|
public static final WEEK7_SICK_SCORE:Int = 350;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
static function scoreNoteWEEK7(msTiming:Float):Int
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-02-22 01:58:15 +00:00
|
|
|
var absTiming:Float = Math.abs(msTiming);
|
|
|
|
|
|
|
|
return switch (absTiming)
|
|
|
|
{
|
|
|
|
case(_ < WEEK7_HIT_WINDOW * WEEK7_SICK_THRESHOLD) => true:
|
|
|
|
LEGACY_SICK_SCORE;
|
|
|
|
case(_ < WEEK7_HIT_WINDOW * WEEK7_GOOD_THRESHOLD) => true:
|
|
|
|
LEGACY_GOOD_SCORE;
|
|
|
|
case(_ < WEEK7_HIT_WINDOW * WEEK7_BAD_THRESHOLD) => true:
|
|
|
|
LEGACY_BAD_SCORE;
|
|
|
|
case(_ < WEEK7_HIT_WINDOW) => true:
|
|
|
|
LEGACY_SHIT_SCORE;
|
|
|
|
default:
|
|
|
|
0;
|
|
|
|
}
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (absTiming < WEEK7_HIT_WINDOW * WEEK7_SICK_THRESHOLD)
|
|
|
|
{
|
|
|
|
return WEEK7_SICK_SCORE;
|
|
|
|
}
|
|
|
|
else if (absTiming < WEEK7_HIT_WINDOW * WEEK7_GOOD_THRESHOLD)
|
|
|
|
{
|
|
|
|
return WEEK7_GOOD_SCORE;
|
|
|
|
}
|
|
|
|
else if (absTiming < WEEK7_HIT_WINDOW * WEEK7_BAD_THRESHOLD)
|
|
|
|
{
|
|
|
|
return WEEK7_BAD_SCORE;
|
|
|
|
}
|
|
|
|
else if (absTiming < WEEK7_HIT_WINDOW)
|
|
|
|
{
|
|
|
|
return WEEK7_SHIT_SCORE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-22 01:58:15 +00:00
|
|
|
static function judgeNoteWEEK7(msTiming:Float):String
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
var absTiming = Math.abs(msTiming);
|
|
|
|
if (absTiming < WEEK7_HIT_WINDOW * WEEK7_SICK_THRESHOLD)
|
|
|
|
{
|
|
|
|
return 'sick';
|
|
|
|
}
|
|
|
|
else if (absTiming < WEEK7_HIT_WINDOW * WEEK7_GOOD_THRESHOLD)
|
|
|
|
{
|
|
|
|
return 'good';
|
|
|
|
}
|
|
|
|
else if (absTiming < WEEK7_HIT_WINDOW * WEEK7_BAD_THRESHOLD)
|
|
|
|
{
|
|
|
|
return 'bad';
|
|
|
|
}
|
|
|
|
else if (absTiming < WEEK7_HIT_WINDOW)
|
|
|
|
{
|
|
|
|
return 'shit';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-03-27 05:25:38 +00:00
|
|
|
FlxG.log.warn('Missed note: Bad timing ($absTiming < $WEEK7_HIT_WINDOW)');
|
2023-01-23 03:25:45 +00:00
|
|
|
return 'miss';
|
|
|
|
}
|
|
|
|
}
|
2024-05-30 09:25:51 +00:00
|
|
|
|
|
|
|
public static function calculateRank(scoreData:Null<SaveScoreData>):Null<ScoringRank>
|
|
|
|
{
|
2024-05-31 09:39:53 +00:00
|
|
|
if (scoreData?.tallies.totalNotes == 0 || scoreData == null) return null;
|
2024-05-30 09:25:51 +00:00
|
|
|
|
2024-06-01 21:13:07 +00:00
|
|
|
// we can return null here, meaning that the player hasn't actually played and finished the song (thus has no data)
|
|
|
|
if (scoreData.tallies.totalNotes == 0) return null;
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
// Perfect (Platinum) is a Sick Full Clear
|
|
|
|
var isPerfectGold = scoreData.tallies.sick == scoreData.tallies.totalNotes;
|
2024-06-11 04:40:43 +00:00
|
|
|
if (isPerfectGold)
|
|
|
|
{
|
|
|
|
return ScoringRank.PERFECT_GOLD;
|
|
|
|
}
|
2024-05-30 09:25:51 +00:00
|
|
|
|
|
|
|
// Else, use the standard grades
|
|
|
|
|
|
|
|
// Grade % (only good and sick), 1.00 is a full combo
|
|
|
|
var grade = (scoreData.tallies.sick + scoreData.tallies.good) / scoreData.tallies.totalNotes;
|
|
|
|
// Clear % (including bad and shit). 1.00 is a full clear but not a full combo
|
|
|
|
var clear = (scoreData.tallies.totalNotesHit) / scoreData.tallies.totalNotes;
|
|
|
|
|
|
|
|
if (grade == Constants.RANK_PERFECT_THRESHOLD)
|
|
|
|
{
|
|
|
|
return ScoringRank.PERFECT;
|
|
|
|
}
|
|
|
|
else if (grade >= Constants.RANK_EXCELLENT_THRESHOLD)
|
|
|
|
{
|
|
|
|
return ScoringRank.EXCELLENT;
|
|
|
|
}
|
|
|
|
else if (grade >= Constants.RANK_GREAT_THRESHOLD)
|
|
|
|
{
|
|
|
|
return ScoringRank.GREAT;
|
|
|
|
}
|
|
|
|
else if (grade >= Constants.RANK_GOOD_THRESHOLD)
|
|
|
|
{
|
|
|
|
return ScoringRank.GOOD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ScoringRank.SHIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum abstract ScoringRank(String)
|
|
|
|
{
|
|
|
|
var PERFECT_GOLD;
|
|
|
|
var PERFECT;
|
|
|
|
var EXCELLENT;
|
|
|
|
var GREAT;
|
|
|
|
var GOOD;
|
|
|
|
var SHIT;
|
|
|
|
|
2024-06-11 04:40:43 +00:00
|
|
|
/**
|
|
|
|
* Converts ScoringRank to an integer value for comparison.
|
|
|
|
* Better ranks should be tied to a higher value.
|
|
|
|
*/
|
|
|
|
static function getValue(rank:Null<ScoringRank>):Int
|
2024-05-31 09:39:53 +00:00
|
|
|
{
|
2024-06-11 04:40:43 +00:00
|
|
|
if (rank == null) return -1;
|
|
|
|
switch (rank)
|
2024-05-31 09:39:53 +00:00
|
|
|
{
|
|
|
|
case PERFECT_GOLD:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 5;
|
2024-05-31 09:39:53 +00:00
|
|
|
case PERFECT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 4;
|
2024-05-31 09:39:53 +00:00
|
|
|
case EXCELLENT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 3;
|
2024-05-31 09:39:53 +00:00
|
|
|
case GREAT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 2;
|
2024-05-31 09:39:53 +00:00
|
|
|
case GOOD:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 1;
|
2024-05-31 09:39:53 +00:00
|
|
|
case SHIT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 0;
|
2024-05-31 09:39:53 +00:00
|
|
|
default:
|
2024-06-11 04:40:43 +00:00
|
|
|
return -1;
|
2024-05-31 09:39:53 +00:00
|
|
|
}
|
2024-06-11 04:40:43 +00:00
|
|
|
}
|
2024-05-31 09:39:53 +00:00
|
|
|
|
2024-06-11 04:40:43 +00:00
|
|
|
// Yes, we really need a different function for each comparison operator.
|
|
|
|
@:op(A > B) static function compareGT(a:Null<ScoringRank>, b:Null<ScoringRank>):Bool
|
|
|
|
{
|
|
|
|
if (a != null && b == null) return true;
|
|
|
|
if (a == null || b == null) return false;
|
2024-05-31 09:39:53 +00:00
|
|
|
|
2024-06-11 04:40:43 +00:00
|
|
|
var temp1:Int = getValue(a);
|
|
|
|
var temp2:Int = getValue(b);
|
|
|
|
|
|
|
|
return temp1 > temp2;
|
2024-05-31 09:39:53 +00:00
|
|
|
}
|
|
|
|
|
2024-06-11 04:40:43 +00:00
|
|
|
@:op(A >= B) static function compareGTEQ(a:Null<ScoringRank>, b:Null<ScoringRank>):Bool
|
|
|
|
{
|
|
|
|
if (a != null && b == null) return true;
|
|
|
|
if (a == null || b == null) return false;
|
|
|
|
|
|
|
|
var temp1:Int = getValue(a);
|
|
|
|
var temp2:Int = getValue(b);
|
|
|
|
|
|
|
|
return temp1 >= temp2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A < B) static function compareLT(a:Null<ScoringRank>, b:Null<ScoringRank>):Bool
|
|
|
|
{
|
|
|
|
if (a != null && b == null) return true;
|
|
|
|
if (a == null || b == null) return false;
|
|
|
|
|
|
|
|
var temp1:Int = getValue(a);
|
|
|
|
var temp2:Int = getValue(b);
|
|
|
|
|
|
|
|
return temp1 < temp2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A <= B) static function compareLTEQ(a:Null<ScoringRank>, b:Null<ScoringRank>):Bool
|
|
|
|
{
|
|
|
|
if (a != null && b == null) return true;
|
|
|
|
if (a == null || b == null) return false;
|
|
|
|
|
|
|
|
var temp1:Int = getValue(a);
|
|
|
|
var temp2:Int = getValue(b);
|
|
|
|
|
|
|
|
return temp1 <= temp2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @:op(A == B) isn't necessary!
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
/**
|
|
|
|
* Delay in seconds
|
|
|
|
*/
|
|
|
|
public function getMusicDelay():Float
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD | PERFECT:
|
|
|
|
// return 2.5;
|
2024-06-11 04:40:43 +00:00
|
|
|
return 95 / 24;
|
2024-05-30 09:25:51 +00:00
|
|
|
case EXCELLENT:
|
2024-06-01 00:17:11 +00:00
|
|
|
return 0;
|
|
|
|
case GREAT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 5 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GOOD:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 3 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case SHIT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 2 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
default:
|
|
|
|
return 3.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBFDelay():Float
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD | PERFECT:
|
|
|
|
// return 2.5;
|
2024-06-11 04:40:43 +00:00
|
|
|
return 95 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case EXCELLENT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 97 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GREAT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 95 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GOOD:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 95 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case SHIT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 95 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
default:
|
|
|
|
return 3.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFlashDelay():Float
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD | PERFECT:
|
|
|
|
// return 2.5;
|
2024-06-11 04:40:43 +00:00
|
|
|
return 129 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case EXCELLENT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 122 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GREAT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 109 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GOOD:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 107 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case SHIT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 186 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
default:
|
|
|
|
return 3.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHighscoreDelay():Float
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD | PERFECT:
|
|
|
|
// return 2.5;
|
2024-06-11 04:40:43 +00:00
|
|
|
return 140 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case EXCELLENT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 140 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GREAT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 129 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case GOOD:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 127 / 24;
|
2024-06-01 00:17:11 +00:00
|
|
|
case SHIT:
|
2024-06-11 04:40:43 +00:00
|
|
|
return 207 / 24;
|
2024-05-30 09:25:51 +00:00
|
|
|
default:
|
|
|
|
return 3.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMusicPath():String
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD:
|
|
|
|
return 'resultsPERFECT';
|
|
|
|
case PERFECT:
|
|
|
|
return 'resultsPERFECT';
|
|
|
|
case EXCELLENT:
|
|
|
|
return 'resultsEXCELLENT';
|
|
|
|
case GREAT:
|
|
|
|
return 'resultsNORMAL';
|
|
|
|
case GOOD:
|
|
|
|
return 'resultsNORMAL';
|
|
|
|
case SHIT:
|
|
|
|
return 'resultsSHIT';
|
|
|
|
default:
|
|
|
|
return 'resultsNORMAL';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasMusicIntro():Bool
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case EXCELLENT:
|
|
|
|
return true;
|
|
|
|
case SHIT:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFreeplayRankIconAsset():Null<String>
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD:
|
|
|
|
return 'PERFECTSICK';
|
|
|
|
case PERFECT:
|
|
|
|
return 'PERFECT';
|
|
|
|
case EXCELLENT:
|
|
|
|
return 'EXCELLENT';
|
|
|
|
case GREAT:
|
|
|
|
return 'GREAT';
|
|
|
|
case GOOD:
|
|
|
|
return 'GOOD';
|
|
|
|
case SHIT:
|
|
|
|
return 'LOSS';
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldMusicLoop():Bool
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD | PERFECT | EXCELLENT | GREAT | GOOD:
|
|
|
|
return true;
|
|
|
|
case SHIT:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHorTextAsset()
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD:
|
|
|
|
return 'resultScreen/rankText/rankScrollPERFECT';
|
|
|
|
case PERFECT:
|
|
|
|
return 'resultScreen/rankText/rankScrollPERFECT';
|
|
|
|
case EXCELLENT:
|
|
|
|
return 'resultScreen/rankText/rankScrollEXCELLENT';
|
|
|
|
case GREAT:
|
|
|
|
return 'resultScreen/rankText/rankScrollGREAT';
|
|
|
|
case GOOD:
|
|
|
|
return 'resultScreen/rankText/rankScrollGOOD';
|
|
|
|
case SHIT:
|
|
|
|
return 'resultScreen/rankText/rankScrollLOSS';
|
|
|
|
default:
|
|
|
|
return 'resultScreen/rankText/rankScrollGOOD';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVerTextAsset()
|
|
|
|
{
|
|
|
|
switch (abstract)
|
|
|
|
{
|
|
|
|
case PERFECT_GOLD:
|
|
|
|
return 'resultScreen/rankText/rankTextPERFECT';
|
|
|
|
case PERFECT:
|
|
|
|
return 'resultScreen/rankText/rankTextPERFECT';
|
|
|
|
case EXCELLENT:
|
|
|
|
return 'resultScreen/rankText/rankTextEXCELLENT';
|
|
|
|
case GREAT:
|
|
|
|
return 'resultScreen/rankText/rankTextGREAT';
|
|
|
|
case GOOD:
|
|
|
|
return 'resultScreen/rankText/rankTextGOOD';
|
|
|
|
case SHIT:
|
|
|
|
return 'resultScreen/rankText/rankTextLOSS';
|
|
|
|
default:
|
|
|
|
return 'resultScreen/rankText/rankTextGOOD';
|
|
|
|
}
|
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|