Adding vibe mana curve

This commit is contained in:
2026-06-25 10:05:49 -04:00
parent 68872f0dac
commit 00e7184b3b
3 changed files with 88 additions and 8 deletions
+36
View File
@@ -38,6 +38,22 @@
<small class="text-danger ms-2 d-block d-md-inline">@deck.ValidationMessage</small>
}
</div>
@{
var distribution = GetManaDistribution();
var maxCount = distribution.Max(x => x.Count);
}
<div class="mana-curve">
@foreach (var entry in distribution)
{
var height = maxCount > 0 ? (entry.Count * 100 / maxCount) : 0;
<div class="mana-bar-container">
<div class="mana-bar-label">@entry.Count</div>
<div class="mana-bar" style="height: @($"{Math.Max(height, 5)}%")"></div>
<div class="mana-cost">@(entry.Cost >= 10 ? "10+" : entry.Cost.ToString())</div>
</div>
}
</div>
</header>
@if (deck.Keycards.Count > 0)
@@ -274,6 +290,26 @@
selectedCard = null;
}
private List<(int Cost, int Count)> GetManaDistribution()
{
if (deck == null) return [];
var counts = new Dictionary<int, int>();
for (int i = 0; i <= 10; i++) counts[i] = 0;
foreach (var cardName in deck.Cards)
{
var card = LookupCard(cardName);
if (card?.Cost != null)
{
var cost = card.Cost.Value;
if (cost >= 10) cost = 10;
counts[cost]++;
}
}
return counts.OrderBy(x => x.Key).Select(x => (x.Key, x.Value)).ToList();
}
private RenderFragment RenderDescription(string description)
{
return builder =>