feat(client): CanonLog container + maintenance mutators (cap 5, dedup, stack)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
client/tests/unit/test_canon_log.gd
Normal file
48
client/tests/unit/test_canon_log.gd
Normal file
@@ -0,0 +1,48 @@
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
const CanonLog = preload("res://scripts/canon_log/canon_log.gd")
|
||||
const PartyMember = preload("res://scripts/canon_log/party_member.gd")
|
||||
const Quest = preload("res://scripts/canon_log/quest.gd")
|
||||
|
||||
|
||||
func test_push_event_caps_at_five():
|
||||
var log = CanonLog.new()
|
||||
for i in 7:
|
||||
log.push_event("event %d" % i)
|
||||
assert_eq(log.recent_events.size(), 5)
|
||||
assert_eq(log.recent_events[0], "event 2")
|
||||
assert_eq(log.recent_events[4], "event 6")
|
||||
|
||||
|
||||
func test_add_fact_dedups():
|
||||
var log = CanonLog.new()
|
||||
log.add_fact("the bridge is out")
|
||||
log.add_fact("the bridge is out")
|
||||
assert_eq(log.established_facts.size(), 1)
|
||||
|
||||
|
||||
func test_humiliations_stack():
|
||||
var log = CanonLog.new()
|
||||
log.add_humiliation("h_1", "vomited on a shrine", 7, 3)
|
||||
log.add_humiliation("h_2", "vomited on a shrine", 7, 5)
|
||||
assert_eq(log.humiliations.size(), 2)
|
||||
|
||||
|
||||
func test_adjust_disposition_clamps_and_reports_missing():
|
||||
var log = CanonLog.new()
|
||||
log.party.append(PartyMember.new("brannoc_thane", "Brannoc Thane", 98))
|
||||
assert_true(log.adjust_disposition("brannoc_thane", 50))
|
||||
assert_eq(log.party_member("brannoc_thane").disposition, 100)
|
||||
assert_false(log.adjust_disposition("nobody", 5))
|
||||
|
||||
|
||||
func test_set_quest_status_rejects_bad_enum():
|
||||
var log = CanonLog.new()
|
||||
log.active_quests.append(Quest.new("find_the_ledger", "The Missing Ledger", "active", "Find it"))
|
||||
assert_false(log.set_quest_status("find_the_ledger", "abandoned"))
|
||||
assert_true(log.set_quest_status("find_the_ledger", "complete"))
|
||||
assert_false(log.set_quest_status("no_quest", "active"))
|
||||
|
||||
|
||||
func test_unsupported_schema_version_returns_null():
|
||||
assert_null(CanonLog.from_dict({"schema_version": 2}))
|
||||
Reference in New Issue
Block a user