Fix combo decay: reset stale settings via version; cap combo at 5 by default
This commit is contained in:
+17
-4
@@ -4,14 +4,17 @@ extends Node
|
||||
## al riavvio della scena.
|
||||
|
||||
const PATH := "user://settings.cfg"
|
||||
const VERSION := 2 # incrementa quando cambiano i default, per resettare i file vecchi
|
||||
var version := VERSION
|
||||
|
||||
var start_time := 4.5 # tempo iniziale (s) tra un ordine e l'altro
|
||||
var min_time := 0.8 # tempo minimo (velocità massima)
|
||||
var time_ramp := 180.0 # secondi di gioco per difficoltà piena
|
||||
var score_ramp := 2000.0 # punteggio per difficoltà piena
|
||||
var points_per_combo := 10 # punti base per ogni livello di combo
|
||||
var combo_decay_threshold := 5.0 # combo sopra cui inizia il decay
|
||||
var combo_decay_rate := 0.06 # combo persi per unità sopra la soglia
|
||||
var max_combo := 5.0 # combo massimo di default (configurabile)
|
||||
var combo_decay_threshold := 0.0 # combo sopra cui inizia il decay (0 = da subito)
|
||||
var combo_decay_rate := 0.15 # combo persi al secondo per unità sopra la soglia
|
||||
var difficulty_decay_rate := 0.3 # decay aggiuntivo legato alla difficoltà
|
||||
# Curva del punteggio: 0=quadratica, 1=scaglioni, 2=radice, 3=additiva
|
||||
var score_curve := 0
|
||||
@@ -25,11 +28,18 @@ func load_settings() -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
if cfg.load(PATH) != OK:
|
||||
return # usa i default
|
||||
version = cfg.get_value("meta", "version", 0)
|
||||
if version < VERSION:
|
||||
# file di impostazioni vecchio: applica i nuovi default e risalva
|
||||
reset_defaults()
|
||||
save_settings()
|
||||
return
|
||||
start_time = cfg.get_value("gameplay", "start_time", start_time)
|
||||
min_time = cfg.get_value("gameplay", "min_time", min_time)
|
||||
time_ramp = cfg.get_value("gameplay", "time_ramp", time_ramp)
|
||||
score_ramp = cfg.get_value("gameplay", "score_ramp", score_ramp)
|
||||
points_per_combo = cfg.get_value("gameplay", "points_per_combo", points_per_combo)
|
||||
max_combo = cfg.get_value("gameplay", "max_combo", max_combo)
|
||||
combo_decay_threshold = cfg.get_value("gameplay", "combo_decay_threshold", combo_decay_threshold)
|
||||
combo_decay_rate = cfg.get_value("gameplay", "combo_decay_rate", combo_decay_rate)
|
||||
difficulty_decay_rate = cfg.get_value("gameplay", "difficulty_decay_rate", difficulty_decay_rate)
|
||||
@@ -38,11 +48,13 @@ func load_settings() -> void:
|
||||
|
||||
func save_settings() -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
cfg.set_value("meta", "version", VERSION)
|
||||
cfg.set_value("gameplay", "start_time", start_time)
|
||||
cfg.set_value("gameplay", "min_time", min_time)
|
||||
cfg.set_value("gameplay", "time_ramp", time_ramp)
|
||||
cfg.set_value("gameplay", "score_ramp", score_ramp)
|
||||
cfg.set_value("gameplay", "points_per_combo", points_per_combo)
|
||||
cfg.set_value("gameplay", "max_combo", max_combo)
|
||||
cfg.set_value("gameplay", "combo_decay_threshold", combo_decay_threshold)
|
||||
cfg.set_value("gameplay", "combo_decay_rate", combo_decay_rate)
|
||||
cfg.set_value("gameplay", "difficulty_decay_rate", difficulty_decay_rate)
|
||||
@@ -56,7 +68,8 @@ func reset_defaults() -> void:
|
||||
time_ramp = 180.0
|
||||
score_ramp = 2000.0
|
||||
points_per_combo = 10
|
||||
combo_decay_threshold = 5.0
|
||||
combo_decay_rate = 0.06
|
||||
max_combo = 5.0
|
||||
combo_decay_threshold = 0.0
|
||||
combo_decay_rate = 0.15
|
||||
difficulty_decay_rate = 0.3
|
||||
score_curve = 0
|
||||
|
||||
Reference in New Issue
Block a user