feat(client): ContentDB loads canon/ + topics/ built dirs
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HuHRPE7VfppUJEaoGBEUqZ
This commit is contained in:
@@ -8,6 +8,8 @@ var locations: Dictionary = {}
|
|||||||
var npcs: Dictionary = {}
|
var npcs: Dictionary = {}
|
||||||
var quests: Dictionary = {}
|
var quests: Dictionary = {}
|
||||||
var items: Dictionary = {}
|
var items: Dictionary = {}
|
||||||
|
var canon_entities: Dictionary = {}
|
||||||
|
var topics: Dictionary = {}
|
||||||
|
|
||||||
|
|
||||||
static func default_content_root() -> String:
|
static func default_content_root() -> String:
|
||||||
@@ -29,6 +31,8 @@ func load_from(content_root: String) -> void:
|
|||||||
npcs = _load_dir(world.path_join("npcs"))
|
npcs = _load_dir(world.path_join("npcs"))
|
||||||
quests = _load_dir(world.path_join("quests"))
|
quests = _load_dir(world.path_join("quests"))
|
||||||
items = _load_dir(world.path_join("items"))
|
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:
|
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_npc(id: String) -> bool: return npcs.has(id)
|
||||||
func has_quest(id: String) -> bool: return quests.has(id)
|
func has_quest(id: String) -> bool: return quests.has(id)
|
||||||
func has_item(id: String) -> bool: return items.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:
|
func companions() -> Array:
|
||||||
|
|||||||
@@ -50,3 +50,19 @@ func test_null_quest_ref_resolves():
|
|||||||
var o := _deserter()
|
var o := _deserter()
|
||||||
o["start_quest_id"] = null
|
o["start_quest_id"] = null
|
||||||
assert_eq(db.unresolved_refs(o), [])
|
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"))
|
||||||
|
|||||||
Reference in New Issue
Block a user