adding maxMisses to ComboRating

This commit is contained in:
⍚~Nex
2025-05-02 17:55:21 +02:00
parent b5b604e580
commit ba92501968
3 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -119,7 +119,7 @@ class HScript extends Script {
interp.execute(expr);
call("new", []);
}
#if GLOBAL_SCRIPT
funkin.backend.scripting.GlobalScript.call("onScriptSetup", [this, "hscript"]);
#end
@@ -2,7 +2,7 @@ package funkin.backend.scripting.events;
final class RatingUpdateEvent extends CancellableEvent {
/**
New combo
New combo (may be null if no ratings were found)
**/
public var rating:ComboRating;
/**
+6 -4
View File
@@ -522,10 +522,10 @@ class PlayState extends MusicBeatState
*/
public function updateRating() {
var rating = null;
var acc = get_accuracy();
var acc = accuracy; // caching since it has a getter with an operation - Nex
for(e in comboRatings)
if (e.percent <= acc && (rating == null || rating.percent < e.percent))
if (comboRatings != null && comboRatings.length > 0) for (e in comboRatings)
if ((e.percent <= acc && e.maxMisses >= misses) && (rating == null || (rating.percent < e.percent && e.maxMisses >= misses)))
rating = e;
var event = scripts.event("onRatingUpdate", EventManager.get(RatingUpdateEvent).recycle(rating, curRating));
@@ -1970,8 +1970,10 @@ final class ComboRating {
public var percent:Float;
public var rating:String;
public var color:FlxColor;
public var maxMisses:Float; // Float since it could be Math.POSITIVE_INFINITY - Nex
public function new(percent:Float, rating:String, color:FlxColor) {
public function new(?percent:Float, ?rating:String, ?color:FlxColor, ?misses:Float) {
maxMisses = misses == null || Math.isNaN(misses) ? Math.POSITIVE_INFINITY : misses;
this.percent = percent;
this.rating = rating;
this.color = color;