Client (game_screen.gd): - Scroll wheel no longer zooms camera when mouse is over the hand panel - Clicking a friendly unit smoothly tweens camera pivot to that unit (EASE_OUT CUBIC, 0.4s) — respects Settings.camera_follow_unit toggle - Chat overlay instantiated from game screen and removed on exit Client (Settings.gd + SettingsScreen): - Added camera_follow_unit bool (default: on) to gameplay settings section - Persisted to user://settings.cfg under [gameplay] - Toggle visible in Settings screen under new GAMEPLAY section Server Admin (MatchmakingQueuePage): - "Clear History" button deletes all non-Searching matchmaking entries Server Admin (GameSessionsPage): - Per-row "Abandon" button for Active/Initializing sessions - "Abandon All Active" bulk button marks all live sessions as Abandoned with EndedAt=now and WinCondition="admin" 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>
197 lines
7.4 KiB
Plaintext
197 lines
7.4 KiB
Plaintext
@page "/game/matchmaking"
|
||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||
@using Microsoft.EntityFrameworkCore
|
||
@using SOR.Database.Contexts
|
||
@using SOR.Database.Enums
|
||
@inject GameDbContext Db
|
||
|
||
<PageTitle>Matchmaking Queue – SOR Admin</PageTitle>
|
||
|
||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||
<h1 class="mb-0">Matchmaking Queue</h1>
|
||
<button class="btn btn-outline-secondary btn-sm" @onclick="LoadAsync">
|
||
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
|
||
</button>
|
||
</div>
|
||
|
||
<!-- Stats -->
|
||
<div class="row g-3 mb-4">
|
||
<div class="col-md-4">
|
||
<div class="card shadow-sm text-center py-3">
|
||
<div class="display-6 fw-bold text-primary">@_searchingCount</div>
|
||
<div class="text-muted small">Currently Searching</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<div class="card shadow-sm text-center py-3">
|
||
<div class="display-6 fw-bold text-success">@_matchedToday</div>
|
||
<div class="text-muted small">Matched Today</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<div class="card shadow-sm text-center py-3">
|
||
<div class="display-6 fw-bold text-secondary">@_cancelledToday</div>
|
||
<div class="text-muted small">Cancelled Today</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
@if (_loading)
|
||
{
|
||
<p class="text-muted">Loading…</p>
|
||
}
|
||
else
|
||
{
|
||
<!-- Active Queue -->
|
||
<div class="card shadow-sm mb-4">
|
||
<div class="card-header fw-medium d-flex justify-content-between">
|
||
<span>Active Queue</span>
|
||
<span class="badge bg-primary">@_searchingEntries.Count players waiting</span>
|
||
</div>
|
||
<div class="card-body p-0">
|
||
<table class="table table-sm table-hover mb-0">
|
||
<thead class="table-light">
|
||
<tr>
|
||
<th>Account</th>
|
||
<th class="text-end">Rank</th>
|
||
<th>Waiting</th>
|
||
<th>Deck</th>
|
||
<th>Entry ID</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach (var e in _searchingEntries)
|
||
{
|
||
<tr>
|
||
<td class="font-monospace small">@e.AccountId.ToString()[..8]…</td>
|
||
<td class="text-end fw-medium">@e.RankScore</td>
|
||
<td class="text-muted small">@FormatWait(e.JoinedAt)</td>
|
||
<td class="font-monospace small text-muted">@e.DeckId.ToString()[..8]…</td>
|
||
<td class="font-monospace small text-muted">@e.Id.ToString()[..8]…</td>
|
||
</tr>
|
||
}
|
||
@if (!_searchingEntries.Any())
|
||
{
|
||
<tr>
|
||
<td colspan="5" class="text-muted text-center py-3">Queue is empty.</td>
|
||
</tr>
|
||
}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Recent Entries -->
|
||
<div class="card shadow-sm">
|
||
<div class="card-header fw-medium d-flex justify-content-between align-items-center">
|
||
<span>Recent Activity (last 100)</span>
|
||
<button class="btn btn-outline-danger btn-sm" @onclick="ClearRecentAsync">
|
||
<i class="bi bi-trash me-1"></i>Clear History
|
||
</button>
|
||
</div>
|
||
<div class="card-body p-0">
|
||
<table class="table table-sm table-hover mb-0">
|
||
<thead class="table-light">
|
||
<tr>
|
||
<th>Joined</th>
|
||
<th>Account</th>
|
||
<th class="text-end">Rank</th>
|
||
<th>Status</th>
|
||
<th>Wait</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach (var e in _recentEntries)
|
||
{
|
||
<tr>
|
||
<td class="text-muted small">@e.JoinedAt.ToString("HH:mm:ss")</td>
|
||
<td class="font-monospace small">@e.AccountId.ToString()[..8]…</td>
|
||
<td class="text-end">@e.RankScore</td>
|
||
<td>
|
||
<span class="badge @StatusBadge(e.Status)">@e.Status</span>
|
||
</td>
|
||
<td class="small text-muted">
|
||
@(e.ResolvedAt.HasValue
|
||
? FormatDuration(e.ResolvedAt.Value - e.JoinedAt)
|
||
: FormatWait(e.JoinedAt))
|
||
</td>
|
||
</tr>
|
||
}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
}
|
||
|
||
@code {
|
||
private bool _loading = true;
|
||
private int _searchingCount, _matchedToday, _cancelledToday;
|
||
|
||
private List<QueueRow> _searchingEntries = new();
|
||
private List<QueueRow> _recentEntries = new();
|
||
|
||
private record QueueRow(
|
||
Guid Id,
|
||
Guid AccountId,
|
||
Guid DeckId,
|
||
int RankScore,
|
||
string Status,
|
||
DateTimeOffset JoinedAt,
|
||
DateTimeOffset? ResolvedAt);
|
||
|
||
protected override async Task OnInitializedAsync() => await LoadAsync();
|
||
|
||
private async Task ClearRecentAsync()
|
||
{
|
||
await Db.MatchmakingEntries
|
||
.Where(e => e.Status != MatchmakingStatus.Searching)
|
||
.ExecuteDeleteAsync();
|
||
await LoadAsync();
|
||
}
|
||
|
||
private async Task LoadAsync()
|
||
{
|
||
_loading = true;
|
||
var todayStart = DateTimeOffset.UtcNow.Date;
|
||
|
||
_searchingCount = await Db.MatchmakingEntries.CountAsync(e => e.Status == MatchmakingStatus.Searching);
|
||
_matchedToday = await Db.MatchmakingEntries.CountAsync(e => e.Status == MatchmakingStatus.Matched && e.ResolvedAt >= todayStart);
|
||
_cancelledToday = await Db.MatchmakingEntries.CountAsync(e => e.Status == MatchmakingStatus.Cancelled && e.ResolvedAt >= todayStart);
|
||
|
||
_searchingEntries = await Db.MatchmakingEntries
|
||
.Where(e => e.Status == MatchmakingStatus.Searching)
|
||
.OrderBy(e => e.JoinedAt)
|
||
.Select(e => new QueueRow(e.Id, e.AccountId, e.DeckId, e.RankScore, e.Status.ToString(), e.JoinedAt, e.ResolvedAt))
|
||
.ToListAsync();
|
||
|
||
_recentEntries = await Db.MatchmakingEntries
|
||
.OrderByDescending(e => e.JoinedAt)
|
||
.Take(100)
|
||
.Select(e => new QueueRow(e.Id, e.AccountId, e.DeckId, e.RankScore, e.Status.ToString(), e.JoinedAt, e.ResolvedAt))
|
||
.ToListAsync();
|
||
|
||
_loading = false;
|
||
}
|
||
|
||
private static string FormatWait(DateTimeOffset joinedAt)
|
||
{
|
||
var wait = DateTimeOffset.UtcNow - joinedAt;
|
||
return FormatDuration(wait);
|
||
}
|
||
|
||
private static string FormatDuration(TimeSpan ts)
|
||
{
|
||
if (ts.TotalHours >= 1) return $"{(int)ts.TotalHours}h {ts.Minutes}m";
|
||
if (ts.TotalMinutes >= 1) return $"{(int)ts.TotalMinutes}m {ts.Seconds}s";
|
||
return $"{(int)ts.TotalSeconds}s";
|
||
}
|
||
|
||
private static string StatusBadge(string status) => status switch
|
||
{
|
||
nameof(MatchmakingStatus.Searching) => "bg-primary",
|
||
nameof(MatchmakingStatus.Matched) => "bg-success",
|
||
nameof(MatchmakingStatus.Cancelled) => "bg-secondary",
|
||
_ => "bg-light text-dark",
|
||
};
|
||
}
|