Files
ChronoCCG/Chrono/Model/CardData.cs
T
2026-06-18 21:07:28 -04:00

44 lines
1.8 KiB
C#

namespace Chrono.Model;
public class CardData
{
public string Name { get; init; } = "";
public string Category { get; init; } = "";
public int? Cost { get; init; }
public int? Attack { get; init; }
public int? Health { get; init; }
public float StatEfficiency => Cost is > 0 && Attack is not null && Health is not null
? MathF.Round((Health.Value + Attack.Value) / (float)Cost.Value, 2)
: 0;
public string? Description { get; init; }
public string? Faction { get; init; }
public string? Set { get; init; }
public string? Speed { get; init; }
public List<string> Archetypes { get; init; } = [];
public List<string>? ImmortalizeTo { get; init; }
public string? ImmortalizeFrom { get; init; }
public string? ImmortalizeWhen { get; init; }
public string? ImageFile { get; init; }
public bool IsAgent => Category == "Agent";
public bool IsSpell => Category == "Spell";
public bool IsToken => Category == "Token";
public string? CostDisplay => Cost?.ToString();
public string? AttackDisplay => Attack?.ToString();
public string? HealthDisplay => Health?.ToString();
public bool HasImmortalize => ImmortalizeTo is { Count: > 0 };
public bool IsImmortalized => ImmortalizeFrom != null;
public string ImagePath => $"cards/{ImageFile ?? "placeholder.png"}";
public bool MatchesSearch(string query)
{
if (string.IsNullOrWhiteSpace(query)) return true;
var q = query.Trim().ToLowerInvariant();
return Name.ToLowerInvariant().Contains(q) ||
(Description?.ToLowerInvariant().Contains(q) ?? false) ||
(Faction?.ToLowerInvariant().Contains(q) ?? false) ||
Archetypes.Any(a => a.ToLowerInvariant().Contains(q));
}
}