Add remaining project files
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using LiteDB;
|
||||
using static DeluxeBackend.Enums;
|
||||
|
||||
namespace DeluxeBackend.Models
|
||||
{
|
||||
public class RoomInstance
|
||||
{
|
||||
[BsonId]
|
||||
public long Id { get; set; }
|
||||
|
||||
public required string PhotonRegion { get; set; } = "eu";
|
||||
public required string PhotonRoom { get; set; }
|
||||
|
||||
public RoomInstanceType InstanceType { get; set; } = RoomInstanceType.Private;
|
||||
|
||||
[BsonRef("subrooms")]
|
||||
public required SubRoom SubRoom { get; set; }
|
||||
public long EventId { get; set; } = -1;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public bool Private { get; set; } = true;
|
||||
public bool GameInProgress { get; set; } = false;
|
||||
public MatchmakingPolicyType MatchmakingPolicy { get; set; } = MatchmakingPolicyType.Default;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.MinValue;
|
||||
|
||||
[BsonIgnore]
|
||||
public Dictionary<string, object?> ToDictionary()
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
Dictionary<string, object?> data = new()
|
||||
{
|
||||
["roomInstanceId"] = Id,
|
||||
["roomId"] = SubRoom.Room.Id,
|
||||
["subRoomId"] = SubRoom.Id,
|
||||
["location"] = SubRoom.LocationId,
|
||||
["roomInstanceType"] = (int)InstanceType,
|
||||
["maxCapacity"] = SubRoom.MaxPlayers,
|
||||
["isFull"] = false,
|
||||
["isPrivate"] = Private,
|
||||
["isInProgress"] = GameInProgress,
|
||||
//["voiceServerId"] = "test-voice-5",
|
||||
//["voiceAuthId"] = "",
|
||||
["matchmakingPolicy"] = (int)MatchmakingPolicy
|
||||
};
|
||||
if (EventId != -1)
|
||||
{
|
||||
data["eventId"] = EventId;
|
||||
}
|
||||
|
||||
string roomName = string.IsNullOrWhiteSpace(SubRoom.Room.Name)
|
||||
? $"UnknownRoom-{SubRoom.Room.Id}"
|
||||
: SubRoom.Room.Name;
|
||||
string name = $"^{roomName}";
|
||||
if (InstanceType == RoomInstanceType.Dormroom)
|
||||
{
|
||||
if (SubRoom.Room.Creator != null) {
|
||||
if (string.IsNullOrEmpty(SubRoom.Room.Creator.Username))
|
||||
{
|
||||
name = $"Can't find room creator username :(";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = $"@{SubRoom.Room.Creator.Username}'s Dorm";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = $"Can't find room creator :(";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data["name"] = name;
|
||||
return data;
|
||||
#pragma warning restore CS8601
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user