Files
systemrevivalserver/Game/Dungeon/DungeonInstance.cs
T
2026-01-11 08:04:20 -05:00

62 lines
2.0 KiB
C#

namespace GameServer.Dungeon;
/// <summary>
/// Represents an active dungeon instance
/// </summary>
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;
/// <summary>
/// Check if a player level is within the bracket range
/// </summary>
public bool IsLevelInBracket(int playerLevel)
{
return playerLevel >= LevelBracketMin && playerLevel <= LevelBracketMax;
}
/// <summary>
/// Calculate level bracket from a player's level (brackets of 10: 1-10, 11-20, 21-30, etc.)
/// </summary>
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);
}
/// <summary>
/// Get the bracket number (1, 2, 3, etc.)
/// </summary>
public int BracketNumber => (LevelBracketMin - 1) / 10 + 1;
}