namespace GameServer.Dungeon; /// /// Represents an active dungeon instance /// public class DungeonInstance { public Guid Id { get; set; } public int Tier { get; set; } public int Seed { get; set; } public DungeonSimulation Simulation { get; set; } = null!; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public bool ClearedHandled { get; set; } = false; // Level bracket system public int LevelBracketMin { get; set; } public int LevelBracketMax { get; set; } public int CreatorLevel { get; set; } public ulong CreatorCharacterId { get; set; } public string CreatorName { get; set; } = ""; // V2 Layout with visual tiles (null if generated with V1) public DungeonLayoutV2? LayoutV2 { get; set; } // Auto-join window (5 minutes) public DateTime JoinWindowEnd => CreatedAt.AddMinutes(5); public bool IsJoinWindowOpen => DateTime.UtcNow < JoinWindowEnd; // Persistence public DateTime LastPlayerActivity { get; set; } = DateTime.UtcNow; public bool IsPersisted { get; set; } = false; public bool BossKilled { get; set; } = false; // Admin editing public bool HasPendingTileUpdates { get; set; } = false; /// /// Check if a player level is within the bracket range /// public bool IsLevelInBracket(int playerLevel) { return playerLevel >= LevelBracketMin && playerLevel <= LevelBracketMax; } /// /// Calculate level bracket from a player's level (brackets of 10: 1-10, 11-20, 21-30, etc.) /// public static (int min, int max) GetLevelBracket(int level) { // Bracket 1: 1-10, Bracket 2: 11-20, etc. int bracketIndex = (level - 1) / 10; int min = bracketIndex * 10 + 1; int max = min + 9; return (min, max); } /// /// Get the bracket number (1, 2, 3, etc.) /// public int BracketNumber => (LevelBracketMin - 1) / 10 + 1; }