diff --git a/client/scripts/content/content_db.gd b/client/scripts/content/content_db.gd index 5c262ba..afa2e07 100644 --- a/client/scripts/content/content_db.gd +++ b/client/scripts/content/content_db.gd @@ -8,6 +8,8 @@ var locations: Dictionary = {} var npcs: Dictionary = {} var quests: Dictionary = {} var items: Dictionary = {} +var canon_entities: Dictionary = {} +var topics: Dictionary = {} static func default_content_root() -> String: @@ -29,6 +31,8 @@ func load_from(content_root: String) -> void: npcs = _load_dir(world.path_join("npcs")) quests = _load_dir(world.path_join("quests")) items = _load_dir(world.path_join("items")) + canon_entities = _load_dir(world.path_join("canon")) + topics = _load_dir(world.path_join("topics")) func _load_dir(dir_path: String) -> Dictionary: @@ -56,6 +60,10 @@ func has_location(id: String) -> bool: return locations.has(id) func has_npc(id: String) -> bool: return npcs.has(id) func has_quest(id: String) -> bool: return quests.has(id) func has_item(id: String) -> bool: return items.has(id) +func canon(id: String) -> Dictionary: return canon_entities.get(id, {}) +func topic(id: String) -> Dictionary: return topics.get(id, {}) +func has_canon(id: String) -> bool: return canon_entities.has(id) +func has_topic(id: String) -> bool: return topics.has(id) func companions() -> Array: diff --git a/client/tests/unit/test_content_db.gd b/client/tests/unit/test_content_db.gd index f237fb3..19eed5a 100644 --- a/client/tests/unit/test_content_db.gd +++ b/client/tests/unit/test_content_db.gd @@ -50,3 +50,19 @@ func test_null_quest_ref_resolves(): var o := _deserter() o["start_quest_id"] = null assert_eq(db.unresolved_refs(o), []) + + +func test_loads_canon_and_topics(): + assert_true(db.has_canon("town.duncarrow")) + assert_true(db.has_canon("place.the-white-antlers")) + assert_true(db.has_topic("rumor.travelers-go-missing")) + + +func test_topic_skeleton_has_no_body(): + var t: Dictionary = db.topic("secret.crell-runs-slave-trade") + assert_false(t.has("body")) # bodies are server-only + + +func test_legacy_npcs_still_load(): + assert_true(db.has_npc("fenn")) + assert_true(db.has_npc("npc.mera-fenn"))