Skip to content

Commit 424f9c0

Browse files
committed
fix: make scoring system compare by tier first
The game will no longer save a faster solve if its tier is worse.
1 parent ea09395 commit 424f9c0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

scripts/play.gd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func _on_Level_done(level):
3838
back.text = "BACK TO LEVEL SELECT"
3939
back.connect("pressed", self, "_on_Button_pressed", ["levels"])
4040
var time = Label.new()
41-
time.text = "%.3f" % get_score()
41+
time.text = "%.3f" % score
4242
time.align = Label.ALIGN_RIGHT
4343
time.size_flags_horizontal = Control.SIZE_EXPAND_FILL
4444
_start_time = -1
@@ -61,7 +61,10 @@ func _on_Level_done(level):
6161
save[name] = {}
6262
if not size in save[name]:
6363
save[name][size] = [-1, INF]
64-
save[name][size] = [moves, min(float(time.text), save[name][size][1])]
64+
var mps1 = Score.get_mps_int(moves, score)
65+
var mps2 = Score.get_mps_int(save[name][size][0], save[name][size][1])
66+
if mps1 > mps2 or mps1 == mps2 and score < save[name][size][1]:
67+
save[name][size] = [moves, score]
6568
GlobalScene.write_save(save)
6669

6770
func _on_Button_pressed(scene):

scripts/score.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const COLORS = [
1515
]
1616

1717
static func get_tier(moves, seconds):
18-
return TIERS[min(moves / seconds, TIERS.size() - 1)]
18+
return TIERS[get_mps_int(moves, seconds)]
19+
20+
static func get_mps_int(moves, seconds):
21+
return min(moves / seconds, TIERS.size() - 1)
1922

2023
static func get_color(moves, seconds):
2124
return COLORS[min(moves / seconds, COLORS.size() - 1)]

0 commit comments

Comments
 (0)