using LiteDB; using static DeluxeBackend.Enums; namespace DeluxeBackend.Models { [Flags] public enum RoomSupports { None = 0, Screens = 1, WalkVR = 2, TeleportVR = 4, Juniors = 8, All = Screens | WalkVR | TeleportVR | Juniors } public class RoomRole { public long AccountId { get; set; } public RoomRoleType InvitedRole { get; set; } = RoomRoleType.None; public RoomRoleType Role { get; set; } = RoomRoleType.None; } public class RoomStats { public List VisitorIds { get; set; } = []; public List CheeredIds { get; set; } = []; public List FavoritedIds { get; set; } = []; public long VisitCount { get; set; } = 0; } public class Room { [BsonId] public long Id { get; set; } public RoomAccessibility Accessibility { get; set; } public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public bool CloningAllowed { get; set; } = false; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; [BsonRef("accounts")] public Account Creator { get; set; } = null!; public string? CustomWarning { get; set; } = string.Empty; public RoomWarningMask WarningMask { get; set; } = RoomWarningMask.None; public string DataBlob { get; set; } = string.Empty; public bool DisableMicAutoMute { get; set; } = false; public bool DisableRoomComments { get; set; } = false; public bool EncryptVoiceChat { get; set; } = false; public string ImageName { get; set; } = "DefaultRoomImage.jpg"; public bool IsDorm { get; set; } = false; public bool IsRRO { get; set; } = false; public int MinLevel { get; set; } = 0; public RoomSupports SupportedPlayerTypes { get; set; } = RoomSupports.All; public List Roles { get; set; } = []; public int? PersistenceVersion { get; set; } public RoomStats Stats { get; set; } = new RoomStats(); [BsonIgnore] public bool HasRole(long id, RoomRoleType requiredRole) { if (Creator != null && Creator.Id == id) { return true; } var playerRoleEntry = Roles.FirstOrDefault(r => r.AccountId == id); RoomRoleType playerRole = playerRoleEntry?.Role ?? RoomRoleType.None; return (int)playerRole >= (int)requiredRole; } } }