- New BoardTemplate entity (TilesJson/StartingZonesJson as jsonb) - BoardTemplateIdOverride on CustomLobby, BoardTemplateId on GameRuleSet - EF migration AddBoardTemplates + applied to pg-forge-01 - Admin list page: /game/board-templates (toggle enable, edit, delete) - Admin builder: paint canvas (22-affinity palette, drag support), zone edit mode (per-player-count seat assignment, erase), tile flags modal - NavMenu: Board Templates link under Game submenu - GameRules: BoardShape default changed to "Default" 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>
129 lines
6.1 KiB
C#
129 lines
6.1 KiB
C#
namespace SOR.Database.Entities.Game;
|
||
|
||
using SOR.Database.Enums;
|
||
|
||
/// <summary>
|
||
/// A custom (non-matchmade) game lobby created by a player.
|
||
///
|
||
/// The host creates the lobby and invites one other player. Once both are present,
|
||
/// a GameSession is created using the custom rules. Rule fields that are null inherit
|
||
/// from the active custom-default GameRuleSet.
|
||
///
|
||
/// Cross-schema: all account and deck IDs are bare Guids — no EF foreign keys.
|
||
/// </summary>
|
||
public sealed class CustomLobby
|
||
{
|
||
public Guid Id { get; set; } = Guid.NewGuid();
|
||
|
||
public string Name { get; set; } = string.Empty;
|
||
public CustomLobbyStatus Status { get; set; } = CustomLobbyStatus.Open;
|
||
|
||
// ── Host ─────────────────────────────────────────────────────────────────
|
||
|
||
public Guid HostAccountId { get; set; }
|
||
public Guid HostDeckId { get; set; }
|
||
|
||
// ── Guest ────────────────────────────────────────────────────────────────
|
||
|
||
public Guid? GuestAccountId { get; set; }
|
||
public Guid? GuestDeckId { get; set; }
|
||
|
||
// ── Linked game session ───────────────────────────────────────────────────
|
||
|
||
/// <summary>Set once the GameSession is created from this lobby.</summary>
|
||
public Guid? GameSessionId { get; set; }
|
||
|
||
// ── Rule overrides (null = use custom-default ruleset value) ─────────────
|
||
|
||
public int? OpeningHandSizeOverride { get; set; }
|
||
public bool? FirstPlayerSkipsDrawOverride { get; set; }
|
||
public int? SpAccumulationPerTurnOverride { get; set; }
|
||
public int? DrawPerTurnOverride { get; set; }
|
||
public bool? SpHasCapOverride { get; set; }
|
||
public int? SpCapOverride { get; set; }
|
||
|
||
// ── Extended rule overrides ───────────────────────────────────────────────
|
||
|
||
/// <summary>Optional password to join this lobby. Null = no password required.</summary>
|
||
public string? Password { get; set; }
|
||
|
||
/// <summary>Max cards in hand. 0 = no cap.</summary>
|
||
public int? HandSizeCapOverride { get; set; }
|
||
|
||
/// <summary>If true, excess cards are auto-discarded when hand is at cap. If false, draw is blocked.</summary>
|
||
public bool? DiscardOnMaxHandOverride { get; set; }
|
||
|
||
/// <summary>Maximum deck size. 0 = no limit.</summary>
|
||
public int? MaxDeckSizeOverride { get; set; }
|
||
|
||
/// <summary>Minimum deck size. 0 = no limit.</summary>
|
||
public int? MinDeckSizeOverride { get; set; }
|
||
|
||
/// <summary>Max copies of a Tier-1 Arch card allowed per deck. 0 = no limit.</summary>
|
||
public int? MaxArchTier1Override { get; set; }
|
||
|
||
/// <summary>Seconds per turn before auto-end. 0 = no timer.</summary>
|
||
public int? TurnTimerSecondsOverride { get; set; }
|
||
|
||
/// <summary>Total game time limit in minutes. 0 = no limit.</summary>
|
||
public int? TimeLimitMinutesOverride { get; set; }
|
||
|
||
/// <summary>Maximum number of turns before game ends. 0 = no limit.</summary>
|
||
public int? TurnLimitOverride { get; set; }
|
||
|
||
/// <summary>Flat MP bonus added to each unit at the start of its owner's turn. 0 = no buff.</summary>
|
||
public int? MpBuffOverride { get; set; }
|
||
|
||
/// <summary>Board width override in columns.</summary>
|
||
public int? BoardWidthOverride { get; set; }
|
||
|
||
/// <summary>Board height override in rows.</summary>
|
||
public int? BoardHeightOverride { get; set; }
|
||
|
||
/// <summary>
|
||
/// Board shape override. Null or "Default" = use BoardShapeGenerator.AutoShape(playerCount).
|
||
/// Valid explicit values: "Rectangle" | "Cross" | "Triangular" | "RadialStar" | "HexRing".
|
||
/// </summary>
|
||
public string? BoardShapeOverride { get; set; }
|
||
|
||
/// <summary>When set, use this BoardTemplate instead of generating a board algorithmically.</summary>
|
||
public Guid? BoardTemplateIdOverride { get; set; }
|
||
|
||
/// <summary>Percentage (0–100) of tiles that start with a random basic affinity. 0 = all void.</summary>
|
||
public int? StartingRandomTilePctOverride { get; set; }
|
||
|
||
// ── Ready-up state ────────────────────────────────────────────────────────
|
||
|
||
/// <summary>True once the host has clicked Ready in the lobby room.</summary>
|
||
public bool HostReady { get; set; } = false;
|
||
|
||
/// <summary>True once the guest has clicked Ready in the lobby room.</summary>
|
||
public bool GuestReady { get; set; } = false;
|
||
|
||
/// <summary>Host's first-turn preference: "host" | "guest" | "random" | null.</summary>
|
||
public string? HostFirstTurnPref { get; set; }
|
||
|
||
/// <summary>Guest's first-turn preference: "host" | "guest" | "random" | null.</summary>
|
||
public string? GuestFirstTurnPref { get; set; }
|
||
|
||
/// <summary>Maximum number of players. Default 2.</summary>
|
||
public int MaxPlayers { get; set; } = 2;
|
||
|
||
/// <summary>"FFA" | "Teams" | "MultiTeam".</summary>
|
||
public string GameMode { get; set; } = "FFA";
|
||
|
||
/// <summary>Number of teams. 1 = FFA, 2 = two-team, etc.</summary>
|
||
public int TeamCount { get; set; } = 1;
|
||
|
||
/// <summary>
|
||
/// JSON array of additional player slots beyond host/guest.
|
||
/// Each element: { "accountId": "...", "deckId": "..." }.
|
||
/// Null until 3rd+ player joins.
|
||
/// </summary>
|
||
public string? AdditionalPlayersJson { get; set; }
|
||
|
||
// ── Timestamps ───────────────────────────────────────────────────────────
|
||
|
||
public DateTimeOffset CreatedAt { get; set; }
|
||
}
|