feat(client): id helper + leaf canon-log entities with owned invariants
Also configure GUT to not treat push_error() as a test failure (client/.gutconfig.json: failure_error_types = [engine, gut]). The brief's LogPlayer/Quest setters intentionally push_error() on rejected input; GUT's default failure_error_types includes push_error, which would fail test_player_rejects_unknown_class and test_quest_status_enum despite their assertions passing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
33
client/scripts/canon_log/quest.gd
Normal file
33
client/scripts/canon_log/quest.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
class_name Quest
|
||||
extends RefCounted
|
||||
## An active-quest row. Owns the status enum {active, complete, failed}.
|
||||
|
||||
const STATUSES := ["active", "complete", "failed"]
|
||||
|
||||
var id: String
|
||||
var name: String
|
||||
var status: String
|
||||
var objective: String
|
||||
|
||||
|
||||
func _init(p_id := "", p_name := "", p_status := "active", p_objective := "") -> void:
|
||||
id = p_id
|
||||
name = p_name
|
||||
objective = p_objective
|
||||
set_status(p_status)
|
||||
|
||||
|
||||
func set_status(v: String) -> bool:
|
||||
if v not in STATUSES:
|
||||
push_error("invalid quest status: %s" % v)
|
||||
return false
|
||||
status = v
|
||||
return true
|
||||
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {"id": id, "name": name, "status": status, "objective": objective}
|
||||
|
||||
|
||||
static func from_dict(d: Dictionary) -> Quest:
|
||||
return Quest.new(d.get("id", ""), d.get("name", ""), d.get("status", "active"), d.get("objective", ""))
|
||||
Reference in New Issue
Block a user