Wire BoardTemplateId through lobby rule DTOs and handlers
CustomRulesOverride and CustomRulesDto both lacked a BoardTemplateId field, so the client's template selection was never received or stored. lobby.BoardTemplateIdOverride always remained null, boardTemplateJson was never built, and the auto-shape generator ran instead of the template. - CustomRulesOverride: add Guid? BoardTemplateId - CustomRulesDto: add Guid? BoardTemplateId (default null for compat) - GameCreateCustomLobbyHandler: save BoardTemplateIdOverride on create; thread boardTemplateId through ToDto() - GameUpdateLobbyRulesHandler: save BoardTemplateIdOverride on update - GameGetLobbyHandler, GameJoinCustomLobbyHandler, GameListCustomLobbiesHandler, GameListActiveLobbiesHandler: include BoardTemplateId in outgoing DTOs 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:
@@ -125,7 +125,12 @@ public sealed record CustomRulesOverride(
|
||||
/// Board shape. Null or "Default" = auto-select by player count via BoardShapeGenerator.AutoShape.
|
||||
/// Explicit values: "Rectangle" | "Cross" | "Triangular" | "RadialStar" | "HexRing".
|
||||
/// </summary>
|
||||
string? BoardShape = null);
|
||||
string? BoardShape = null,
|
||||
/// <summary>
|
||||
/// When set, use this board template instead of generating a board from BoardShape.
|
||||
/// Null or absent = no template (use shape generator).
|
||||
/// </summary>
|
||||
Guid? BoardTemplateId = null);
|
||||
|
||||
/// <summary>Join an open custom lobby with the specified deck.</summary>
|
||||
public sealed record JoinCustomLobbyRequest(Guid LobbyId, Guid DeckId, string? Password = null);
|
||||
@@ -712,7 +717,8 @@ public sealed record CustomRulesDto(
|
||||
int StartingRandomTilePct,
|
||||
/// <summary>"Default" = auto by player count; otherwise explicit shape name.</summary>
|
||||
string BoardShape,
|
||||
bool HasPassword);
|
||||
bool HasPassword,
|
||||
Guid? BoardTemplateId = null);
|
||||
|
||||
/// <summary>Client-facing lobby preset summary.</summary>
|
||||
public sealed record LobbyPresetDto(
|
||||
|
||||
@@ -95,6 +95,7 @@ internal sealed class GameCreateCustomLobbyHandler : GameHandlerBase, IMessageHa
|
||||
MpBuffOverride = req.Rules?.MpBuff,
|
||||
StartingRandomTilePctOverride = req.Rules?.StartingRandomTilePct,
|
||||
BoardShapeOverride = req.Rules?.BoardShape,
|
||||
BoardTemplateIdOverride = req.Rules?.BoardTemplateId,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
@@ -105,7 +106,7 @@ internal sealed class GameCreateCustomLobbyHandler : GameHandlerBase, IMessageHa
|
||||
new CreateCustomLobbyResponse(
|
||||
LobbyId : lobby.Id,
|
||||
LobbyName : lobby.Name,
|
||||
ActiveRules : ToDto(effective, req.Password != null, req.Rules?.BoardShape),
|
||||
ActiveRules : ToDto(effective, req.Password != null, req.Rules?.BoardShape, req.Rules?.BoardTemplateId),
|
||||
MaxPlayers : lobby.MaxPlayers,
|
||||
GameMode : lobby.GameMode,
|
||||
TeamCount : lobby.TeamCount));
|
||||
@@ -113,7 +114,8 @@ internal sealed class GameCreateCustomLobbyHandler : GameHandlerBase, IMessageHa
|
||||
|
||||
// Shared helper used by list/join handlers as well.
|
||||
// boardShape: the lobby's BoardShapeOverride string; null/"Default" → shown as "Default".
|
||||
internal static CustomRulesDto ToDto(GameRules r, bool hasPassword = false, string? boardShape = null) => new(
|
||||
// boardTemplateId: the lobby's BoardTemplateIdOverride; null = no template.
|
||||
internal static CustomRulesDto ToDto(GameRules r, bool hasPassword = false, string? boardShape = null, Guid? boardTemplateId = null) => new(
|
||||
OpeningHandSize : r.OpeningHandSize,
|
||||
FirstPlayerSkipsDraw : r.FirstPlayerSkipsDraw,
|
||||
SpAccumulationPerTurn : r.SpAccumulationPerTurn,
|
||||
@@ -135,5 +137,6 @@ internal sealed class GameCreateCustomLobbyHandler : GameHandlerBase, IMessageHa
|
||||
BoardShape : string.IsNullOrEmpty(boardShape) || boardShape == "Default"
|
||||
? "Default"
|
||||
: boardShape,
|
||||
HasPassword : hasPassword);
|
||||
HasPassword : hasPassword,
|
||||
BoardTemplateId : boardTemplateId);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ internal sealed class GameGetLobbyHandler : GameHandlerBase, IMessageHandler
|
||||
TimeLimitMinutes = lobby.TimeLimitMinutesOverride ?? GameRules.Default.TimeLimitMinutes,
|
||||
TurnLimit = lobby.TurnLimitOverride ?? GameRules.Default.TurnLimit,
|
||||
MpBuff = lobby.MpBuffOverride ?? GameRules.Default.MpBuff,
|
||||
}, lobby.Password != null, lobby.BoardShapeOverride);
|
||||
}, lobby.Password != null, lobby.BoardShapeOverride, lobby.BoardTemplateIdOverride);
|
||||
|
||||
var dto = new CustomLobbyDetailDto(
|
||||
LobbyId : lobby.Id,
|
||||
|
||||
@@ -181,7 +181,7 @@ internal sealed class GameJoinCustomLobbyHandler : GameHandlerBase, IMessageHand
|
||||
new JoinCustomLobbyResponse(
|
||||
LobbyId : lobby.Id,
|
||||
Status : lobby.Status == CustomLobbyStatus.Full ? "WaitingForReady" : "WaitingForPlayers",
|
||||
ActiveRules : GameCreateCustomLobbyHandler.ToDto(effective, lobby.Password != null, lobby.BoardShapeOverride),
|
||||
ActiveRules : GameCreateCustomLobbyHandler.ToDto(effective, lobby.Password != null, lobby.BoardShapeOverride, lobby.BoardTemplateIdOverride),
|
||||
GameSessionId : null,
|
||||
HostAccountId : lobby.HostAccountId,
|
||||
HostDisplayName : hostName,
|
||||
|
||||
@@ -95,7 +95,8 @@ internal sealed class GameListActiveLobbiesHandler : GameHandlerBase, IMessageHa
|
||||
MpBuff : l.MpBuffOverride ?? GameRules.Default.MpBuff,
|
||||
StartingRandomTilePct : l.StartingRandomTilePctOverride ?? GameRules.Default.StartingRandomTilePct,
|
||||
BoardShape : l.BoardShapeOverride ?? "Default",
|
||||
HasPassword : l.Password != null)));
|
||||
HasPassword : l.Password != null,
|
||||
BoardTemplateId : l.BoardTemplateIdOverride)));
|
||||
|
||||
return ServerMessage.Reply("game.custom.list_active.ack", message.Seq,
|
||||
new ListActiveLobbiesResponse(
|
||||
|
||||
@@ -118,7 +118,8 @@ internal sealed class GameListCustomLobbiesHandler : GameHandlerBase, IMessageHa
|
||||
MpBuff : l.MpBuffOverride ?? GameRules.Default.MpBuff,
|
||||
StartingRandomTilePct : l.StartingRandomTilePctOverride ?? GameRules.Default.StartingRandomTilePct,
|
||||
BoardShape : l.BoardShapeOverride ?? "Default",
|
||||
HasPassword : l.Password != null),
|
||||
HasPassword : l.Password != null,
|
||||
BoardTemplateId : l.BoardTemplateIdOverride),
|
||||
CreatedAt : l.CreatedAt,
|
||||
MaxPlayers : l.MaxPlayers,
|
||||
CurrentPlayerCount : currentPlayerCount,
|
||||
|
||||
@@ -72,6 +72,7 @@ internal sealed class GameUpdateLobbyRulesHandler : GameHandlerBase, IMessageHan
|
||||
lobby.MpBuffOverride = r.MpBuff;
|
||||
lobby.StartingRandomTilePctOverride = r.StartingRandomTilePct;
|
||||
lobby.BoardShapeOverride = r.BoardShape;
|
||||
lobby.BoardTemplateIdOverride = r.BoardTemplateId;
|
||||
|
||||
await _gameDb.SaveChangesAsync(ct);
|
||||
|
||||
@@ -95,7 +96,7 @@ internal sealed class GameUpdateLobbyRulesHandler : GameHandlerBase, IMessageHan
|
||||
TurnLimit = r.TurnLimit ?? GameRules.Default.TurnLimit,
|
||||
MpBuff = r.MpBuff ?? GameRules.Default.MpBuff,
|
||||
StartingRandomTilePct = r.StartingRandomTilePct ?? GameRules.Default.StartingRandomTilePct,
|
||||
}, lobby.Password != null, r.BoardShape);
|
||||
}, lobby.Password != null, r.BoardShape, r.BoardTemplateId);
|
||||
|
||||
var updatedPush = ServerMessage.Push("game.custom.lobby_updated",
|
||||
new LobbyUpdatedPush(lobby.Id, effective));
|
||||
|
||||
Reference in New Issue
Block a user