Add matchmaking + gameplay services (SOR.Matchmaking + SOR.Game)
DB layer:
- Account.RankScore (int, default 1000) — ELO rank for matchmaking
- GameEnums: MatchmakingStatus, GameSessionStatus, GamePhase
- Entities: MatchmakingEntry, GameSession, GameActionLog
- GameDbContext (schema: game) + AddGameDatabase() registration
- Migrations: AddRankScore (Identity), InitialCreate (Game)
SOR.Matchmaking:
- MatchmakerService (BackgroundService) — 5s poll, ELO ±100→±500 range
- Handlers: matchmaking.join, matchmaking.leave, matchmaking.status
- Pushes MatchFoundPush to both players via IClientPush on match
SOR.Game:
- GameState / PlayerState / CardInstance / FieldCard JSONB model
- GameEngine (pure static): Init, Draw, PlayCard, Attack, EndTurn, Concede
- ELO delta (K=32) computed and applied on game end
- Handlers: game.ready, game.get_state, game.draw, game.play_card,
game.attack, game.end_turn, game.concede
- State filtered per-viewer (opponent hand/deck hidden)
- GameOverPush with rank deltas to both players
Admin pages:
- /game/matchmaking — live queue stats, active entries, recent activity
- /game/sessions — session stats, filterable by status/account
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:
@@ -0,0 +1,33 @@
|
||||
namespace SOR.Database.Entities.Game;
|
||||
|
||||
using SOR.Database.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a player's entry in the matchmaking queue.
|
||||
/// Created when a player joins the queue; status updated when matched or cancelled.
|
||||
///
|
||||
/// Cross-schema: AccountId and DeckId are bare Guids — no EF foreign keys.
|
||||
/// </summary>
|
||||
public sealed class MatchmakingEntry
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
/// <summary>Identity schema account (bare Guid — no EF FK).</summary>
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
/// <summary>Deck the player intends to use for the match.</summary>
|
||||
public Guid DeckId { get; set; }
|
||||
|
||||
/// <summary>ELO rank score at the time the player joined the queue.</summary>
|
||||
public int RankScore { get; set; }
|
||||
|
||||
public MatchmakingStatus Status { get; set; } = MatchmakingStatus.Searching;
|
||||
|
||||
public DateTimeOffset JoinedAt { get; set; }
|
||||
|
||||
/// <summary>Null until a match is found or entry is cancelled.</summary>
|
||||
public DateTimeOffset? ResolvedAt { get; set; }
|
||||
|
||||
/// <summary>Set when status transitions to Matched.</summary>
|
||||
public Guid? MatchedGameSessionId { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user