Feature: leaderboard hide, ability animations, card sounds, BGM, in-game settings

Server:
- Account.IsHiddenFromLeaderboard: filter bots/devs from leaderboard
- AbilityAnimationDefinition: type, effect, dimensions, asset/sound URLs per ability
- CardAnimationBinding: CastSoundCdnUrl + ImpactSoundCdnUrl per card action
- GameAudioConfig entity: admin-configurable BGM tracks per context
- GetGameAudioConfigHandler (content.get_audio_config) + ServiceRegistration
- Admin pages: AccountDetail toggle, AudioConfig CRUD, CardEditor + AbilityBuilder UI
- Migrations: AddLeaderboardHide, AddCardActionSounds, AddGameAudioConfig

Client:
- Music.gd autoload: fetches BGM config, crossfades between context tracks
- InGameSettings overlay: audio sliders, camera follow toggle, concede with confirm
- GameScreen: gear button opens settings; ConcedeBtn moved into settings panel
- project.godot: Music autoload registered

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-03-13 23:31:10 -04:00
co-authored by Claude Happy
parent c44dadec45
commit 3810742fe6
27 changed files with 1086 additions and 25 deletions
@@ -117,6 +117,11 @@
<i class="bi bi-robot me-2"></i>AI Art Tracker
</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link text-white-50 py-1" href="/content/audio">
<i class="bi bi-music-note-beamed me-2"></i>Audio Config
</NavLink>
</li>
</ul>
</li>
<li class="nav-item">
@@ -396,6 +396,28 @@ else
</div>
</div>
<!-- Leaderboard -->
<div class="col-md-6">
<div class="card shadow-sm">
<div class="card-header fw-medium">Leaderboard</div>
<div class="card-body">
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" role="switch"
id="hideLeaderboard"
checked="@_account.IsHiddenFromLeaderboard"
@onchange="ToggleLeaderboardHideAsync" />
<label class="form-check-label" for="hideLeaderboard">
Hidden from leaderboard
</label>
</div>
<div class="form-text">
When enabled, this account will not appear in the public leaderboard.
Use for bots, dev accounts, and internal test accounts.
</div>
</div>
</div>
</div>
<!-- Account Properties -->
<div class="col-12">
<div class="card shadow-sm">
@@ -800,6 +822,27 @@ else
}
}
// ── Leaderboard ───────────────────────────────────────────────────────────
private async Task ToggleLeaderboardHideAsync()
{
if (_account == null) return;
_account.IsHiddenFromLeaderboard = !_account.IsHiddenFromLeaderboard;
var result = await UserManager.UpdateAsync(_account);
if (result.Succeeded)
{
_message = _account.IsHiddenFromLeaderboard
? "Account hidden from leaderboard."
: "Account restored to leaderboard.";
_isError = false;
}
else
{
_message = string.Join(" ", result.Errors.Select(e => e.Description));
_isError = true;
}
}
// ── Account Properties ─────────────────────────────────────────────────────
private void StartEditProp(AccountProperty prop)
@@ -371,6 +371,72 @@
@onclick="() => { ab.Actions.Add(new ActionDraft()); Compile(); }">
<i class="bi bi-plus-lg me-1"></i>Add Action
</button>
<!-- Animation & Sound -->
<hr class="my-3" />
<div class="d-flex align-items-center gap-2 mb-2">
<h6 class="text-muted small mb-0">Animation &amp; Sound</h6>
<div class="form-check form-switch mb-0">
<input class="form-check-input" type="checkbox" role="switch"
id="hasAnim_@idx"
@bind="ab.HasAnimation" @bind:after="Compile" />
<label class="form-check-label small" for="hasAnim_@idx">Enable</label>
</div>
</div>
@if (ab.HasAnimation)
{
<div class="row g-2 mb-2">
<div class="col-md-3">
<label class="form-label small">Type</label>
<select class="form-select form-select-sm" @bind="ab.AnimationType" @bind:after="Compile">
@foreach (var t in AnimationTypes)
{ <option value="@t">@t</option> }
</select>
</div>
<div class="col-md-3">
<label class="form-label small">Effect</label>
<select class="form-select form-select-sm" @bind="ab.AnimationEffect" @bind:after="Compile">
@foreach (var e in AnimationEffects)
{ <option value="@e">@e</option> }
</select>
</div>
<div class="col-md-2">
<label class="form-label small">Width</label>
<input type="number" step="0.1" class="form-control form-control-sm"
@bind="ab.AnimationWidth" @bind:after="Compile" />
</div>
<div class="col-md-2">
<label class="form-label small">Height</label>
<input type="number" step="0.1" class="form-control form-control-sm"
@bind="ab.AnimationHeight" @bind:after="Compile" />
</div>
<div class="col-md-2">
<label class="form-label small">Duration (s)</label>
<input type="number" step="0.1" class="form-control form-control-sm"
@bind="ab.AnimationDuration" @bind:after="Compile" />
</div>
</div>
<div class="row g-2 mb-2">
<div class="col-12">
<label class="form-label small">Asset URL</label>
<input class="form-control form-control-sm" @bind="ab.AnimationAssetUrl" @bind:after="Compile"
placeholder="https://cdn.sor.gg/fx/…" />
</div>
</div>
<div class="row g-2">
<div class="col-md-6">
<label class="form-label small">Cast Sound URL</label>
<input class="form-control form-control-sm" @bind="ab.CastSoundUrl" @bind:after="Compile"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
<div class="col-md-6">
<label class="form-label small">Impact Sound URL</label>
<input class="form-control form-control-sm" @bind="ab.ImpactSoundUrl" @bind:after="Compile"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
</div>
}
</div>
</div>
}
@@ -442,6 +508,9 @@
private static readonly string[] ControllerValues = ["Owner", "Opponent"];
private static readonly string[] ZoneValues = ["Hand", "Deck", "Discard", "Battlefield"];
private static readonly string[] AnimationTypes = ["Projectile", "LinearProjectile", "ArcProjectile", "Aura"];
private static readonly string[] AnimationEffects = ["Self", "Target", "Some", "All"];
private static readonly string[] CostTypes = [
"SpiritPoints", "SacrificeTokens", "DiscardFromHand", "MillTopOfDeck",
"MillBottomOfDeck", "SendSpiritFromBattlefieldToDiscard",
@@ -647,6 +716,19 @@
ab.Actions.Add(act);
}
if (node["Animation"] is JsonObject anim)
{
ab.HasAnimation = true;
ab.AnimationType = anim["Type"]?.GetValue<string>() ?? "Projectile";
ab.AnimationEffect = anim["Effect"]?.GetValue<string>() ?? "Target";
ab.AnimationAssetUrl = anim["AssetUrl"]?.GetValue<string>() ?? "";
ab.AnimationWidth = anim["Width"]?.GetValue<float>() ?? 1f;
ab.AnimationHeight = anim["Height"]?.GetValue<float>() ?? 1f;
ab.AnimationDuration = anim["Duration"]?.GetValue<float>() ?? 1f;
ab.CastSoundUrl = anim["CastSoundUrl"]?.GetValue<string>() ?? "";
ab.ImpactSoundUrl = anim["ImpactSoundUrl"]?.GetValue<string>() ?? "";
}
_abilities.Add(ab);
}
@@ -900,6 +982,26 @@
}
node["Actions"] = actionsArr;
if (ab.HasAnimation)
{
var animNode = new JsonObject
{
["Type"] = ab.AnimationType,
["Effect"] = ab.AnimationEffect,
["Width"] = ab.AnimationWidth,
["Height"] = ab.AnimationHeight,
["Duration"] = ab.AnimationDuration,
};
if (!string.IsNullOrWhiteSpace(ab.AnimationAssetUrl))
animNode["AssetUrl"] = ab.AnimationAssetUrl;
if (!string.IsNullOrWhiteSpace(ab.CastSoundUrl))
animNode["CastSoundUrl"] = ab.CastSoundUrl;
if (!string.IsNullOrWhiteSpace(ab.ImpactSoundUrl))
animNode["ImpactSoundUrl"] = ab.ImpactSoundUrl;
node["Animation"] = animNode;
}
arr.Add(node);
}
@@ -1474,6 +1576,17 @@
public List<CostDraft> Costs { get; set; } = new();
public List<ConditionDraft> Conditions { get; set; } = new();
public List<ActionDraft> Actions { get; set; } = new();
// Animation & Sound (client-side metadata only)
public bool HasAnimation { get; set; } = false;
public string AnimationType { get; set; } = "Projectile";
public string AnimationEffect { get; set; } = "Target";
public string AnimationAssetUrl { get; set; } = "";
public float AnimationWidth { get; set; } = 1f;
public float AnimationHeight { get; set; } = 1f;
public float AnimationDuration { get; set; } = 1f;
public string CastSoundUrl { get; set; } = "";
public string ImpactSoundUrl { get; set; } = "";
}
private sealed class ActionDraft
@@ -323,19 +323,27 @@ else
<h6 class="text-muted mb-3">Animation Bindings</h6>
<table class="table table-sm">
<thead><tr><th>Action</th><th>CDN URL</th><th>AI</th><th>Upload</th><th></th></tr></thead>
<thead><tr><th>Action</th><th>Animation CDN URL</th><th>Cast Sound URL</th><th>Impact Sound URL</th><th>AI</th><th>Upload</th><th></th></tr></thead>
<tbody>
@foreach (var anim in _card.AnimationBindings)
{
var capturedAnim = anim;
<tr>
<td style="width:160px">
<td style="width:130px">
<input @bind="anim.ActionName" class="form-control form-control-sm"
placeholder="e.g. attack" />
</td>
<td>
<input @bind="anim.AnimationCdnUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/…" />
placeholder="https://cdn.sor.gg/anims/…" />
</td>
<td>
<input @bind="anim.CastSoundCdnUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</td>
<td>
<input @bind="anim.ImpactSoundCdnUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</td>
<td style="width:50px" class="text-center align-middle">
<div class="form-check d-flex justify-content-center">
@@ -0,0 +1,202 @@
@page "/content/audio"
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
@using Microsoft.EntityFrameworkCore
@using SOR.Database.Contexts
@using SOR.Database.Entities.Catalog
@inject CatalogDbContext Db
<PageTitle>Audio Config – SOR Admin</PageTitle>
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="mb-0">Background Music</h1>
<div class="text-muted small">Configure BGM tracks served to clients per game context</div>
</div>
<button class="btn btn-outline-secondary btn-sm" @onclick="LoadAsync" disabled="@_loading">
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
</button>
</div>
@if (_message is not null)
{
<div class="alert @(_isError ? "alert-danger" : "alert-success") alert-dismissible">
@_message
<button type="button" class="btn-close" @onclick="() => _message = null"></button>
</div>
}
<div class="card shadow-sm mb-4">
<div class="card-header fw-medium">Tracks</div>
<div class="card-body p-0">
@if (_loading)
{
<p class="p-3 text-muted">Loading…</p>
}
else if (_tracks.Count == 0)
{
<p class="p-3 text-muted fst-italic">No tracks configured. Add one below.</p>
}
else
{
<table class="table table-sm table-hover mb-0">
<thead>
<tr>
<th>Context</th>
<th>Track Name</th>
<th>CDN URL</th>
<th style="width:80px" class="text-center">Active</th>
<th style="width:80px"></th>
</tr>
</thead>
<tbody>
@foreach (var t in _tracks.OrderBy(t => t.Context).ThenBy(t => t.TrackName))
{
var track = t;
<tr class="@(track.IsActive ? "" : "opacity-50")">
<td class="align-middle">
<input @bind="track.Context" class="form-control form-control-sm"
placeholder="e.g. Game" style="width:140px" />
</td>
<td class="align-middle">
<input @bind="track.TrackName" class="form-control form-control-sm"
placeholder="e.g. Battle Theme 1" />
</td>
<td class="align-middle">
<input @bind="track.TrackCdnUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/music/…" />
</td>
<td class="text-center align-middle">
<div class="form-check d-flex justify-content-center">
<input @bind="track.IsActive" type="checkbox" class="form-check-input" />
</div>
</td>
<td class="align-middle">
<button class="btn btn-sm btn-outline-primary me-1" @onclick="() => SaveTrackAsync(track)">
<i class="bi bi-floppy"></i>
</button>
<button class="btn btn-sm btn-outline-danger" @onclick="() => DeleteTrackAsync(track)">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
<div class="card shadow-sm">
<div class="card-header fw-medium">Add Track</div>
<div class="card-body">
<div class="row g-2 align-items-end">
<div class="col-md-2">
<label class="form-label small">Context</label>
<input @bind="_newContext" class="form-control form-control-sm"
placeholder="Lobby" list="context-suggestions" />
<datalist id="context-suggestions">
<option value="Lobby" />
<option value="Game" />
<option value="Matchmaking" />
<option value="CharacterSelect" />
<option value="Victory" />
</datalist>
</div>
<div class="col-md-3">
<label class="form-label small">Track Name</label>
<input @bind="_newTrackName" class="form-control form-control-sm"
placeholder="e.g. Main Theme" />
</div>
<div class="col-md-5">
<label class="form-label small">CDN URL</label>
<input @bind="_newCdnUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/music/…" />
</div>
<div class="col-md-2">
<button class="btn btn-primary btn-sm w-100"
@onclick="AddTrackAsync"
disabled="@(string.IsNullOrWhiteSpace(_newContext) || string.IsNullOrWhiteSpace(_newTrackName) || string.IsNullOrWhiteSpace(_newCdnUrl))">
<i class="bi bi-plus-lg me-1"></i>Add
</button>
</div>
</div>
</div>
</div>
@code {
private List<GameAudioConfig> _tracks = new();
private bool _loading;
private string? _message;
private bool _isError;
private string _newContext = "";
private string _newTrackName = "";
private string _newCdnUrl = "";
protected override async Task OnInitializedAsync() => await LoadAsync();
private async Task LoadAsync()
{
_loading = true;
_tracks = await Db.AudioConfigs.OrderBy(t => t.Context).ToListAsync();
_loading = false;
}
private async Task SaveTrackAsync(GameAudioConfig track)
{
try
{
await Db.SaveChangesAsync();
_message = $"Track \"{track.TrackName}\" saved.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Save failed: {ex.Message}";
_isError = true;
}
}
private async Task DeleteTrackAsync(GameAudioConfig track)
{
Db.AudioConfigs.Remove(track);
try
{
await Db.SaveChangesAsync();
_tracks.Remove(track);
_message = $"Track \"{track.TrackName}\" deleted.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Delete failed: {ex.Message}";
_isError = true;
}
}
private async Task AddTrackAsync()
{
var track = new GameAudioConfig
{
Id = Guid.NewGuid(),
Context = _newContext.Trim(),
TrackName = _newTrackName.Trim(),
TrackCdnUrl = _newCdnUrl.Trim(),
IsActive = true,
};
Db.AudioConfigs.Add(track);
try
{
await Db.SaveChangesAsync();
_tracks.Add(track);
_newContext = _newTrackName = _newCdnUrl = "";
_message = $"Track \"{track.TrackName}\" added.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Add failed: {ex.Message}";
_isError = true;
}
}
}