298 lines
11 KiB
Plaintext
298 lines
11 KiB
Plaintext
@page "/cards"
|
|
|
|
<PageTitle>Card Gallery</PageTitle>
|
|
|
|
<div class="gallery-container">
|
|
<div class="gallery-header">
|
|
<h1>Card Gallery</h1>
|
|
<p class="text-secondary">Browse all @allCards.Count cards</p>
|
|
</div>
|
|
|
|
<div class="category-tabs">
|
|
<button class="tab @(categoryFilter == "" ? "active" : "")" @onclick='@(() => SetCategory(""))'>
|
|
<i class="bi bi-grid-3x3-gap-fill"></i> All
|
|
</button>
|
|
<button class="tab agent @(categoryFilter == "Agent" ? "active" : "")" @onclick='@(() => SetCategory("Agent"))'>
|
|
<i class="bi bi-person-fill"></i> Agents
|
|
</button>
|
|
<button class="tab spell @(categoryFilter == "Spell" ? "active" : "")" @onclick='@(() => SetCategory("Spell"))'>
|
|
<i class="bi bi-wand"></i> Spells
|
|
</button>
|
|
<button class="tab token @(categoryFilter == "Token" ? "active" : "")" @onclick='@(() => SetCategory("Token"))'>
|
|
<i class="bi bi-coin"></i> Tokens
|
|
</button>
|
|
</div>
|
|
|
|
<div class="filter-bar">
|
|
<div class="search-wrapper">
|
|
<i class="bi bi-search search-icon"></i>
|
|
<input @bind="search" @bind:event="oninput" class="form-control search-input"
|
|
placeholder="Search cards by name or description..."/>
|
|
@if (search.Length > 0)
|
|
{
|
|
<button class="search-clear" @onclick="ClearSearch"><i class="bi bi-x-lg"></i></button>
|
|
}
|
|
</div>
|
|
<select @bind="factionFilter" class="form-select filter-select">
|
|
<option value="">All Factions</option>
|
|
@foreach (var f in factions)
|
|
{
|
|
<option value="@f">@f</option>
|
|
}
|
|
</select>
|
|
<select @bind="costFilter" class="form-select filter-select">
|
|
<option value="">All Costs</option>
|
|
@for (var i = 0; i <= 12; i++)
|
|
{
|
|
<option value="@i">@i</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
@if (HasActiveFilters)
|
|
{
|
|
<div class="active-filters">
|
|
<span class="filter-label">Filters:</span>
|
|
@if (categoryFilter != "")
|
|
{
|
|
<span class="filter-chip">
|
|
<i class="bi bi-tag-fill"></i> @categoryFilter
|
|
<button @onclick="ClearCategoryFilter"><i class="bi bi-x"></i></button>
|
|
</span>
|
|
}
|
|
@if (factionFilter != "")
|
|
{
|
|
<span class="filter-chip">
|
|
<i class="bi bi-flag-fill"></i> @factionFilter
|
|
<button @onclick="ClearFactionFilter"><i class="bi bi-x"></i></button>
|
|
</span>
|
|
}
|
|
@if (costFilter != "")
|
|
{
|
|
<span class="filter-chip">
|
|
<i class="bi bi-lightning-fill"></i> Cost @costFilter
|
|
<button @onclick="ClearCostFilter"><i class="bi bi-x"></i></button>
|
|
</span>
|
|
}
|
|
<button class="clear-all" @onclick="ClearFilters">Clear all</button>
|
|
</div>
|
|
}
|
|
|
|
<div class="result-count">
|
|
<span>@filteredCards.Count() card@(filteredCards.Count() != 1 ? "s" : "") found</span>
|
|
@if (HasActiveFilters || search != "")
|
|
{
|
|
<span class="text-muted">out of @allCards.Count total</span>
|
|
}
|
|
</div>
|
|
|
|
@if (filteredCards.Any())
|
|
{
|
|
<div class="card-grid">
|
|
@{ var idx = 0; }
|
|
@foreach (var card in filteredCards)
|
|
{
|
|
<div class="card-cell @(selectedCard == card ? "selected" : "")"
|
|
style="--i: @idx"
|
|
@onclick="() => SelectCard(card)">
|
|
<div class="card-image-wrapper">
|
|
<div class="card-shimmer"></div>
|
|
<img src="@card.ImagePath" alt="@card.Name" loading="lazy"
|
|
onerror="this.src='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%22200%22 height=%22280%22><rect fill=%22%23222244%22 width=%22200%22 height=%22280%22/><text fill=%22%23686888%22 font-size=%2214%22 x=%22100%22 y=%22140%22 text-anchor=%22middle%22 dominant-baseline=%22middle%22>No Image</text></svg>'"/>
|
|
@if (card.Cost.HasValue)
|
|
{
|
|
<div class="card-cost-badge">@card.Cost</div>
|
|
}
|
|
@if (card.HasImmortalize)
|
|
{
|
|
<div class="card-immortalize-badge" title="Immortalizes"><i class="bi bi-star-fill"></i>
|
|
</div>
|
|
}
|
|
</div>
|
|
<div class="card-label">
|
|
<div class="card-name">@card.Name</div>
|
|
<div class="card-category-badge @card.Category?.ToLowerInvariant()">@card.Category</div>
|
|
</div>
|
|
</div>
|
|
idx++;
|
|
}
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div class="empty-state">
|
|
<i class="bi bi-search"></i>
|
|
<p>No cards match your filters.</p>
|
|
<button class="btn btn-outline-secondary" @onclick="ClearFilters">Reset Filters</button>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@if (selectedCard != null)
|
|
{
|
|
<div class="modal-backdrop" @onclick="CloseDetail"></div>
|
|
<div class="card-detail">
|
|
<button class="detail-close" @onclick="CloseDetail"><i class="bi bi-x-lg"></i></button>
|
|
<div class="detail-layout">
|
|
<div class="detail-image">
|
|
<img src="@selectedCard.ImagePath" alt="@selectedCard.Name"/>
|
|
</div>
|
|
<div class="detail-info">
|
|
<div class="detail-header">
|
|
<h2>@selectedCard.Name</h2>
|
|
<div class="detail-meta">
|
|
<span
|
|
class="meta-badge category @selectedCard.Category?.ToLowerInvariant()">@selectedCard.Category</span>
|
|
@if (selectedCard.Cost.HasValue)
|
|
{
|
|
<span class="meta-badge cost"><i class="bi bi-lightning-fill"></i> @selectedCard.Cost</span>
|
|
}
|
|
@if (selectedCard.Attack.HasValue)
|
|
{
|
|
<span class="meta-badge attack"><i class="bi bi-crosshair"></i> @selectedCard.Attack</span>
|
|
}
|
|
@if (selectedCard.Health.HasValue)
|
|
{
|
|
<span class="meta-badge health"><i class="bi bi-heart-fill"></i> @selectedCard.Health</span>
|
|
}
|
|
@if (selectedCard.Speed != null)
|
|
{
|
|
<span class="meta-badge speed"><i class="bi bi-wind"></i> @selectedCard.Speed</span>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
@if (selectedCard.Faction != null)
|
|
{
|
|
<div class="detail-field">
|
|
<span class="field-label"><i class="bi bi-flag-fill"></i> Faction</span>
|
|
<span class="field-value">@selectedCard.Faction</span>
|
|
</div>
|
|
}
|
|
@if (selectedCard.Description != null)
|
|
{
|
|
<div class="detail-field description">
|
|
<span class="field-label"><i class="bi bi-chat-quote-fill"></i></span>
|
|
<span class="field-value">@selectedCard.Description</span>
|
|
</div>
|
|
}
|
|
@if (selectedCard.Set != null)
|
|
{
|
|
<div class="detail-field">
|
|
<span class="field-label"><i class="bi bi-collection"></i> Set</span>
|
|
<span class="field-value">@selectedCard.Set</span>
|
|
</div>
|
|
}
|
|
@if (selectedCard.Archetypes is { Count: > 0 })
|
|
{
|
|
<div class="detail-field">
|
|
<span class="field-label"><i class="bi bi-layers-fill"></i> Archetypes</span>
|
|
<span class="field-value">@string.Join(", ", selectedCard.Archetypes)</span>
|
|
</div>
|
|
}
|
|
@if (selectedCard.ImmortalizeWhen != null)
|
|
{
|
|
<div class="detail-field">
|
|
<span class="field-label"><i class="bi bi-star-fill"></i> Immortalize When</span>
|
|
<span class="field-value">@selectedCard.ImmortalizeWhen</span>
|
|
</div>
|
|
}
|
|
@if (selectedCard.HasImmortalize)
|
|
{
|
|
<div class="detail-field">
|
|
<span class="field-label"><i class="bi bi-arrow-right-circle-fill"></i> Immortalizes To</span>
|
|
<span class="field-value">@string.Join(", ", selectedCard.ImmortalizeTo!)</span>
|
|
</div>
|
|
}
|
|
@if (selectedCard.ImmortalizeFrom != null)
|
|
{
|
|
<div class="detail-field">
|
|
<span class="field-label"><i class="bi bi-arrow-left-circle-fill"></i> Immortalizes From</span>
|
|
<span class="field-value">@selectedCard.ImmortalizeFrom</span>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
private List<CardData> allCards = [];
|
|
private IEnumerable<CardData> filteredCards => ApplyFilters();
|
|
private string search = "";
|
|
private string categoryFilter = "";
|
|
private string factionFilter = "";
|
|
private string costFilter = "";
|
|
private CardData? selectedCard;
|
|
private List<string> factions = [];
|
|
|
|
private bool HasActiveFilters => categoryFilter != "" || factionFilter != "" || costFilter != "";
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
allCards = CardDatabase.Cards;
|
|
factions = allCards
|
|
.Select(c => c.Faction)
|
|
.Where(f => f != null)
|
|
.Distinct()
|
|
.OrderBy(f => f)
|
|
.ToList()!;
|
|
}
|
|
|
|
private IEnumerable<CardData> ApplyFilters()
|
|
{
|
|
var q = search?.Trim().ToLowerInvariant() ?? "";
|
|
return allCards.Where(c =>
|
|
(q.Length == 0 || c.Name.ToLowerInvariant().Contains(q) ||
|
|
(c.Description?.ToLowerInvariant().Contains(q) ?? false)) &&
|
|
(categoryFilter == "" || c.Category == categoryFilter) &&
|
|
(factionFilter == "" || c.Faction == factionFilter) &&
|
|
(costFilter == "" || c.Cost?.ToString() == costFilter)
|
|
);
|
|
}
|
|
|
|
private void SetCategory(string cat)
|
|
{
|
|
categoryFilter = categoryFilter == cat ? "" : cat;
|
|
}
|
|
|
|
private void ClearCategoryFilter()
|
|
{
|
|
categoryFilter = "";
|
|
}
|
|
|
|
private void ClearFactionFilter()
|
|
{
|
|
factionFilter = "";
|
|
}
|
|
|
|
private void ClearCostFilter()
|
|
{
|
|
costFilter = "";
|
|
}
|
|
|
|
private void ClearSearch()
|
|
{
|
|
search = "";
|
|
}
|
|
|
|
private void SelectCard(CardData card)
|
|
{
|
|
selectedCard = card;
|
|
}
|
|
|
|
private void CloseDetail()
|
|
{
|
|
selectedCard = null;
|
|
}
|
|
|
|
private void ClearFilters()
|
|
{
|
|
search = "";
|
|
categoryFilter = "";
|
|
factionFilter = "";
|
|
costFilter = "";
|
|
}
|
|
|
|
}
|