diff --git a/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd b/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd
index f8c816f..89e3a69 100644
--- a/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd
+++ b/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd
@@ -116,42 +116,72 @@ func _build_fields(r: Dictionary) -> void:
var cur_is_hex : bool = get_s.call("boardShape", "Default") == "Hexagon"
add_option.call("Grid Type", "_gridType", ["Square", "Hexagon"],
"Hexagon" if cur_is_hex else "Square")
- add_int.call("Board Width", "boardWidth", 3, 12, 6, "")
- add_int.call("Board Height", "boardHeight", 3, 12, 6, "")
- 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")
- add_int.call("Hex Sides", "hexSides", 3, 10, 5, "Hexagon only: tiles per side (3–10)")
+ var gt_opt := _controls["_gridType"] as OptionButton
- # Board template picker — populate from BoardTemplateCache (GUID values, not labels).
- var tmpl_key := "boardTemplateIdOverride"
- var cur_tmpl_id : Variant = get_s.call(tmpl_key, "")
- var custom_tmpls : Array = BoardTemplateCache.get_templates_for_custom()
+ # Square-only rows
+ add_int.call("Board Width", "boardWidth", 3, 12, 6, "")
+ var sq_width_row := fields_box.get_child(fields_box.get_child_count() - 1)
+ add_int.call("Board Height", "boardHeight", 3, 12, 6, "")
+ var sq_height_row := fields_box.get_child(fields_box.get_child_count() - 1)
+ 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")
+ var sq_shape_row := fields_box.get_child(fields_box.get_child_count() - 1)
+
+ # Hex-only rows
+ add_int.call("Hex Sides", "hexSides", 3, 10, 5, "Hexagon only: tiles per side (3–10)")
+ var hex_sides_row := fields_box.get_child(fields_box.get_child_count() - 1)
+
+ # Board template picker — filtered by current grid type.
+ var tmpl_key := "boardTemplateIdOverride"
+ var cur_tmpl_id : Variant = get_s.call(tmpl_key, "")
+ var all_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.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
+ _option_ids[tmpl_key] = []
+
+ # Rebuilds template picker items to match the given grid type.
+ var _fill_tmpl := func(is_hex: bool) -> void:
+ var opt := _controls.get(tmpl_key) as OptionButton
+ if not is_instance_valid(opt):
+ return
+ var ids : Array[String] = []
+ opt.clear()
+ opt.add_item("— None —")
+ ids.append("")
+ var sel := 0
+ for t: Dictionary in all_custom_tmpls:
+ var t_is_hex := str(t.get("gridType", "Square")) == "Hexagon"
+ if t_is_hex != is_hex:
+ continue
+ var tid := str(t.get("id", ""))
+ var tname := str(t.get("name", tid.substr(0, min(8, tid.length()))))
+ var tw := int(t.get("width", 0))
+ var th := int(t.get("height", 0))
+ opt.add_item("%s (%d×%d)" % [tname, tw, th])
+ ids.append(tid)
+ if tid == cur_tmpl_id:
+ sel = ids.size() - 1
+ opt.selected = sel
+ _option_ids[tmpl_key] = ids
+
+ # Toggles visibility of grid-type-specific rows and refreshes the template picker.
+ var _update_board_vis := func(is_hex: bool) -> void:
+ sq_width_row.visible = not is_hex
+ sq_height_row.visible = not is_hex
+ sq_shape_row.visible = not is_hex
+ hex_sides_row.visible = is_hex
+ _fill_tmpl.call(is_hex)
+
+ _update_board_vis.call(cur_is_hex)
+ gt_opt.item_selected.connect(func(idx: int): _update_board_vis.call(idx == 1))
# ── Deck ───────────────────────────────────────────────────────────────────
_section("DECK")
diff --git a/Server/src/SOR.Admin/Components/Pages/Game/BoardTemplateBuilderPage.razor b/Server/src/SOR.Admin/Components/Pages/Game/BoardTemplateBuilderPage.razor
index 2896feb..d68a610 100644
--- a/Server/src/SOR.Admin/Components/Pages/Game/BoardTemplateBuilderPage.razor
+++ b/Server/src/SOR.Admin/Components/Pages/Game/BoardTemplateBuilderPage.razor
@@ -89,24 +89,45 @@ else
-
+
-
-
-
-
-
-
-
-
-
- Tiles inside the new bounds are preserved.
+
+
+
+ @if (_template.GridType == "Hexagon")
+ {
+
+
+
+
Diameter = 2N−1. Tiles: 3N²−3N+1.
+
+
+ }
+ else
+ {
+
+
+
+
+
+
+
+
+
+
Tiles inside the new bounds are preserved.
+ }
@@ -237,29 +258,72 @@ else
-
_mouseDown = false"
- @onmouseleave="() => _mouseDown = false">
- @for (int row = 0; row < _template.Height; row++)
- {
- @for (int col = 0; col < _template.Width; col++)
+ @if (_template.GridType == "Hexagon")
+ {
+ const double HexR = 16.0;
+ const double HexPad = 12.0;
+ int hexN = _template.HexSides > 0 ? _template.HexSides : Math.Max(3, _pendingHexSides);
+ int hexDim = 2 * hexN - 1;
+ double svgW = HexR * Math.Sqrt(3) * (hexDim - 1) + 2 * HexR + 2 * HexPad;
+ double svgH = HexR * 1.5 * (hexDim - 1) + 2 * HexR + 2 * HexPad;
+
+
+ }
+ else
+ {
+
_mouseDown = false"
+ @onmouseleave="() => _mouseDown = false">
+ @for (int row = 0; row < _template.Height; row++)
+ {
+ @for (int col = 0; col < _template.Width; col++)
+ {
+ var r = row; var c = col;
+
OnCellMouseDown(c, r))"
+ @onmouseenter="@(() => OnCellMouseEnter(c, r))"
+ @ondblclick="@(() => OpenTileModal(c, r))">
+
+ }
+ }
+
+ }
@@ -329,8 +393,9 @@ else
// ── Template + in-memory state ────────────────────────────────────────────
private BoardTemplate _template = new();
- private int _pendingWidth = 8;
- private int _pendingHeight = 8;
+ private int _pendingWidth = 8;
+ private int _pendingHeight = 8;
+ private int _pendingHexSides = 5;
// Only non-default tiles stored; key = "x,y"
private Dictionary _tiles = new();
@@ -374,9 +439,10 @@ else
if (_isNew)
{
- _template = new BoardTemplate { CreatedAt = DateTimeOffset.UtcNow, UpdatedAt = DateTimeOffset.UtcNow };
- _pendingWidth = _template.Width;
- _pendingHeight = _template.Height;
+ _template = new BoardTemplate { CreatedAt = DateTimeOffset.UtcNow, UpdatedAt = DateTimeOffset.UtcNow };
+ _pendingWidth = _template.Width;
+ _pendingHeight = _template.Height;
+ _pendingHexSides = 5;
}
else
{
@@ -387,9 +453,10 @@ else
_loading = false;
return;
}
- _template = t;
- _pendingWidth = t.Width;
- _pendingHeight = t.Height;
+ _template = t;
+ _pendingWidth = t.Width;
+ _pendingHeight = t.Height;
+ _pendingHexSides = t.HexSides > 0 ? t.HexSides : 5;
DeserializeTiles(t.TilesJson);
DeserializeZones(t.StartingZonesJson);
}
@@ -458,6 +525,85 @@ else
});
}
+ private void ApplyHexSides()
+ {
+ var n = Math.Clamp(_pendingHexSides, 3, 10);
+ _pendingHexSides = n;
+ _template.HexSides = n;
+ int dim = 2 * n - 1;
+ _template.Width = dim;
+ _template.Height = dim;
+
+ var toRemoveTiles = _tiles.Keys
+ .Where(k => { var p = k.Split(','); return !IsHexInBounds(int.Parse(p[0]), int.Parse(p[1]), n); })
+ .ToList();
+ foreach (var k in toRemoveTiles) _tiles.Remove(k);
+
+ foreach (var seatMap in _zones.Values)
+ foreach (var tileSet in seatMap.Values)
+ tileSet.RemoveWhere(k =>
+ {
+ var p = k.Split(',');
+ return !IsHexInBounds(int.Parse(p[0]), int.Parse(p[1]), n);
+ });
+ }
+
+ private void OnGridTypeChanged()
+ {
+ _tiles.Clear();
+ _zones.Clear();
+ if (_template.GridType == "Hexagon")
+ {
+ _template.HexSides = _pendingHexSides;
+ int dim = 2 * _pendingHexSides - 1;
+ _template.Width = dim;
+ _template.Height = dim;
+ }
+ else
+ {
+ _template.HexSides = 0;
+ _template.Width = _pendingWidth;
+ _template.Height = _pendingHeight;
+ }
+ }
+
+ // ── Hex geometry helpers ──────────────────────────────────────────────────
+
+ private static bool IsHexInBounds(int x, int y, int N)
+ {
+ int q = x - (N - 1);
+ int r = y - (N - 1);
+ int s = -q - r;
+ return Math.Max(Math.Abs(q), Math.Max(Math.Abs(r), Math.Abs(s))) <= N - 1;
+ }
+
+ private static double HexCellX(int x, int y, int N, double R, double pad)
+ {
+ int q = x - (N - 1);
+ int r = y - (N - 1);
+ double offsetX = pad + R * Math.Sqrt(3) * (N - 1);
+ return offsetX + R * Math.Sqrt(3) * q + R * Math.Sqrt(3) / 2.0 * r;
+ }
+
+ private static double HexCellY(int y, int N, double R, double pad)
+ {
+ int r = y - (N - 1);
+ return pad + R * 1.5 * (N - 1) + R * 1.5 * r;
+ }
+
+ private static string HexPolygonPoints(double cx, double cy, double R)
+ {
+ var sb = new System.Text.StringBuilder();
+ for (int i = 0; i < 6; i++)
+ {
+ double angle = Math.PI / 180.0 * (60.0 * i - 30.0); // pointy-top
+ if (i > 0) sb.Append(' ');
+ sb.Append(FormattableString.Invariant(
+ $"{cx + R * Math.Cos(angle):F1},{cy + R * Math.Sin(angle):F1}"));
+ }
+ return sb.ToString();
+ }
+
// ── Cell interactions ─────────────────────────────────────────────────────
private void OnCellMouseDown(int x, int y)
diff --git a/Server/src/SOR.Content/ContentMessages.cs b/Server/src/SOR.Content/ContentMessages.cs
index 83358a2..5827386 100644
--- a/Server/src/SOR.Content/ContentMessages.cs
+++ b/Server/src/SOR.Content/ContentMessages.cs
@@ -208,7 +208,9 @@ public sealed record BoardTemplateDto(
bool IsAvailableForRanked,
bool IsAvailableForCustom,
string TilesJson,
- string StartingZonesJson);
+ string StartingZonesJson,
+ string GridType = "Square",
+ int HexSides = 0);
// ── BGM config ───────────────────────────────────────────────────────────────
diff --git a/Server/src/SOR.Content/Handlers/ContentBoardTemplatesHandler.cs b/Server/src/SOR.Content/Handlers/ContentBoardTemplatesHandler.cs
index bd97778..9e2f773 100644
--- a/Server/src/SOR.Content/Handlers/ContentBoardTemplatesHandler.cs
+++ b/Server/src/SOR.Content/Handlers/ContentBoardTemplatesHandler.cs
@@ -40,7 +40,9 @@ internal sealed class ContentBoardTemplatesHandler : IMessageHandler
t.IsAvailableForRanked,
t.IsAvailableForCustom,
t.TilesJson,
- t.StartingZonesJson))
+ t.StartingZonesJson,
+ t.GridType,
+ t.HexSides))
.ToListAsync(ct);
return ServerMessage.Reply(