278 lines
10 KiB
Plaintext
278 lines
10 KiB
Plaintext
@page "/cards"
|
|
@inject HttpClient Http
|
|
|
|
<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 agent @(categoryFilter == "Immortalized" ? "active" : "")" @onclick='@(() => SetCategory("Immortalized"))'>
|
|
<i class="bi bi-person-fill"></i> Immortalized
|
|
</button>
|
|
<!-- //Todo make agent being linked to immortal for side by side sorting
|
|
<button class="tab agent @(agentLink ? "active" : "")" @onclick='@(() => ToggleAgentLink())'>
|
|
<i class="bi bi-person-fill"></i> Link
|
|
</button>
|
|
-->
|
|
<button class="tab spell @(categoryFilter == "Spell" ? "active" : "")" @onclick='@(() => SetCategory("Spell"))'>
|
|
<i class="bi bi-wand"></i> Spells
|
|
</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 <= 13; i++)
|
|
{
|
|
<option value="@i">@i</option>
|
|
}
|
|
</select>
|
|
<div class="sort-group d-flex gap-1">
|
|
<select @bind="sortBy" class="form-select filter-select sort-select">
|
|
<option value="Cost">Sort by Cost</option>
|
|
<option value="Name">Sort by Name</option>
|
|
<option value="Attack">Sort by Attack</option>
|
|
<option value="Health">Sort by Health</option>
|
|
<option value="Efficiency">Sort by Efficiency</option>
|
|
</select>
|
|
<button class="btn btn-outline-secondary sort-dir-btn" @onclick="() => sortDescending = !sortDescending"
|
|
title="@(sortDescending ? "Descending" : "Ascending")">
|
|
<i class="bi bi-sort-@(sortDescending ? "down" : "up")"></i>
|
|
</button>
|
|
</div>
|
|
<button class="btn @(showDetailedView ? "btn-primary" : "btn-outline-primary") view-toggle-btn"
|
|
@onclick="() => showDetailedView = !showDetailedView" title="Toggle Detailed View">
|
|
<i class="bi bi-list-ul"></i>
|
|
</button>
|
|
</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 @(showDetailedView ? "detailed-view" : "")">
|
|
@{ var idx = 0; }
|
|
@foreach (var card in filteredCards.Where(a=>a.Category is "Agent" or "Spell" or "Immortalized"))
|
|
{
|
|
<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.IsImmortalized)
|
|
{
|
|
<div class="card-immortalize-badge" title="Immortalizes"><i class="bi bi-star-fill"></i>
|
|
</div>
|
|
}
|
|
</div>
|
|
@if (showDetailedView)
|
|
{
|
|
<div class="card-label">
|
|
<div class="card-name">@card.Name</div>
|
|
<div class="card-stats">
|
|
@if (card.Attack.HasValue)
|
|
{
|
|
<span class="stat"><i class="bi bi-crosshair"></i> @card.Attack</span>
|
|
}
|
|
@if (card.Health.HasValue)
|
|
{
|
|
<span class="stat"><i class="bi bi-heart-fill"></i> @card.Health</span>
|
|
}
|
|
</div>
|
|
<div class="card-description-preview">@card.Description</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)
|
|
{
|
|
<CardDialog Card="selectedCard" OnClose="CloseDetail" OnNavigate="SelectCard" />
|
|
}
|
|
|
|
@code {
|
|
private List<CardData> allCards = [];
|
|
private IEnumerable<CardData> filteredCards => ApplyFilters();
|
|
private string search = "";
|
|
private string categoryFilter = "";
|
|
private string immortalFilter = "";
|
|
private bool agentLink = true;
|
|
private string factionFilter = "";
|
|
private string costFilter = "";
|
|
private string sortBy = "Cost";
|
|
private bool sortDescending;
|
|
private bool showDetailedView;
|
|
private CardData? selectedCard;
|
|
private List<string> factions = [];
|
|
|
|
private bool HasActiveFilters => categoryFilter != "" || factionFilter != "" || costFilter != "" || immortalFilter != "";
|
|
|
|
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 filtered = allCards.Where(c =>
|
|
c.MatchesSearch(search) &&
|
|
(categoryFilter == "" || c.Category == categoryFilter) &&
|
|
(factionFilter == "" || c.Faction == factionFilter) &&
|
|
(costFilter == "" || c.Cost?.ToString() == costFilter)
|
|
);
|
|
|
|
return sortBy switch
|
|
{
|
|
"Cost" => sortDescending ? filtered.OrderByDescending(c => c.Cost) : filtered.OrderBy(c => c.Cost),
|
|
"Efficiency" => sortDescending ? filtered.OrderByDescending(c => c.StatEfficiency) : filtered.OrderBy(c => c.StatEfficiency),
|
|
"Attack" => sortDescending ? filtered.OrderByDescending(c => c.Attack) : filtered.OrderBy(c => c.Attack),
|
|
"Health" => sortDescending ? filtered.OrderByDescending(c => c.Health) : filtered.OrderBy(c => c.Health),
|
|
_ => sortDescending ? filtered.OrderByDescending(c => c.Name) : filtered.OrderBy(c => c.Name)
|
|
};
|
|
}
|
|
|
|
private void SetImmortal(string imm)
|
|
{
|
|
immortalFilter = immortalFilter == imm ? "" : imm;
|
|
}
|
|
|
|
private void ClearImmortalFilter()
|
|
{
|
|
immortalFilter = "";
|
|
}
|
|
|
|
private void SetCategory(string cat)
|
|
{
|
|
categoryFilter = categoryFilter == cat ? "" : cat;
|
|
}
|
|
|
|
private void ClearCategoryFilter()
|
|
{
|
|
categoryFilter = "";
|
|
}
|
|
|
|
private void ClearFactionFilter()
|
|
{
|
|
factionFilter = "";
|
|
}
|
|
|
|
private void ToggleAgentLink()
|
|
{
|
|
agentLink = !agentLink;
|
|
}
|
|
|
|
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 = "";
|
|
}
|
|
}
|