Switch hex polygon board from radius to side length
- Add HexSideLength property to BoardTemplate (tiles per edge) - Add EF migration 20260406000000_AddBoardTemplateHexSideLength - Replace NPolyInside (Euclidean circle test) with HexLine + flood-fill: * N corners placed at circumradius = (L-1)/(2·sin(π/N)) in hex-Cartesian * Corners snapped to nearest integer axial cell via HexRound * Perimeter built by hex-line lerp between adjacent corners * Interior determined by BFS flood-fill from center - Auto-compute bounding hex radius from side length (max(L*2, ceil(circumR)+2)) - UI: expose Side Length input instead of Radius; canvas header shows L=n tiles/edge - Zone tiles now walk along actual hex-line edges from each corner Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d28d02428d
commit
1feda0a59c
@@ -108,10 +108,10 @@ else
|
||||
<div class="form-text">Number of corners / player slots. 3 = triangle, 6 = hexagon, 10 = decagon.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Radius (tiles)</label>
|
||||
<input type="number" class="form-control" min="2" max="15"
|
||||
@bind="_pendingHexRadius" />
|
||||
<div class="form-text">Board radius from center to corner. Diameter = 2R+1.</div>
|
||||
<label class="form-label fw-semibold">Side Length (tiles)</label>
|
||||
<input type="number" class="form-control" min="1" max="12"
|
||||
@bind="_pendingHexSideLength" />
|
||||
<div class="form-text">Number of hex tiles per polygon edge.</div>
|
||||
</div>
|
||||
<button class="btn btn-outline-secondary btn-sm w-100" @onclick="ApplyHexConfig">
|
||||
Apply
|
||||
@@ -266,9 +266,9 @@ else
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
@if (_template.GridType == "Hexagon")
|
||||
{
|
||||
int _hpoly = _template.HexPolygonSides > 0 ? _template.HexPolygonSides : _pendingHexPolySides;
|
||||
int _hradius = _template.HexSides > 1 ? _template.HexSides - 1 : _pendingHexRadius;
|
||||
<span>Canvas <span class="text-muted small">@_hpoly-gon, R=@_hradius (@(2*_hradius+1)×@(2*_hradius+1))</span></span>
|
||||
int _hpoly = _template.HexPolygonSides > 0 ? _template.HexPolygonSides : _pendingHexPolySides;
|
||||
int _hside = _template.HexSideLength > 0 ? _template.HexSideLength : _pendingHexSideLength;
|
||||
<span>Canvas <span class="text-muted small">@_hpoly-gon, L=@_hside tiles/edge</span></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -284,7 +284,7 @@ else
|
||||
const double HexR = 16.0;
|
||||
const double HexPad = 12.0;
|
||||
// hexN = radius + 1 (for HexGrid coordinate math)
|
||||
int hexN = _template.HexSides > 0 ? _template.HexSides : (_pendingHexRadius + 1);
|
||||
int hexN = _template.HexSides > 0 ? _template.HexSides : (_pendingHexSideLength * 2 + 1);
|
||||
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;
|
||||
@@ -406,8 +406,8 @@ else
|
||||
private BoardTemplate _template = new();
|
||||
private int _pendingWidth = 8;
|
||||
private int _pendingHeight = 8;
|
||||
private int _pendingHexPolySides = 6; // polygon corner count (3–10)
|
||||
private int _pendingHexRadius = 5; // board radius in tiles (2–15)
|
||||
private int _pendingHexPolySides = 6; // polygon corner count (3–10)
|
||||
private int _pendingHexSideLength = 5; // tiles per polygon edge (1–12)
|
||||
|
||||
// Only non-default tiles stored; key = "x,y"
|
||||
private Dictionary<string, TileDefinition> _tiles = new();
|
||||
@@ -454,8 +454,8 @@ else
|
||||
_template = new BoardTemplate { CreatedAt = DateTimeOffset.UtcNow, UpdatedAt = DateTimeOffset.UtcNow };
|
||||
_pendingWidth = _template.Width;
|
||||
_pendingHeight = _template.Height;
|
||||
_pendingHexPolySides = 6;
|
||||
_pendingHexRadius = 5;
|
||||
_pendingHexPolySides = 6;
|
||||
_pendingHexSideLength = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -469,8 +469,8 @@ else
|
||||
_template = t;
|
||||
_pendingWidth = t.Width;
|
||||
_pendingHeight = t.Height;
|
||||
_pendingHexPolySides = t.HexPolygonSides > 0 ? t.HexPolygonSides : 6;
|
||||
_pendingHexRadius = t.HexSides > 1 ? t.HexSides - 1 : 5;
|
||||
_pendingHexPolySides = t.HexPolygonSides > 0 ? t.HexPolygonSides : 6;
|
||||
_pendingHexSideLength = t.HexSideLength > 0 ? t.HexSideLength : 5;
|
||||
DeserializeTiles(t.TilesJson);
|
||||
DeserializeZones(t.StartingZonesJson);
|
||||
}
|
||||
@@ -540,81 +540,112 @@ else
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a regular N-gon of hex tiles and N corner starting zones.
|
||||
/// HexSides is stored as radius+1 (for HexGrid coordinate math).
|
||||
/// HexPolygonSides is stored as N (the corner count / polygon shape).
|
||||
/// Generate a regular N-gon of hex tiles using a HexLine perimeter + flood-fill interior.
|
||||
/// HexSideLength = tiles per polygon edge (drives circumradius and bounding pool).
|
||||
/// HexSides = bounding radius + 1 (auto-computed; used for hex coordinate math).
|
||||
/// HexPolygonSides = N (corner count / polygon shape).
|
||||
/// </summary>
|
||||
private void ApplyHexConfig()
|
||||
{
|
||||
int N = Math.Clamp(_pendingHexPolySides, 3, 10);
|
||||
int R = Math.Clamp(_pendingHexRadius, 2, 15);
|
||||
int sides = R + 1; // HexGrid "sides" parameter = radius + 1
|
||||
int dim = 2 * R + 1;
|
||||
int N = Math.Clamp(_pendingHexPolySides, 3, 10);
|
||||
int L = Math.Clamp(_pendingHexSideLength, 1, 12);
|
||||
|
||||
_pendingHexPolySides = N;
|
||||
_pendingHexRadius = R;
|
||||
_template.HexSides = sides;
|
||||
_template.HexPolygonSides = N;
|
||||
_template.Width = dim;
|
||||
_template.Height = dim;
|
||||
// Circumradius (hex-Cartesian units ≡ hex-step units) so each edge ≈ L tiles.
|
||||
// Adjacent corner distance = 2R·sin(π/N) = L−1 hex steps.
|
||||
double circumR = L <= 1 ? 0.0 : (L - 1.0) / (2.0 * Math.Sin(Math.PI / N));
|
||||
|
||||
// Bounding hex-grid radius: must fully contain the polygon with margin.
|
||||
int R = Math.Max(L * 2, (int)Math.Ceiling(circumR) + 2);
|
||||
R = Math.Clamp(R, 2, 30);
|
||||
|
||||
int dim = 2 * R + 1;
|
||||
|
||||
_pendingHexPolySides = N;
|
||||
_pendingHexSideLength = L;
|
||||
_template.HexSides = R + 1;
|
||||
_template.HexPolygonSides = N;
|
||||
_template.HexSideLength = L;
|
||||
_template.Width = dim;
|
||||
_template.Height = dim;
|
||||
|
||||
_tiles.Clear();
|
||||
_zones.Clear();
|
||||
|
||||
// Mark every tile that is inside the hexagonal arrangement but outside the N-gon as absent.
|
||||
// Tiles inside the N-gon are left as default (no entry = void tile = present).
|
||||
// ── Step 1: Compute N corners in axial (q,r) ─────────────────────────
|
||||
var corners = new (int q, int r)[N];
|
||||
for (int k = 0; k < N; k++)
|
||||
{
|
||||
double angle = Math.PI / 2.0 + 2.0 * Math.PI * k / N;
|
||||
// Hex-Cartesian → axial: cy = r·√3/2 → fr = cy·2/√3; cx = q + r·0.5 → fq = cx − fr·0.5
|
||||
double hcx = circumR * Math.Cos(angle);
|
||||
double hcy = circumR * Math.Sin(angle);
|
||||
double fr = hcy * 2.0 / Math.Sqrt(3.0);
|
||||
double fq = hcx - fr * 0.5;
|
||||
corners[k] = HexRound(fq, fr);
|
||||
}
|
||||
|
||||
// ── Step 2: Perimeter via hex-lines between adjacent corners ──────────
|
||||
var perimeter = new HashSet<(int q, int r)>();
|
||||
for (int k = 0; k < N; k++)
|
||||
{
|
||||
var (q0, r0) = corners[k];
|
||||
var (q1, r1) = corners[(k + 1) % N];
|
||||
foreach (var pt in HexLinePath(q0, r0, q1, r1))
|
||||
perimeter.Add(pt);
|
||||
}
|
||||
|
||||
// ── Step 3: Flood-fill interior from center (0,0) ────────────────────
|
||||
var interior = new HashSet<(int q, int r)>(perimeter);
|
||||
if (!interior.Contains((0, 0)))
|
||||
{
|
||||
interior.Add((0, 0));
|
||||
var bfsQueue = new Queue<(int q, int r)>();
|
||||
bfsQueue.Enqueue((0, 0));
|
||||
int[] dq = { 1, 0, -1, -1, 0, 1 };
|
||||
int[] dr = { 0, 1, 1, 0, -1, -1 };
|
||||
while (bfsQueue.Count > 0)
|
||||
{
|
||||
var (q, r) = bfsQueue.Dequeue();
|
||||
for (int d = 0; d < 6; d++)
|
||||
{
|
||||
int nq = q + dq[d], nr = r + dr[d];
|
||||
if (Math.Abs(nq) > R || Math.Abs(nr) > R || Math.Abs(nq + nr) > R) continue;
|
||||
if (!interior.Add((nq, nr))) continue;
|
||||
bfsQueue.Enqueue((nq, nr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Step 4: Mark tiles outside polygon as absent ──────────────────────
|
||||
for (int x = 0; x < dim; x++)
|
||||
for (int y = 0; y < dim; y++)
|
||||
{
|
||||
int q = x - R, r = y - R;
|
||||
if (Math.Max(Math.Abs(q), Math.Max(Math.Abs(r), Math.Abs(q + r))) > R)
|
||||
continue; // outside hex bounding circle — not rendered
|
||||
|
||||
double cx = q + r * 0.5;
|
||||
double cy = r * Math.Sqrt(3.0) / 2.0;
|
||||
if (!NPolyInside(cx, cy, N, R))
|
||||
{
|
||||
var tile = GetOrCreateTile(x, y);
|
||||
tile.IsAbsent = true;
|
||||
}
|
||||
if (Math.Abs(q) > R || Math.Abs(r) > R || Math.Abs(q + r) > R) continue;
|
||||
if (!interior.Contains((q, r)))
|
||||
GetOrCreateTile(x, y).IsAbsent = true;
|
||||
}
|
||||
|
||||
// N vertex positions (scaled hex Cartesian)
|
||||
var verts = new (double vx, double vy)[N];
|
||||
for (int k = 0; k < N; k++)
|
||||
{
|
||||
double angle = Math.PI / 2.0 + 2.0 * Math.PI * k / N;
|
||||
verts[k] = (R * Math.Cos(angle), R * Math.Sin(angle));
|
||||
}
|
||||
|
||||
// For each player count 2..N, pick evenly-spaced corners.
|
||||
int half = Math.Max(1, R / 4);
|
||||
// ── Step 5: Build starting zones (corner + tiles along adjacent edges) ─
|
||||
int half = Math.Max(1, L / 4);
|
||||
for (int playerCount = 2; playerCount <= N; playerCount++)
|
||||
{
|
||||
var seatMap = new Dictionary<int, HashSet<string>>();
|
||||
for (int seat = 0; seat < playerCount; seat++)
|
||||
{
|
||||
int ci = (int)Math.Round((double)seat * N / playerCount) % N;
|
||||
var (vx, vy) = verts[ci];
|
||||
var zone = new HashSet<string>();
|
||||
int ci = (int)Math.Round((double)seat * N / playerCount) % N;
|
||||
var (cq, cr) = corners[ci];
|
||||
// Snap corner to nearest non-absent tile using hex-Cartesian lookup.
|
||||
var cornerTile = FindNearestNgonTile(cq + cr * 0.5, cr * Math.Sqrt(3.0) / 2.0, R);
|
||||
var zone = new HashSet<string> { TileKey(cornerTile.x, cornerTile.y) };
|
||||
|
||||
// Corner tile
|
||||
var corner = FindNearestNgonTile(vx, vy, R);
|
||||
zone.Add(TileKey(corner.x, corner.y));
|
||||
|
||||
// Edge tiles toward adjacent vertices
|
||||
for (int step = 1; step <= half; step++)
|
||||
{
|
||||
double t = (double)step / (half + 1);
|
||||
int nextCi = (ci + 1) % N;
|
||||
int prevCi = (ci - 1 + N) % N;
|
||||
var n1 = FindNearestNgonTile(vx + (verts[nextCi].vx - vx) * t,
|
||||
vy + (verts[nextCi].vy - vy) * t, R);
|
||||
var n2 = FindNearestNgonTile(vx + (verts[prevCi].vx - vx) * t,
|
||||
vy + (verts[prevCi].vy - vy) * t, R);
|
||||
zone.Add(TileKey(n1.x, n1.y));
|
||||
zone.Add(TileKey(n2.x, n2.y));
|
||||
}
|
||||
// Walk along the hex-line edges toward each adjacent corner.
|
||||
var (nq, nr) = corners[(ci + 1) % N];
|
||||
var (pq, pr) = corners[(ci - 1 + N) % N];
|
||||
foreach (var (lq, lr) in HexLinePath(cq, cr, nq, nr).Skip(1).Take(half))
|
||||
zone.Add(TileKey(lq + R, lr + R));
|
||||
foreach (var (lq, lr) in HexLinePath(cq, cr, pq, pr).Skip(1).Take(half))
|
||||
zone.Add(TileKey(lq + R, lr + R));
|
||||
|
||||
seatMap[seat] = zone;
|
||||
}
|
||||
@@ -628,9 +659,13 @@ else
|
||||
_zones.Clear();
|
||||
if (_template.GridType == "Hexagon")
|
||||
{
|
||||
_template.HexSides = _pendingHexRadius + 1;
|
||||
double circumR = _pendingHexSideLength <= 1 ? 0.0
|
||||
: (_pendingHexSideLength - 1.0) / (2.0 * Math.Sin(Math.PI / _pendingHexPolySides));
|
||||
int R = Math.Max(_pendingHexSideLength * 2, (int)Math.Ceiling(circumR) + 2);
|
||||
R = Math.Clamp(R, 2, 30);
|
||||
_template.HexSides = R + 1;
|
||||
_template.HexPolygonSides = _pendingHexPolySides;
|
||||
int dim = 2 * _pendingHexRadius + 1;
|
||||
int dim = 2 * R + 1;
|
||||
_template.Width = dim;
|
||||
_template.Height = dim;
|
||||
}
|
||||
@@ -656,24 +691,28 @@ else
|
||||
return Math.Max(Math.Abs(q), Math.Max(Math.Abs(r), Math.Abs(q + r))) <= R;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True when scaled hex-Cartesian point (cx,cy) is inside a regular N-gon with
|
||||
/// circumradius R. Uses cross-product test on each CCW edge (slightly expanded to
|
||||
/// include boundary tiles).
|
||||
/// </summary>
|
||||
private static bool NPolyInside(double cx, double cy, int N, double R)
|
||||
/// <summary>Round continuous axial (fq,fr) to the nearest integer hex cell (preserves cube constraint).</summary>
|
||||
private static (int q, int r) HexRound(double fq, double fr)
|
||||
{
|
||||
double Rexp = R * 1.02; // slight expansion to include perimeter tiles
|
||||
for (int k = 0; k < N; k++)
|
||||
double fs = -fq - fr;
|
||||
int rq = (int)Math.Round(fq), rr = (int)Math.Round(fr), rs = (int)Math.Round(fs);
|
||||
double dq = Math.Abs(rq - fq), dr = Math.Abs(rr - fr), ds = Math.Abs(rs - fs);
|
||||
if (dq > dr && dq > ds) rq = -rr - rs;
|
||||
else if (dr > ds) rr = -rq - rs;
|
||||
return (rq, rr);
|
||||
}
|
||||
|
||||
/// <summary>Yield all hex cells on the straight line from (q0,r0) to (q1,r1) via cube lerp.</summary>
|
||||
private static IEnumerable<(int q, int r)> HexLinePath(int q0, int r0, int q1, int r1)
|
||||
{
|
||||
int s0 = -q0 - r0, s1 = -q1 - r1;
|
||||
int steps = Math.Max(Math.Abs(q1 - q0), Math.Max(Math.Abs(r1 - r0), Math.Abs(s1 - s0)));
|
||||
for (int i = 0; i <= steps; i++)
|
||||
{
|
||||
double a1 = Math.PI / 2.0 + 2.0 * Math.PI * k / N;
|
||||
double a2 = Math.PI / 2.0 + 2.0 * Math.PI * (k + 1) / N;
|
||||
double v1x = Rexp * Math.Cos(a1), v1y = Rexp * Math.Sin(a1);
|
||||
double v2x = Rexp * Math.Cos(a2), v2y = Rexp * Math.Sin(a2);
|
||||
double cross = (v2x - v1x) * (cy - v1y) - (v2y - v1y) * (cx - v1x);
|
||||
if (cross < -1e-9) return false;
|
||||
double t = steps == 0 ? 0.0 : (double)i / steps;
|
||||
var pt = HexRound(q0 + (q1 - q0) * t, r0 + (r1 - r0) * t);
|
||||
yield return pt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Find the nearest non-absent hex tile (in offset coords) to scaled-Cartesian (vx,vy).</summary>
|
||||
|
||||
@@ -37,6 +37,8 @@ public sealed class BoardTemplate
|
||||
public int HexSides { get; set; } = 0;
|
||||
/// <summary>Number of polygon sides/corners (3–10). 6 = regular hexagon. Only meaningful when GridType = "Hexagon".</summary>
|
||||
public int HexPolygonSides { get; set; } = 6;
|
||||
/// <summary>Number of hex tiles per polygon edge. Drives the board shape. Only meaningful when GridType = "Hexagon".</summary>
|
||||
public int HexSideLength { get; set; } = 5;
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
Generated
+544
@@ -0,0 +1,544 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SOR.Database.Contexts;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Game
|
||||
{
|
||||
[DbContext(typeof(GameDbContext))]
|
||||
[Migration("20260406000000_AddBoardTemplateHexSideLength")]
|
||||
partial class AddBoardTemplateHexSideLength
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("game")
|
||||
.HasAnnotation("ProductVersion", "8.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.BoardTemplate", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("GridType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Height")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HexPolygonSides")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HexSideLength")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HexSides")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsAvailableForCustom")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsAvailableForRanked")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("MaxPlayers")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MinPlayers")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("StartingZonesJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<string>("TilesJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Width")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsEnabled");
|
||||
|
||||
b.ToTable("board_templates", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.CustomLobby", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AdditionalPlayersJson")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("additional_players_json");
|
||||
|
||||
b.Property<int?>("BoardHeightOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("BoardShapeOverride")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("BoardTemplateIdOverride")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int?>("BoardWidthOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool?>("DiscardOnMaxHandOverride")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("DrawPerTurnOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool?>("FirstPlayerSkipsDrawOverride")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("GameMode")
|
||||
.IsRequired()
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("text")
|
||||
.HasDefaultValue("FFA")
|
||||
.HasColumnName("game_mode");
|
||||
|
||||
b.Property<Guid?>("GameSessionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("GuestAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("GuestDeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("GuestFirstTurnPref")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("GuestReady")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("HandSizeCapOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("HexSidesOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("HostAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("HostDeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("HostFirstTurnPref")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("HostReady")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("MaxArchTier1Override")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MaxDeckSizeOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaxPlayers")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MinDeckSizeOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MpBuffOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("OpeningHandSizeOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("SpAccumulationPerTurnOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SpCapOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool?>("SpHasCapOverride")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("StartingRandomTilePctOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TeamAssignmentsJson")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("TeamCount")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasDefaultValue(1)
|
||||
.HasColumnName("team_count");
|
||||
|
||||
b.Property<int?>("TimeLimitMinutesOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("TurnLimitOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("TurnTimerSecondsOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HostAccountId");
|
||||
|
||||
b.HasIndex("Status", "CreatedAt");
|
||||
|
||||
b.ToTable("custom_lobbies", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.GameActionLog", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ActionType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ActorAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("GameSessionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("OccurredAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("PayloadJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("payload");
|
||||
|
||||
b.Property<string>("ResultJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("result");
|
||||
|
||||
b.Property<int>("SequenceNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ActorAccountId");
|
||||
|
||||
b.HasIndex("GameSessionId", "SequenceNumber")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("action_logs", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.GameRuleSet", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("BoardHeight")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid?>("BoardTemplateId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("BoardWidth")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("DiscardOnMaxHand")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("DrawPerTurn")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("FirstPlayerSkipsDraw")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("GridType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("HandSizeCap")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HexSides")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsCustomDefault")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsRankedDefault")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("LoserOpReward")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaxArchTier1")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MaxDeckSize")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MinDeckSize")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MpBuff")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("OpeningHandSize")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RankDiffOpMultiplierPct")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SpAccumulationPerTurn")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SpCap")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("SpHasCap")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("StartingRandomTilePct")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TimeLimitMinutes")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TurnLimit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TurnTimerSeconds")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("WinnerOpReward")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsCustomDefault");
|
||||
|
||||
b.HasIndex("IsRankedDefault");
|
||||
|
||||
b.ToTable("game_rule_sets", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.GameSession", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AdditionalPlayersJson")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("additional_players_json");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("EndedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("GameMode")
|
||||
.IsRequired()
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("text")
|
||||
.HasDefaultValue("FFA")
|
||||
.HasColumnName("game_mode");
|
||||
|
||||
b.Property<DateTimeOffset?>("LastActionAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PlayerCount")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasDefaultValue(2)
|
||||
.HasColumnName("player_count");
|
||||
|
||||
b.Property<Guid>("PlayerOneAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PlayerOneDeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("PlayerOneReady")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<Guid>("PlayerTwoAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PlayerTwoDeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("PlayerTwoReady")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("RuleSnapshotJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("rule_snapshot");
|
||||
|
||||
b.Property<DateTimeOffset?>("StartedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("StateJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("state");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WinCondition")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("WinnerAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlayerOneAccountId");
|
||||
|
||||
b.HasIndex("PlayerTwoAccountId");
|
||||
|
||||
b.HasIndex("Status", "CreatedAt");
|
||||
|
||||
b.ToTable("game_sessions", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.LobbyPreset", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("OwnerAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("RulesJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerAccountId");
|
||||
|
||||
b.ToTable("lobby_presets", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.MatchmakingEntry", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("AccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("DeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("JoinedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("MatchedGameSessionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("RankScore")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset?>("ResolvedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AccountId", "Status");
|
||||
|
||||
b.HasIndex("Status", "RankScore");
|
||||
|
||||
b.ToTable("matchmaking_entries", "game");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.GameActionLog", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Game.GameSession", "Session")
|
||||
.WithMany("ActionLog")
|
||||
.HasForeignKey("GameSessionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Session");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Game.GameSession", b =>
|
||||
{
|
||||
b.Navigation("ActionLog");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Game
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddBoardTemplateHexSideLength : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "HexSideLength",
|
||||
schema: "game",
|
||||
table: "board_templates",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HexSideLength",
|
||||
schema: "game",
|
||||
table: "board_templates");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,9 @@ namespace SOR.Database.Migrations.Game
|
||||
b.Property<int>("HexPolygonSides")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HexSideLength")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HexSides")
|
||||
.HasColumnType("integer");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user