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:
dingo
2026-02-26 06:57:13 -05:00
co-authored by Claude Happy
parent b5c9385e73
commit 2058a47a92
40 changed files with 3360 additions and 0 deletions
+4
View File
@@ -17,7 +17,9 @@ using SOR.Bazaar;
using SOR.Chat;
using SOR.Collection;
using SOR.Content;
using SOR.Game;
using SOR.Gateway;
using SOR.Matchmaking;
using SOR.Versioning;
using SOR.Networking.Nats;
using SOR.Networking.Redis;
@@ -140,6 +142,8 @@ if (IsEnabled("gateway")) builder.Services.AddGatewayService(builder.Configur
if (IsEnabled("bazaar")) builder.Services.AddBazaarService(builder.Configuration);
if (IsEnabled("content")) builder.Services.AddContentService(builder.Configuration);
if (IsEnabled("versioning")) builder.Services.AddVersioningService(builder.Configuration);
if (IsEnabled("matchmaking")) builder.Services.AddMatchmakingService(builder.Configuration);
if (IsEnabled("game")) builder.Services.AddGameService(builder.Configuration);
// TODO: Uncomment as each service is implemented:
// if (IsEnabled("leaderboard")) builder.Services.AddLeaderboardService(builder.Configuration);
+2
View File
@@ -34,5 +34,7 @@
<ProjectReference Include="..\SOR.Bazaar\SOR.Bazaar.csproj" />
<ProjectReference Include="..\SOR.Content\SOR.Content.csproj" />
<ProjectReference Include="..\SOR.Versioning\SOR.Versioning.csproj" />
<ProjectReference Include="..\SOR.Matchmaking\SOR.Matchmaking.csproj" />
<ProjectReference Include="..\SOR.Game\SOR.Game.csproj" />
</ItemGroup>
</Project>