@page "/database" @using Model.Entity @using Model.Entity.Data @using Model.Entity.Parts Database

Database

Showing @filteredEntities.Count @(filteredEntities.Count == 1 ? "entity" : "entities")
@foreach (var entity in filteredEntities) {
@entity.Info().Name
@{ var vanguard = entity.VanguardAdded(); if (vanguard != null) { @(EntityData.Get().TryGetValue(vanguard!.ImmortalId, out var imm) ? imm.Info().Name : "") } }
@entity.EntityType.Replace("_", " ") @if (entity.Faction() != null) { @(EntityData.Get().TryGetValue(entity.Faction().Faction, out var fac) ? fac.Info().Name : "") }
@if (!string.IsNullOrEmpty(entity.Info().Description)) {

@(entity.Info().Description.Length > 120 ? entity.Info().Description[..117] + "..." : entity.Info().Description)

}
}
@if (filteredEntities.Count == 0) { }
@code { private string selectedFaction = DataType.Any; private string selectedImmortal = DataType.Any; private List immortalChoices = new(); private List allEntities = new(); private List filteredEntities = new(); protected override void OnInitialized() { allEntities = EntityModel.GetList() .Where(e => !e.IsSpeculative) .ToList(); RefreshImmortalChoices(); ApplyFilters(); } private void OnFactionChanged() { if (selectedFaction != DataType.FACTION_QRath && selectedFaction != DataType.FACTION_Aru) { selectedFaction = DataType.Any; } selectedImmortal = DataType.Any; RefreshImmortalChoices(); ApplyFilters(); } private void OnImmortalChanged() { ApplyFilters(); } private void RefreshImmortalChoices() { immortalChoices.Clear(); if (selectedFaction == DataType.FACTION_QRath || selectedFaction == DataType.Any) { AddImmortalChoice(DataType.IMMORTAL_Orzum); AddImmortalChoice(DataType.IMMORTAL_Ajari); } if (selectedFaction == DataType.FACTION_Aru || selectedFaction == DataType.Any) { AddImmortalChoice(DataType.IMMORTAL_Atzlan); AddImmortalChoice(DataType.IMMORTAL_Mala); AddImmortalChoice(DataType.IMMORTAL_Xol); } } private void AddImmortalChoice(string id) { var name = EntityData.Get().TryGetValue(id, out var model) ? model.Info().Name : id.Replace("IMMORTAL_", ""); immortalChoices.Add(new ImmortalChoice(id, name)); } private void ApplyFilters() { var query = allEntities.AsEnumerable(); if (selectedFaction != DataType.Any) { query = query.Where(e => e.Faction() != null && e.Faction().Faction == selectedFaction); } if (selectedImmortal != DataType.Any) { query = query.Where(e => e.VanguardAdded() != null && e.VanguardAdded().ImmortalId == selectedImmortal); } filteredEntities = query.OrderBy(e => e.Info().Name).ToList(); } private record ImmortalChoice(string Key, string Name); }