Phase 5: Preset system — VoteSessionService + 5 handlers
- VoteSessionService singleton: ConcurrentDictionary<Guid, ActiveVote> keyed by lobbyId. TryStart prevents concurrent votes; Cast resolves immediately on any rejection or all approval. - GameSavePresetHandler (game.custom.preset.save): captures lobby override columns into CustomRulesOverride JSON and persists as LobbyPreset; participants only. - GameListPresetsHandler (game.custom.preset.list): returns all presets owned by caller. - GameDeletePresetHandler (game.custom.preset.delete): owner-only delete. - GameProposePresetHandler (game.custom.preset.propose): host-only in Full lobby; starts vote with guest as sole voter; pushes game.custom.preset.vote_requested to guest. - GameVotePresetHandler (game.custom.preset.vote): casts yes/no; Approved → applies preset overrides to lobby DB + pushes game.custom.lobby_updated to both; Rejected → pushes game.custom.preset.vote_rejected to both. - GameMessages.cs: SavePreset/ListPresets/DeletePreset/ProposePreset/VotePreset request/response types; LobbyPresetDto; PresetVoteRequestedPush, LobbyUpdatedPush, PresetVoteRejectedPush. 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:
@@ -124,6 +124,25 @@ public sealed record JoinCustomLobbyRequest(Guid LobbyId, Guid DeckId, string? P
|
||||
/// <summary>Leave or cancel a custom lobby.</summary>
|
||||
public sealed record LeaveCustomLobbyRequest(Guid LobbyId);
|
||||
|
||||
// ── Preset requests ───────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Save the current lobby's rule overrides as a named preset (participants only).</summary>
|
||||
public sealed record SavePresetRequest(Guid LobbyId, string PresetName);
|
||||
|
||||
/// <summary>List all presets owned by the calling player.</summary>
|
||||
public sealed record ListPresetsRequest();
|
||||
|
||||
/// <summary>Delete a preset owned by the calling player.</summary>
|
||||
public sealed record DeletePresetRequest(Guid PresetId);
|
||||
|
||||
/// <summary>Host proposes loading a preset; triggers a yes/no vote for the other participant.</summary>
|
||||
public sealed record ProposePresetRequest(Guid LobbyId, Guid PresetId);
|
||||
|
||||
/// <summary>Cast a yes/no vote on the active preset-load proposal for a lobby.</summary>
|
||||
public sealed record VotePresetRequest(Guid LobbyId, bool Accept);
|
||||
|
||||
// ── Spectator requests ────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Join a game session as a spectator.</summary>
|
||||
public sealed record SpectateRequest(Guid SessionId);
|
||||
|
||||
@@ -188,6 +207,20 @@ public sealed record JoinCustomLobbyResponse(
|
||||
|
||||
public sealed record LeaveCustomLobbyResponse(Guid LobbyId);
|
||||
|
||||
// ── Preset responses ──────────────────────────────────────────────────────────
|
||||
|
||||
public sealed record SavePresetResponse(Guid PresetId, string Name);
|
||||
|
||||
public sealed record ListPresetsResponse(IEnumerable<LobbyPresetDto> Presets);
|
||||
|
||||
public sealed record DeletePresetResponse(Guid PresetId);
|
||||
|
||||
public sealed record ProposePresetResponse(Guid LobbyId, string Status); // "VoteStarted"
|
||||
|
||||
public sealed record VotePresetResponse(Guid LobbyId, string Outcome); // "Approved" | "Rejected" | "Pending"
|
||||
|
||||
// ── Spectator responses ───────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Ack for game.spectate — spectator receives current filtered game state.</summary>
|
||||
public sealed record SpectateResponse(GameStateDto State);
|
||||
|
||||
@@ -253,6 +286,24 @@ public sealed record CustomLobbyGuestJoinedPush(
|
||||
Guid GuestAccountId,
|
||||
string LobbyName);
|
||||
|
||||
/// <summary>
|
||||
/// Pushed to the non-proposing participant when the host proposes loading a preset.
|
||||
/// The recipient should display the proposed rules and prompt Accept/Reject.
|
||||
/// </summary>
|
||||
public sealed record PresetVoteRequestedPush(
|
||||
Guid LobbyId,
|
||||
Guid PresetId,
|
||||
string PresetName,
|
||||
CustomRulesOverride Rules);
|
||||
|
||||
/// <summary>
|
||||
/// Pushed to both participants when a preset-load vote is approved and lobby rules update.
|
||||
/// </summary>
|
||||
public sealed record LobbyUpdatedPush(Guid LobbyId, CustomRulesDto NewRules);
|
||||
|
||||
/// <summary>Pushed to both participants when a preset-load vote is rejected.</summary>
|
||||
public sealed record PresetVoteRejectedPush(Guid LobbyId, Guid PresetId);
|
||||
|
||||
// ── DTOs ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
@@ -364,6 +415,13 @@ public sealed record CustomRulesDto(
|
||||
int MpBuff,
|
||||
bool HasPassword);
|
||||
|
||||
/// <summary>Client-facing lobby preset summary.</summary>
|
||||
public sealed record LobbyPresetDto(
|
||||
Guid PresetId,
|
||||
string Name,
|
||||
CustomRulesOverride Rules,
|
||||
DateTimeOffset CreatedAt);
|
||||
|
||||
/// <summary>
|
||||
/// A single client-provided target for one action in an ability.
|
||||
/// Exactly one of InstanceId or Coord should be set, matching the action's TargetType.
|
||||
|
||||
Reference in New Issue
Block a user