Admin updates, dungeon viewer
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Server.Game.Dungeon;
|
||||
|
||||
/// <summary>
|
||||
/// Admin/management extensions for DungeonHandler
|
||||
/// </summary>
|
||||
public partial class DungeonHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all active dungeon instances (for admin viewing)
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<DungeonInstance> GetActiveDungeons()
|
||||
{
|
||||
return _dungeons.Values.ToList().AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a specific dungeon by ID (for admin viewing)
|
||||
/// </summary>
|
||||
public DungeonInstance? GetDungeon(Guid id)
|
||||
{
|
||||
_dungeons.TryGetValue(id, out var dungeon);
|
||||
return dungeon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force close a dungeon (admin action)
|
||||
/// Removes all players and destroys the instance
|
||||
/// </summary>
|
||||
public bool ForceCloseDungeon(Guid dungeonId)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
// Remove all players from the dungeon
|
||||
foreach (var player in dungeon.Simulation.Players.Values.ToList())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Send them back to town
|
||||
// Note: This is a simplified version - in production you'd want to
|
||||
// properly handle player state transitions
|
||||
//dungeon.Simulation.RemovePlayer(player.CharacterId);
|
||||
Console.WriteLine("Force Close Dungeon -- Needs Implemented");
|
||||
}
|
||||
catch { /* Ignore errors during cleanup */ }
|
||||
}
|
||||
|
||||
// Remove the dungeon
|
||||
return _dungeons.TryRemove(dungeonId, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get summary statistics for admin dashboard
|
||||
/// </summary>
|
||||
public DungeonStats GetStats()
|
||||
{
|
||||
var dungeons = _dungeons.Values.ToList();
|
||||
|
||||
return new DungeonStats
|
||||
{
|
||||
ActiveCount = dungeons.Count,
|
||||
TotalPlayers = dungeons.Sum(d => d.Simulation.Players.Count),
|
||||
TotalMobsAlive = dungeons.Sum(d => d.Simulation.Mobs.Values.Count(m => m.IsAlive)),
|
||||
CompletedCount = dungeons.Count(d => d.Simulation.Phase == DungeonPhase.Cleared),
|
||||
BossesKilled = dungeons.Count(d => d.BossKilled)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Statistics for admin dashboard
|
||||
/// </summary>
|
||||
public class DungeonStats
|
||||
{
|
||||
public int ActiveCount { get; set; }
|
||||
public int TotalPlayers { get; set; }
|
||||
public int TotalMobsAlive { get; set; }
|
||||
public int CompletedCount { get; set; }
|
||||
public int BossesKilled { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user