31 lines
798 B
GDScript
31 lines
798 B
GDScript
class_name RunSettings
|
|
extends RefCounted
|
|
|
|
const DIFFICULTY_IDS: Array[StringName] = [&"touriste", &"crawler", &"veteran", &"masochiste"]
|
|
|
|
var seed: String
|
|
var difficulty_id: StringName
|
|
var permadeath: bool
|
|
var pet_enabled: bool
|
|
|
|
func _init(
|
|
new_seed: String = "",
|
|
new_difficulty_id: StringName = &"crawler",
|
|
new_permadeath: bool = false,
|
|
new_pet_enabled: bool = false
|
|
) -> void:
|
|
seed = new_seed.strip_edges()
|
|
difficulty_id = new_difficulty_id
|
|
permadeath = new_permadeath
|
|
pet_enabled = new_pet_enabled
|
|
|
|
func is_valid() -> bool:
|
|
return not seed.is_empty() and difficulty_id in DIFFICULTY_IDS
|
|
|
|
func validation_error() -> String:
|
|
if seed.is_empty():
|
|
return "A run seed is required."
|
|
if not difficulty_id in DIFFICULTY_IDS:
|
|
return "Unknown difficulty id: %s." % difficulty_id
|
|
return ""
|