Balancing
This commit is contained in:
parent
90d6c5c926
commit
22d7326565
6 changed files with 116 additions and 105 deletions
|
|
@ -18,10 +18,7 @@ extends Resource
|
|||
@export var cost_linear_increase: int = 100 # Only used if cost_scaling_type is Linear
|
||||
@export var cost_ladder: Array[int] = [] # Fixed costs per rank (overrides scaling if defined)
|
||||
|
||||
@export_subgroup("Effect Scaling")
|
||||
@export_enum("Linear", "Exponential") var effect_scaling_type: int = 1 # Default to Exponential
|
||||
@export var effect_scaling_multiplier: float = 1.2 # Exponential: multiplier per rank
|
||||
@export var effect_linear_increase: float = 0.1 # Linear: flat increase per rank (e.g., 0.1 = +10% per rank)
|
||||
@export var effect_ladder: Array[float] = [] # Effect values per rank
|
||||
|
||||
@export_group("Base Modifiers")
|
||||
@export var base_modifiers: Dictionary = {}
|
||||
|
|
@ -44,44 +41,27 @@ func get_next_cost() -> int:
|
|||
|
||||
## Returns the current modifiers based on rank
|
||||
func get_current_modifiers() -> Dictionary:
|
||||
# If not unlocked yet, return empty modifiers
|
||||
if not is_unlocked or current_rank == 0:
|
||||
return {}
|
||||
|
||||
# Rank 1 should give base modifiers without scaling
|
||||
if current_rank == 1:
|
||||
return base_modifiers.duplicate()
|
||||
|
||||
# Rank 2+ applies scaling
|
||||
return get_modifiers_at_rank(current_rank)
|
||||
|
||||
## Returns modifiers for a specific rank (useful for preview)
|
||||
func get_modifiers_at_rank(rank: int) -> Dictionary:
|
||||
if not is_scaling or rank == 0:
|
||||
if rank == 0:
|
||||
return {}
|
||||
|
||||
# For one-shot unlocks or empty ladder, return base_modifiers
|
||||
if effect_ladder.size() == 0:
|
||||
return base_modifiers.duplicate()
|
||||
|
||||
# Rank 1 returns base modifiers without scaling
|
||||
if rank == 1:
|
||||
return base_modifiers.duplicate()
|
||||
|
||||
var scaled_modifiers = {}
|
||||
|
||||
var ladder_index = rank - 1
|
||||
if ladder_index >= effect_ladder.size():
|
||||
ladder_index = effect_ladder.size() - 1 # Use last value if rank exceeds ladder
|
||||
|
||||
var result = {}
|
||||
for key in base_modifiers.keys():
|
||||
var base_value = base_modifiers[key]
|
||||
|
||||
if effect_scaling_type == 0: # Linear scaling
|
||||
# Linear: add flat increase per rank above 1
|
||||
# e.g., base 1.5 (+50%), linear 0.1 (+10%), rank 2 = 1.6 (+60%), rank 3 = 1.7 (+70%)
|
||||
var additional_ranks = rank - 1
|
||||
scaled_modifiers[key] = base_value + (effect_linear_increase * additional_ranks)
|
||||
else: # Exponential scaling
|
||||
# Exponential: scale the bonus part from rank 1
|
||||
# The bonus at rank 1 is (base_value - 1.0)
|
||||
# At higher ranks, multiply this bonus by multiplier^(rank-1)
|
||||
var base_bonus = base_value - 1.0
|
||||
var scaled_bonus = base_bonus * pow(effect_scaling_multiplier, rank - 1)
|
||||
scaled_modifiers[key] = 1.0 + scaled_bonus
|
||||
|
||||
return scaled_modifiers
|
||||
result[key] = effect_ladder[ladder_index]
|
||||
return result
|
||||
|
||||
## Convert a modifier value to a percentage string
|
||||
func _modifier_to_percentage(value: float) -> String:
|
||||
|
|
@ -132,17 +112,17 @@ func get_modifiers_comparison_string() -> String:
|
|||
var current = get_current_modifiers()
|
||||
var next_rank = get_next_rank()
|
||||
var next = get_modifiers_at_rank(next_rank)
|
||||
|
||||
|
||||
var lines = []
|
||||
|
||||
# If no current modifiers (not unlocked yet), show next only
|
||||
if current.is_empty():
|
||||
var lines = []
|
||||
for key in next.keys():
|
||||
var display_name = key.replace("_", " ").capitalize()
|
||||
var next_pct = _modifier_to_percentage(next[key])
|
||||
lines.append("%s: %s" % [display_name, next_pct])
|
||||
return "\n".join(lines)
|
||||
|
||||
var lines = []
|
||||
for key in current.keys():
|
||||
var display_name = key.replace("_", " ").capitalize()
|
||||
var current_pct = _modifier_to_percentage(current[key])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue