Feature: card unit SFX + genus multi-select + CardEditor UX fixes

- CardDefinition: add MoveSoundUrl, DamagedSoundUrl, BlockedSoundUrl,
  AttackSoundUrl, DeathSoundUrl columns (nullable text)
- Migration 20260317100000_AddCardUnitSounds: 5 new columns on card_definitions
- CardDefinitionDto + ContentDtoMapper: expose 5 SFX fields to client
- CardEditor:
  - Genus: replace plain text input with DB-backed checkbox multi-select
    (loads distinct tags from all cards; add new tags inline)
  - Channel range (Min/Max): now ArchSpirit-only (removed from Spirit)
  - CanUseAbility / RequiresLos: default true for display & new cards
  - Assets tab: Unit Sound Effects section (5 CDN URL inputs)
  - model-viewer script injected lazily so 3D preview renders

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-17 09:36:18 -04:00
co-authored by Claude Happy
parent 3ba33275e3
commit c105120dc6
7 changed files with 765 additions and 23 deletions
@@ -126,17 +126,17 @@ else
@if (_card.CardType is CardType.ArchSpirit or CardType.Spirit)
{
<div class="row g-3">
<div class="col-12"><h6 class="text-muted">Channeling</h6></div>
<div class="col-md-3">
<label class="form-label">Min Channel Range</label>
<input @bind="_card.MinChannelRange" type="number" min="0" class="form-control" />
</div>
<div class="col-md-3">
<label class="form-label">Max Channel Range</label>
<input @bind="_card.MaxChannelRange" type="number" min="0" class="form-control" />
</div>
@if (_card.CardType == CardType.ArchSpirit)
{
<div class="col-12"><h6 class="text-muted">Channeling</h6></div>
<div class="col-md-3">
<label class="form-label">Min Channel Range</label>
<input @bind="_card.MinChannelRange" type="number" min="0" class="form-control" />
</div>
<div class="col-md-3">
<label class="form-label">Max Channel Range</label>
<input @bind="_card.MaxChannelRange" type="number" min="0" class="form-control" />
</div>
<div class="col-md-2">
<label class="form-label">Tier</label>
<input @bind="_card.Tier" type="number" min="1" max="5" class="form-control" />
@@ -207,9 +207,33 @@ else
<div class="col-12"><h6 class="text-muted mt-2">Genus Tags</h6></div>
<div class="col-md-6">
<input @bind="_genusInput" class="form-control"
placeholder="Comma-separated tags, e.g. Elemental, Beast" />
<div class="form-text">Stored as a Postgres text[] array.</div>
@if (_availableGenus.Count > 0)
{
<div class="border rounded p-2 mb-1" style="max-height:160px;overflow-y:auto">
@foreach (var tag in _availableGenus)
{
var capturedTag = tag;
<div class="form-check">
<input type="checkbox" class="form-check-input"
id="genus_@capturedTag"
checked="@_selectedGenus.Contains(capturedTag)"
@onchange="e => ToggleGenus(capturedTag, (bool)(e.Value ?? false))" />
<label class="form-check-label" for="genus_@capturedTag">@capturedTag</label>
</div>
}
</div>
}
<div class="input-group input-group-sm">
<input @bind="_newGenusTag" class="form-control"
placeholder="Add new genus tag…" />
<button class="btn btn-outline-secondary" type="button" @onclick="AddGenusTag">
<i class="bi bi-plus-lg"></i>
</button>
</div>
@if (_selectedGenus.Count > 0)
{
<div class="form-text">Selected: @string.Join(", ", _selectedGenus)</div>
}
</div>
</div>
}
@@ -491,6 +515,35 @@ else
<button class="btn btn-sm btn-outline-secondary" @onclick="AddAnimation">
<i class="bi bi-plus-lg me-1"></i>Add Animation
</button>
<h6 class="text-muted mb-3 mt-4">Unit Sound Effects</h6>
<div class="row g-3">
<div class="col-md-4">
<label class="form-label">Move Sound URL</label>
<input @bind="_card.MoveSoundUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
<div class="col-md-4">
<label class="form-label">Damaged Sound URL</label>
<input @bind="_card.DamagedSoundUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
<div class="col-md-4">
<label class="form-label">Blocked Sound URL</label>
<input @bind="_card.BlockedSoundUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
<div class="col-md-4">
<label class="form-label">Attack Sound URL</label>
<input @bind="_card.AttackSoundUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
<div class="col-md-4">
<label class="form-label">Death Sound URL</label>
<input @bind="_card.DeathSoundUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/sfx/…" />
</div>
</div>
}
}
@@ -569,6 +622,17 @@ else
</div>
}
<!-- model-viewer web component (guard: only load once per page) -->
<script>
if (!window.__modelViewerLoaded) {
window.__modelViewerLoaded = true;
var s = document.createElement('script');
s.type = 'module';
s.src = 'https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js';
document.head.appendChild(s);
}
</script>
<!-- JS: model-viewer animation interop (guard prevents double-define if CdnBrowser also loaded it) -->
<script>
(function () {
@@ -600,7 +664,9 @@ else
private bool _saving;
private string? _saveError;
private bool _saveSuccess;
private string _genusInput = string.Empty;
private List<string> _selectedGenus = new();
private List<string> _availableGenus = new();
private string _newGenusTag = string.Empty;
private string _abilitiesJson = string.Empty;
private readonly HashSet<Guid> _uploading = new();
private string? _uploadError;
@@ -755,12 +821,25 @@ else
{
_isNew = Id == null;
// Load all distinct genus tags from the DB for the multi-select.
var allGenusArrays = await Db.CardDefinitions
.Where(c => c.Genus != null)
.Select(c => c.Genus!)
.ToListAsync();
_availableGenus = allGenusArrays
.SelectMany(g => g)
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(g => g)
.ToList();
if (_isNew)
{
_card = new CardDefinition
{
CreatedAt = DateTimeOffset.UtcNow,
UpdatedAt = DateTimeOffset.UtcNow,
CreatedAt = DateTimeOffset.UtcNow,
UpdatedAt = DateTimeOffset.UtcNow,
CanUseAbility = true,
RequiresLos = true,
};
}
else
@@ -772,9 +851,12 @@ else
if (_card != null)
{
_genusInput = _card.Genus != null
? string.Join(", ", _card.Genus)
: string.Empty;
_selectedGenus = _card.Genus?.ToList() ?? new List<string>();
// Ensure any card-specific tags appear in the available list.
foreach (var tag in _selectedGenus)
if (!_availableGenus.Contains(tag, StringComparer.OrdinalIgnoreCase))
_availableGenus.Add(tag);
_availableGenus.Sort(StringComparer.OrdinalIgnoreCase);
_abilitiesJson = _card.CardType is CardType.Repentance
or CardType.Instinct or CardType.Terramorpha
@@ -795,9 +877,7 @@ else
try
{
_card.Genus = string.IsNullOrWhiteSpace(_genusInput)
? null
: _genusInput.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
_card.Genus = _selectedGenus.Count > 0 ? _selectedGenus.ToArray() : null;
if (_card.CardType is CardType.Repentance or CardType.Instinct or CardType.Terramorpha)
_card.EffectsJson = string.IsNullOrWhiteSpace(_abilitiesJson) ? null : _abilitiesJson;
@@ -945,6 +1025,28 @@ else
_ => "*/*",
};
// ── Genus helpers ─────────────────────────────────────────────────────────
private void ToggleGenus(string tag, bool selected)
{
if (selected) { if (!_selectedGenus.Contains(tag)) _selectedGenus.Add(tag); }
else _selectedGenus.Remove(tag);
}
private void AddGenusTag()
{
var tag = _newGenusTag.Trim();
if (string.IsNullOrEmpty(tag)) return;
if (!_availableGenus.Contains(tag, StringComparer.OrdinalIgnoreCase))
{
_availableGenus.Add(tag);
_availableGenus.Sort(StringComparer.OrdinalIgnoreCase);
}
if (!_selectedGenus.Contains(tag, StringComparer.OrdinalIgnoreCase))
_selectedGenus.Add(tag);
_newGenusTag = string.Empty;
}
// ── Flag descriptors ──────────────────────────────────────────────────────
private sealed record FlagDescriptor(
@@ -960,8 +1062,8 @@ else
new("Can Be Blocked", c => c.CanBeBlocked ?? false, (c, v) => c.CanBeBlocked = v),
new("Can Move", c => c.CanMove ?? false, (c, v) => c.CanMove = v),
new("Can Be Obstructed", c => c.CanBeObstructed ?? false, (c, v) => c.CanBeObstructed = v),
new("Requires LOS", c => c.RequiresLos ?? false, (c, v) => c.RequiresLos = v),
new("Can Use Ability", c => c.CanUseAbility ?? false, (c, v) => c.CanUseAbility = v),
new("Requires LOS", c => c.RequiresLos ?? true, (c, v) => c.RequiresLos = v),
new("Can Use Ability", c => c.CanUseAbility ?? true, (c, v) => c.CanUseAbility = v),
new("Can Be Sacrificed", c => c.CanBeSacrificed ?? false, (c, v) => c.CanBeSacrificed = v),
];
}