From 2058a47a92b44b1de16deb67c27dae6e30bb56bd Mon Sep 17 00:00:00 2001 From: dingo Date: Thu, 26 Feb 2026 06:57:13 -0500 Subject: [PATCH] Add matchmaking + gameplay services (SOR.Matchmaking + SOR.Game) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-Authored-By: Happy --- Server/SOR.slnx | 2 + .../SOR.Admin/Components/Layout/NavMenu.razor | 17 + .../Pages/Game/GameSessionsPage.razor | 229 +++++++++ .../Pages/Game/MatchmakingQueuePage.razor | 183 ++++++++ Server/src/SOR.Admin/Program.cs | 1 + .../SOR.Database/Contexts/GameDbContext.cs | 70 +++ .../Entities/Game/GameActionLog.cs | 33 ++ .../SOR.Database/Entities/Game/GameSession.cs | 63 +++ .../Entities/Game/MatchmakingEntry.cs | 33 ++ .../SOR.Database/Entities/Identity/Account.cs | 6 + Server/src/SOR.Database/Enums/GameEnums.cs | 46 ++ .../20260226112003_InitialCreate.Designer.cs | 178 +++++++ .../Game/20260226112003_InitialCreate.cs | 146 ++++++ .../Game/GameDbContextModelSnapshot.cs | 175 +++++++ .../20260226111950_AddRankScore.Designer.cs | 410 ++++++++++++++++ .../Identity/20260226111950_AddRankScore.cs | 31 ++ .../SorIdentityDbContextModelSnapshot.cs | 3 + .../src/SOR.Database/ServiceRegistration.cs | 9 + Server/src/SOR.Game/GameEngine.cs | 439 ++++++++++++++++++ Server/src/SOR.Game/GameMessages.cs | 103 ++++ Server/src/SOR.Game/GameState.cs | 102 ++++ .../SOR.Game/Handlers/GameAttackHandler.cs | 74 +++ .../SOR.Game/Handlers/GameConcedeHandler.cs | 64 +++ .../src/SOR.Game/Handlers/GameDrawHandler.cs | 49 ++ .../SOR.Game/Handlers/GameEndTurnHandler.cs | 48 ++ .../SOR.Game/Handlers/GameGetStateHandler.cs | 43 ++ .../src/SOR.Game/Handlers/GameHandlerBase.cs | 137 ++++++ .../SOR.Game/Handlers/GamePlayCardHandler.cs | 48 ++ .../src/SOR.Game/Handlers/GameReadyHandler.cs | 136 ++++++ Server/src/SOR.Game/SOR.Game.csproj | 15 + Server/src/SOR.Game/ServiceRegistration.cs | 34 ++ Server/src/SOR.Host/Program.cs | 4 + Server/src/SOR.Host/SOR.Host.csproj | 2 + .../Handlers/MatchmakingGetStatusHandler.cs | 44 ++ .../Handlers/MatchmakingJoinHandler.cs | 76 +++ .../Handlers/MatchmakingLeaveHandler.cs | 51 ++ .../src/SOR.Matchmaking/MatchmakerService.cs | 165 +++++++ .../SOR.Matchmaking/MatchmakingMessages.cs | 45 ++ .../SOR.Matchmaking/SOR.Matchmaking.csproj | 15 + .../SOR.Matchmaking/ServiceRegistration.cs | 31 ++ 40 files changed, 3360 insertions(+) create mode 100644 Server/src/SOR.Admin/Components/Pages/Game/GameSessionsPage.razor create mode 100644 Server/src/SOR.Admin/Components/Pages/Game/MatchmakingQueuePage.razor create mode 100644 Server/src/SOR.Database/Contexts/GameDbContext.cs create mode 100644 Server/src/SOR.Database/Entities/Game/GameActionLog.cs create mode 100644 Server/src/SOR.Database/Entities/Game/GameSession.cs create mode 100644 Server/src/SOR.Database/Entities/Game/MatchmakingEntry.cs create mode 100644 Server/src/SOR.Database/Enums/GameEnums.cs create mode 100644 Server/src/SOR.Database/Migrations/Game/20260226112003_InitialCreate.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Game/20260226112003_InitialCreate.cs create mode 100644 Server/src/SOR.Database/Migrations/Game/GameDbContextModelSnapshot.cs create mode 100644 Server/src/SOR.Database/Migrations/Identity/20260226111950_AddRankScore.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Identity/20260226111950_AddRankScore.cs create mode 100644 Server/src/SOR.Game/GameEngine.cs create mode 100644 Server/src/SOR.Game/GameMessages.cs create mode 100644 Server/src/SOR.Game/GameState.cs create mode 100644 Server/src/SOR.Game/Handlers/GameAttackHandler.cs create mode 100644 Server/src/SOR.Game/Handlers/GameConcedeHandler.cs create mode 100644 Server/src/SOR.Game/Handlers/GameDrawHandler.cs create mode 100644 Server/src/SOR.Game/Handlers/GameEndTurnHandler.cs create mode 100644 Server/src/SOR.Game/Handlers/GameGetStateHandler.cs create mode 100644 Server/src/SOR.Game/Handlers/GameHandlerBase.cs create mode 100644 Server/src/SOR.Game/Handlers/GamePlayCardHandler.cs create mode 100644 Server/src/SOR.Game/Handlers/GameReadyHandler.cs create mode 100644 Server/src/SOR.Game/SOR.Game.csproj create mode 100644 Server/src/SOR.Game/ServiceRegistration.cs create mode 100644 Server/src/SOR.Matchmaking/Handlers/MatchmakingGetStatusHandler.cs create mode 100644 Server/src/SOR.Matchmaking/Handlers/MatchmakingJoinHandler.cs create mode 100644 Server/src/SOR.Matchmaking/Handlers/MatchmakingLeaveHandler.cs create mode 100644 Server/src/SOR.Matchmaking/MatchmakerService.cs create mode 100644 Server/src/SOR.Matchmaking/MatchmakingMessages.cs create mode 100644 Server/src/SOR.Matchmaking/SOR.Matchmaking.csproj create mode 100644 Server/src/SOR.Matchmaking/ServiceRegistration.cs diff --git a/Server/SOR.slnx b/Server/SOR.slnx index 2758226..6525cb7 100644 --- a/Server/SOR.slnx +++ b/Server/SOR.slnx @@ -8,8 +8,10 @@ + + diff --git a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor index 33c0ea1..509abf8 100644 --- a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor +++ b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor @@ -63,6 +63,23 @@ +