feat: add run creation lifecycle
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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 ""
|
||||
@@ -0,0 +1 @@
|
||||
uid://dq4n1mtxs0ovv
|
||||
@@ -2,12 +2,16 @@ class_name RunState
|
||||
extends RefCounted
|
||||
|
||||
var seed: String
|
||||
var settings: RunSettings
|
||||
var player_name := "Sans-Nom"
|
||||
var base_archetype: StringName = &"vanguard"
|
||||
var current_floor := 0
|
||||
var current_turn := 0
|
||||
var log: Array[GameEvent] = []
|
||||
|
||||
func _init(new_seed: String) -> void:
|
||||
seed = new_seed
|
||||
func _init(new_seed: String, new_settings: RunSettings = null) -> void:
|
||||
settings = new_settings if new_settings != null else RunSettings.new(new_seed)
|
||||
seed = settings.seed
|
||||
|
||||
func next_turn() -> int:
|
||||
current_turn += 1
|
||||
|
||||
Reference in New Issue
Block a user