Files
idle/core/prestige/prestige_config.gd

80 lines
1.9 KiB
GDScript

class_name PrestigeConfig
extends Resource
enum BasisType {
LIFETIME_TOTAL,
RUN_TOTAL,
RUN_MAX,
ALL_CURRENCIES,
}
enum FormulaType {
POWER,
TRIANGULAR_INVERSE,
}
enum RoundingMode {
FLOOR,
ROUND,
CEIL,
}
enum MultiplierMode {
ADDITIVE,
MULTIPLICATIVE_POWER,
}
@export var id: StringName = &"primary"
@export var display_name: String = "Ascension"
@export var prestige_currency_id: StringName = &"prestige"
@export var source_currency_id: StringName = &"magic"
@export var basis: BasisType = BasisType.LIFETIME_TOTAL
@export var formula: FormulaType = FormulaType.POWER
@export var threshold_mantissa: float = 1.0
@export var threshold_exponent: int = 4
@export var scale: float = 1.0
@export var exponent: float = 0.5
@export var flat_bonus: float = 0.0
@export var minimum_gain: int = 0
@export var rounding_mode: RoundingMode = RoundingMode.FLOOR
@export var allow_prestige_without_gain: bool = false
@export var multiplier_mode: MultiplierMode = MultiplierMode.ADDITIVE
@export var base_multiplier: float = 1.0
@export var multiplier_per_prestige: float = 0.05
@export var multiplier_exponent: float = 1.0
@export var include_currency_ids: Array[StringName] = []
func get_threshold() -> BigNumber:
return BigNumber.new(threshold_mantissa, threshold_exponent)
func is_valid() -> bool:
if String(id).strip_edges().is_empty():
return false
if String(source_currency_id).strip_edges().is_empty() and basis != BasisType.ALL_CURRENCIES:
return false
if threshold_mantissa <= 0.0:
return false
if scale < 0.0:
return false
if formula == FormulaType.POWER and exponent <= 0.0:
return false
if base_multiplier < 0.0:
return false
return true
func is_cumulative_basis() -> bool:
return basis != BasisType.RUN_TOTAL
func round_value(value: float) -> float:
if not is_finite(value):
return value
match rounding_mode:
RoundingMode.CEIL:
return ceilf(value)
RoundingMode.ROUND:
return roundf(value)
_:
return floorf(value)