Implement phase-3 board template client integration

Server:
- Add GetBoardTemplatesRequest/Response + BoardTemplateDto to ContentMessages.cs
- ContentBoardTemplatesHandler: content.board_templates → returns all enabled
  templates (id, name, dimensions, player range, flags, tilesJson, startingZonesJson)
- Register AddGameDatabase + ContentBoardTemplatesHandler in SOR.Content

Client:
- BoardTemplateCache.gd autoload: fetches content.board_templates on demand,
  exposes get_templates_for_custom(), get_templates_for_ranked(), get_template_by_id()
- rules_editor_dialog.gd: add Board Template OptionButton in the BOARD section;
  uses _option_ids map so confirmed() emits the template GUID (not label text)
- project.godot: register BoardTemplateCache autoload

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-27 21:12:49 -04:00
co-authored by Claude Happy
parent 1368083405
commit 5b836a8e7f
6 changed files with 191 additions and 2 deletions
@@ -16,7 +16,10 @@ signal cancelled
@onready var cancel_btn : Button = %CancelBtn
@onready var confirm_btn : Button = %ConfirmBtn
var _controls : Dictionary = {}
var _controls : Dictionary = {}
## For OptionButtons that carry GUID values rather than display text:
## key → Array[String] of IDs, parallel to the button's item list.
var _option_ids : Dictionary = {}
func _ready() -> void:
@@ -33,6 +36,7 @@ func setup(current_rules: Dictionary, is_host: bool) -> void:
func _build_fields(r: Dictionary) -> void:
_controls.clear()
_option_ids.clear()
for child in fields_box.get_children():
child.queue_free()
@@ -114,6 +118,37 @@ func _build_fields(r: Dictionary) -> void:
add_int.call("Starting Tile Affinity %","startingRandomTilePct",0, 100, 0, "% of tiles with a random basic affinity")
add_option.call("Board Shape", "boardShape", ["Default", "Rectangle", "Cross", "Triangular", "RadialStar", "HexRing"], "Default")
# Board template picker — populate from BoardTemplateCache (GUID values, not labels).
var tmpl_key := "boardTemplateIdOverride"
var cur_tmpl_id := get_s.call(tmpl_key, "")
var custom_tmpls : Array = BoardTemplateCache.get_templates_for_custom()
var tmpl_hbox := HBoxContainer.new()
var tmpl_lbl := Label.new()
tmpl_lbl.text = "Board Template"
tmpl_lbl.tooltip_text = "Overrides the board layout with an admin-defined template. Ignores Board Shape when set."
tmpl_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
tmpl_hbox.add_child(tmpl_lbl)
var tmpl_opt := OptionButton.new()
var tmpl_ids : Array[String] = []
tmpl_opt.add_item("— None —")
tmpl_ids.append("")
var tmpl_sel := 0
for i: int in range(custom_tmpls.size()):
var t := custom_tmpls[i] as Dictionary
var tid := str(t.get("id", ""))
var tname := str(t.get("name", tid.substr(0, 8)))
var tw := int(t.get("width", 0))
var th := int(t.get("height", 0))
tmpl_opt.add_item("%s (%d×%d)" % [tname, tw, th])
tmpl_ids.append(tid)
if tid == cur_tmpl_id:
tmpl_sel = i + 1
tmpl_opt.selected = tmpl_sel
tmpl_hbox.add_child(tmpl_opt)
fields_box.add_child(tmpl_hbox)
_controls[tmpl_key] = tmpl_opt
_option_ids[tmpl_key] = tmpl_ids
# ── Deck ───────────────────────────────────────────────────────────────────
_section("DECK")
add_int.call("Min Deck Size", "minDeckSize", 0, 60, 0, "0 = no limit")
@@ -144,6 +179,12 @@ func _on_confirm() -> void:
elif ctrl is CheckBox:
overrides[key] = ctrl.button_pressed
elif ctrl is OptionButton:
overrides[key] = ctrl.get_item_text(ctrl.selected)
if _option_ids.has(key):
# Emit the underlying GUID, not the display label.
var ids : Array = _option_ids[key]
var idx : int = ctrl.selected
overrides[key] = ids[idx] if idx < ids.size() else ""
else:
overrides[key] = ctrl.get_item_text(ctrl.selected)
confirmed.emit(overrides)
queue_free()