diff --git a/Services/Admin/Pages/Dungeons/View.cshtml.cs b/Services/Admin/Pages/Dungeons/View.cshtml.cs index 9e87484..d875fcf 100644 --- a/Services/Admin/Pages/Dungeons/View.cshtml.cs +++ b/Services/Admin/Pages/Dungeons/View.cshtml.cs @@ -34,7 +34,8 @@ public class ViewModel : AdminPageModel public async Task OnGetAsync(Guid id) { - Dungeon = _dungeonHandler.GetDungeon(id); + var dungeon = _dungeonHandler.GetDungeon(id); + Dungeon = dungeon; MobDefinitions = await _db.DungeonMobDefinitions .Where(m => m.IsEnabled).OrderBy(m => m.Name).ToListAsync(); @@ -65,11 +66,11 @@ public class ViewModel : AdminPageModel cols = s.Columns })); - if (Dungeon == null) return; + if (dungeon == null) return; - Duration = FormatDuration(DateTime.UtcNow - Dungeon.CreatedAt); + Duration = FormatDuration(DateTime.UtcNow - dungeon.CreatedAt); - var layout = Dungeon.LayoutV2; + var layout = dungeon.LayoutV2; if (layout != null) { MapWidth = layout.Width; @@ -89,20 +90,20 @@ public class ViewModel : AdminPageModel } else { MapWidth = 100; MapHeight = 100; } - PlayersJson = JsonSerializer.Serialize(Dungeon.Simulation.Players.Values.Select(p => new { + PlayersJson = JsonSerializer.Serialize(dungeon.Simulation.Players.Values.Select(p => new { id = p.CharacterId.ToString(), name = p.CharacterName, x = p.X, y = p.Y, health = p.Health, maxHealth = p.MaxHealth, isAlive = p.IsAlive })); - MobsJson = JsonSerializer.Serialize(Dungeon.Simulation.Mobs.Values.Select(m => new { + MobsJson = JsonSerializer.Serialize(dungeon.Simulation.Mobs.Values.Select(m => new { id = m.Id, name = m.Name, x = m.X, y = m.Y, health = m.Health, maxHealth = m.MaxHealth, alive = m.IsAlive, isBoss = m.Type == DataServer.Data.Enums.MobType.Boss, state = m.State.ToString(), abilities = m.Abilities.Select(a => new { id = a.AbilityId, name = a.Definition?.Name ?? $"Ability {a.AbilityId}", key = a.Definition?.Key ?? "" }), resistances = m.Stats.Resistances, lootGold = m.DeathLootGold, lootItems = m.DeathLoot == null - ? Array.Empty() - : m.DeathLoot.Select(l => new { id = l.ItemDefinitionId, name = l.Item?.Name ?? $"Item {l.ItemDefinitionId}", qty = l.Quantity }) + ? Enumerable.Empty() + : m.DeathLoot.Select(l => (object)new { id = l.ItemDefinitionId, name = l.Item?.Name ?? $"Item {l.ItemDefinitionId}", qty = l.Quantity }) })); } @@ -126,8 +127,8 @@ public class ViewModel : AdminPageModel resistances = m.Stats.Resistances, lootGold = m.DeathLootGold, lootItems = m.DeathLoot == null - ? Array.Empty() - : m.DeathLoot.Select(l => new { id = l.ItemDefinitionId, name = l.Item?.Name ?? $"Item {l.ItemDefinitionId}", qty = l.Quantity }) + ? Enumerable.Empty() + : m.DeathLoot.Select(l => (object)new { id = l.ItemDefinitionId, name = l.Item?.Name ?? $"Item {l.ItemDefinitionId}", qty = l.Quantity }) }) }); }