JSON import keeps a group's colour

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-11-14 13:26:50 -06:00
parent dba3f6514e
commit 0ed2ba553b
2 changed files with 5 additions and 1 deletions

View file

@ -65,7 +65,7 @@ static func _canon_group(gd: Dictionary) -> Dictionary:
if str(m) != "" and not members.has(str(m)):
members.append(str(m))
g["members"] = members
_keep(gd, g, ["parent"])
_keep(gd, g, ["parent", "color"])
return g

View file

@ -56,6 +56,10 @@ func _test_json() -> void:
var res2 := JsonIO.import_json(JsonIO.export_json(small))
_check(res2["ok"] and res2["collection"] == JsonIO.canonical(small), "small spread round-trips exactly")
_check(not JsonIO.export_json({"tables": [], "state": {"draws": 1}}).contains("state"), "export drops unknown/local keys")
var coloured := _small()
coloured["groups"] = [{"id": "g1", "name": "Gear", "members": ["loot"], "color": "#7a3fa8"}]
var cres := JsonIO.import_json(JsonIO.export_json(coloured))
_check(cres["ok"] and cres["collection"]["groups"][0].get("color", "") == "#7a3fa8", "a group's colour survives export and import")
# Legacy keys: triggers, die, collection name.
var legacy := JsonIO.import_json('{"format_version":1,"collection":"Old","tables":[{"id":"a","name":"A","die":20,"entries":[{"text":"x","triggers":["a"]}]}]}')