Skip to content

Commit ba92501

Browse files
committed
adding maxMisses to ComboRating
1 parent b5b604e commit ba92501

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

source/funkin/backend/scripting/HScript.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class HScript extends Script {
119119
interp.execute(expr);
120120
call("new", []);
121121
}
122-
122+
123123
#if GLOBAL_SCRIPT
124124
funkin.backend.scripting.GlobalScript.call("onScriptSetup", [this, "hscript"]);
125125
#end

source/funkin/backend/scripting/events/RatingUpdateEvent.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package funkin.backend.scripting.events;
22

33
final class RatingUpdateEvent extends CancellableEvent {
44
/**
5-
New combo
5+
New combo (may be null if no ratings were found)
66
**/
77
public var rating:ComboRating;
88
/**

source/funkin/game/PlayState.hx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ class PlayState extends MusicBeatState
522522
*/
523523
public function updateRating() {
524524
var rating = null;
525-
var acc = get_accuracy();
525+
var acc = accuracy; // caching since it has a getter with an operation - Nex
526526

527-
for(e in comboRatings)
528-
if (e.percent <= acc && (rating == null || rating.percent < e.percent))
527+
if (comboRatings != null && comboRatings.length > 0) for (e in comboRatings)
528+
if ((e.percent <= acc && e.maxMisses >= misses) && (rating == null || (rating.percent < e.percent && e.maxMisses >= misses)))
529529
rating = e;
530530

531531
var event = scripts.event("onRatingUpdate", EventManager.get(RatingUpdateEvent).recycle(rating, curRating));
@@ -1970,8 +1970,10 @@ final class ComboRating {
19701970
public var percent:Float;
19711971
public var rating:String;
19721972
public var color:FlxColor;
1973+
public var maxMisses:Float; // Float since it could be Math.POSITIVE_INFINITY - Nex
19731974

1974-
public function new(percent:Float, rating:String, color:FlxColor) {
1975+
public function new(?percent:Float, ?rating:String, ?color:FlxColor, ?misses:Float) {
1976+
maxMisses = misses == null || Math.isNaN(misses) ? Math.POSITIVE_INFINITY : misses;
19751977
this.percent = percent;
19761978
this.rating = rating;
19771979
this.color = color;

0 commit comments

Comments
 (0)