Fix card report ability check and add description columns
- HasAbilities now uses JsonDocument to check array length > 0, so cards with an empty [] don't incorrectly show as having abilities. - Added Card Desc column/filter: whether the card's own Description field is non-empty. - Added Ability Desc column/filter: whether at least one ability in the JSON array has a non-empty description field. Shows — when card has no abilities. 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:
@@ -107,6 +107,24 @@
|
|||||||
<option value="no">No abilities</option>
|
<option value="no">No abilities</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<label class="form-label form-label-sm mb-1">Ability Desc</label>
|
||||||
|
<select @bind="_filterAbilityDesc" @bind:after="Filter" class="form-select form-select-sm">
|
||||||
|
<option value="">All</option>
|
||||||
|
<option value="yes">Has description</option>
|
||||||
|
<option value="no">Missing description</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<label class="form-label form-label-sm mb-1">Card Desc</label>
|
||||||
|
<select @bind="_filterCardDesc" @bind:after="Filter" class="form-select form-select-sm">
|
||||||
|
<option value="">All</option>
|
||||||
|
<option value="yes">Has description</option>
|
||||||
|
<option value="no">Missing description</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row g-2 align-items-end mt-1">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<label class="form-label form-label-sm mb-1">Sound Effects</label>
|
<label class="form-label form-label-sm mb-1">Sound Effects</label>
|
||||||
<select @bind="_filterSfx" @bind:after="Filter" class="form-select form-select-sm">
|
<select @bind="_filterSfx" @bind:after="Filter" class="form-select form-select-sm">
|
||||||
@@ -151,7 +169,9 @@
|
|||||||
<th>Published</th>
|
<th>Published</th>
|
||||||
<th style="white-space:nowrap">3D Model</th>
|
<th style="white-space:nowrap">3D Model</th>
|
||||||
<th style="white-space:nowrap">2D Art</th>
|
<th style="white-space:nowrap">2D Art</th>
|
||||||
|
<th>Card Desc</th>
|
||||||
<th>Abilities</th>
|
<th>Abilities</th>
|
||||||
|
<th style="white-space:nowrap">Ability Desc</th>
|
||||||
<th>SFX</th>
|
<th>SFX</th>
|
||||||
<th>Prebuilt Decks</th>
|
<th>Prebuilt Decks</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -210,6 +230,16 @@
|
|||||||
<span class="text-danger">✗</span>
|
<span class="text-danger">✗</span>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@if (row.HasCardDescription)
|
||||||
|
{
|
||||||
|
<span class="text-success">✓</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="text-danger">✗</span>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (row.HasAbilities)
|
@if (row.HasAbilities)
|
||||||
{
|
{
|
||||||
@@ -220,6 +250,20 @@
|
|||||||
<span class="text-danger">✗</span>
|
<span class="text-danger">✗</span>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@if (!row.HasAbilities)
|
||||||
|
{
|
||||||
|
<span class="text-muted">—</span>
|
||||||
|
}
|
||||||
|
else if (row.AbilitiesHaveDescriptions)
|
||||||
|
{
|
||||||
|
<span class="text-success">✓</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="text-danger">✗</span>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (row.HasSfx)
|
@if (row.HasSfx)
|
||||||
{
|
{
|
||||||
@@ -263,7 +307,9 @@
|
|||||||
bool Has3dModel,
|
bool Has3dModel,
|
||||||
bool ModelAiGenerated,
|
bool ModelAiGenerated,
|
||||||
bool Has2dArt,
|
bool Has2dArt,
|
||||||
|
bool HasCardDescription,
|
||||||
bool HasAbilities,
|
bool HasAbilities,
|
||||||
|
bool AbilitiesHaveDescriptions,
|
||||||
bool HasSfx,
|
bool HasSfx,
|
||||||
IReadOnlyList<(Guid Id, string Name)> InDecks);
|
IReadOnlyList<(Guid Id, string Name)> InDecks);
|
||||||
|
|
||||||
@@ -280,9 +326,11 @@
|
|||||||
private string _filter3dModel = string.Empty;
|
private string _filter3dModel = string.Empty;
|
||||||
private string _filterAiModel = string.Empty;
|
private string _filterAiModel = string.Empty;
|
||||||
private string _filter2dArt = string.Empty;
|
private string _filter2dArt = string.Empty;
|
||||||
private string _filterAbilities = string.Empty;
|
private string _filterAbilities = string.Empty;
|
||||||
private string _filterSfx = string.Empty;
|
private string _filterAbilityDesc = string.Empty;
|
||||||
private string _filterInDeck = string.Empty;
|
private string _filterCardDesc = string.Empty;
|
||||||
|
private string _filterSfx = string.Empty;
|
||||||
|
private string _filterInDeck = string.Empty;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -314,20 +362,23 @@
|
|||||||
|
|
||||||
_rows = cards.Select(c =>
|
_rows = cards.Select(c =>
|
||||||
{
|
{
|
||||||
var model = c.Assets.Where(a => a.AssetType == CardAssetType.Model3D).ToList();
|
var model = c.Assets.Where(a => a.AssetType == CardAssetType.Model3D).ToList();
|
||||||
var art = c.Assets.Where(a => a.AssetType == CardAssetType.Art2D).ToList();
|
var art = c.Assets.Where(a => a.AssetType == CardAssetType.Art2D).ToList();
|
||||||
var hasSfx = c.MoveSoundUrl != null || c.DamagedSoundUrl != null
|
var hasSfx = c.MoveSoundUrl != null || c.DamagedSoundUrl != null
|
||||||
|| c.BlockedSoundUrl != null || c.AttackSoundUrl != null || c.DeathSoundUrl != null;
|
|| c.BlockedSoundUrl != null || c.AttackSoundUrl != null || c.DeathSoundUrl != null;
|
||||||
var hasAbilities = !string.IsNullOrEmpty(c.AbilitiesJson) || !string.IsNullOrEmpty(c.EffectsJson);
|
var abilityJson = c.AbilitiesJson ?? c.EffectsJson;
|
||||||
|
var hasAbilities = JsonArrayHasElements(abilityJson);
|
||||||
cardToDecks.TryGetValue(c.Id, out var decks);
|
cardToDecks.TryGetValue(c.Id, out var decks);
|
||||||
return new CardRow(
|
return new CardRow(
|
||||||
Card: c,
|
Card: c,
|
||||||
Has3dModel: model.Count > 0,
|
Has3dModel: model.Count > 0,
|
||||||
ModelAiGenerated: model.Any(a => a.IsAiGenerated),
|
ModelAiGenerated: model.Any(a => a.IsAiGenerated),
|
||||||
Has2dArt: art.Count > 0,
|
Has2dArt: art.Count > 0,
|
||||||
HasAbilities: hasAbilities,
|
HasCardDescription: !string.IsNullOrWhiteSpace(c.Description),
|
||||||
HasSfx: hasSfx,
|
HasAbilities: hasAbilities,
|
||||||
InDecks: (decks ?? new()).AsReadOnly());
|
AbilitiesHaveDescriptions: hasAbilities && JsonAbilitiesHaveDescriptions(abilityJson),
|
||||||
|
HasSfx: hasSfx,
|
||||||
|
InDecks: (decks ?? new()).AsReadOnly());
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
Filter();
|
Filter();
|
||||||
@@ -376,6 +427,12 @@
|
|||||||
if (_filterAbilities == "yes" && !row.HasAbilities) return false;
|
if (_filterAbilities == "yes" && !row.HasAbilities) return false;
|
||||||
if (_filterAbilities == "no" && row.HasAbilities) return false;
|
if (_filterAbilities == "no" && row.HasAbilities) return false;
|
||||||
|
|
||||||
|
if (_filterAbilityDesc == "yes" && (!row.HasAbilities || !row.AbilitiesHaveDescriptions)) return false;
|
||||||
|
if (_filterAbilityDesc == "no" && row.HasAbilities && row.AbilitiesHaveDescriptions) return false;
|
||||||
|
|
||||||
|
if (_filterCardDesc == "yes" && !row.HasCardDescription) return false;
|
||||||
|
if (_filterCardDesc == "no" && row.HasCardDescription) return false;
|
||||||
|
|
||||||
if (_filterSfx == "yes" && !row.HasSfx) return false;
|
if (_filterSfx == "yes" && !row.HasSfx) return false;
|
||||||
if (_filterSfx == "no" && row.HasSfx) return false;
|
if (_filterSfx == "no" && row.HasSfx) return false;
|
||||||
|
|
||||||
@@ -385,4 +442,37 @@
|
|||||||
return true;
|
return true;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Returns true if the JSON string is a non-empty array (not null, not [], not "null").</summary>
|
||||||
|
private static bool JsonArrayHasElements(string? json)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(json)) return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var doc = System.Text.Json.JsonDocument.Parse(json);
|
||||||
|
return doc.RootElement.ValueKind == System.Text.Json.JsonValueKind.Array
|
||||||
|
&& doc.RootElement.GetArrayLength() > 0;
|
||||||
|
}
|
||||||
|
catch { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Returns true if at least one ability in the JSON array has a non-empty description.</summary>
|
||||||
|
private static bool JsonAbilitiesHaveDescriptions(string? json)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(json)) return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var doc = System.Text.Json.JsonDocument.Parse(json);
|
||||||
|
if (doc.RootElement.ValueKind != System.Text.Json.JsonValueKind.Array) return false;
|
||||||
|
foreach (var elem in doc.RootElement.EnumerateArray())
|
||||||
|
{
|
||||||
|
if (elem.TryGetProperty("description", out var desc)
|
||||||
|
&& desc.ValueKind == System.Text.Json.JsonValueKind.String
|
||||||
|
&& !string.IsNullOrWhiteSpace(desc.GetString()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch { return false; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user