From 3b71fcdcc0b79934d2f43d4a3889389e74a8e7c7 Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Fri, 10 Jul 2026 12:36:37 -0500 Subject: [PATCH] feat(client): CanonLog.add_quest/has_quest for offer_quest --- client/scripts/canon_log/canon_log.gd | 14 ++++++++++++++ client/tests/unit/test_canon_log.gd | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client/scripts/canon_log/canon_log.gd b/client/scripts/canon_log/canon_log.gd index 7fe7c9d..01ca212 100644 --- a/client/scripts/canon_log/canon_log.gd +++ b/client/scripts/canon_log/canon_log.gd @@ -58,6 +58,20 @@ func adjust_disposition(id: String, delta: int) -> bool: return true +func has_quest(id: String) -> bool: + for q in active_quests: + if q.id == id: + return true + return false + + +func add_quest(id: String, name: String, objective: String) -> bool: + if has_quest(id): + return false + active_quests.append(Quest.new(id, name, "active", objective)) + return true + + func set_quest_status(id: String, status: String) -> bool: for q in active_quests: if q.id == id: diff --git a/client/tests/unit/test_canon_log.gd b/client/tests/unit/test_canon_log.gd index aa7235c..bd0c414 100644 --- a/client/tests/unit/test_canon_log.gd +++ b/client/tests/unit/test_canon_log.gd @@ -46,3 +46,15 @@ func test_set_quest_status_rejects_bad_enum(): func test_unsupported_schema_version_returns_null(): assert_null(CanonLog.from_dict({"schema_version": 2})) + + +func test_add_quest_appends_active_and_is_idempotent(): + var log = CanonLog.new() + assert_false(log.has_quest("find_the_ledger")) + assert_true(log.add_quest("find_the_ledger", "The Missing Ledger", "Find who took it")) + assert_true(log.has_quest("find_the_ledger")) + assert_eq(log.active_quests.size(), 1) + assert_eq(log.active_quests[0].status, "active") + # second add is a no-op + assert_false(log.add_quest("find_the_ledger", "x", "y")) + assert_eq(log.active_quests.size(), 1)