Files
DungeonCrawlerWorld/scripts/domain/run/run_settings.gd

37 lines
1.1 KiB
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
var pet_name: String
var pet_species: String
func _init(
new_seed: String = "",
new_difficulty_id: StringName = &"crawler",
new_permadeath: bool = false,
new_pet_enabled: bool = false,
new_pet_name: String = "Familier",
new_pet_species: String = "Animal"
) -> void:
seed = new_seed.strip_edges()
difficulty_id = new_difficulty_id
permadeath = new_permadeath
pet_enabled = new_pet_enabled
pet_name = new_pet_name.strip_edges() if not new_pet_name.strip_edges().is_empty() else "Familier"
pet_species = new_pet_species.strip_edges() if not new_pet_species.strip_edges().is_empty() else "Animal"
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 ""