165 lines
4.1 KiB
C#
165 lines
4.1 KiB
C#
using CGamesServer.Api.Entities;
|
||
using MessagePack;
|
||
using StackExchange.Redis;
|
||
|
||
namespace CGamesServer.Api.Dto
|
||
{
|
||
[MessagePackObject]
|
||
public class RoomInfo
|
||
{
|
||
/// <summary>
|
||
/// 房间ID
|
||
/// </summary>
|
||
|
||
[Key("roomId")]
|
||
public string RoomID { get; set; } = string.Empty;
|
||
|
||
/// <summary>
|
||
/// 房间显示名称
|
||
/// </summary>
|
||
|
||
[Key("roomName")]
|
||
public string RoomName { get; set; } = string.Empty;
|
||
|
||
/// <summary>
|
||
/// 地图ID
|
||
/// </summary>
|
||
|
||
[Key("mapId")]
|
||
public string MapID { get; set; } = string.Empty;
|
||
|
||
/// <summary>
|
||
/// 房间密码,默认为空
|
||
/// </summary>
|
||
[Key("roomPwd")]
|
||
public string? RoomPwd { get; set; }
|
||
|
||
|
||
/// <summary>
|
||
/// 房间AI电脑玩家数量
|
||
/// </summary>
|
||
[Key("aiCount")]
|
||
public int AICount { get; set; } = 0;
|
||
|
||
/// <summary>
|
||
/// 房间总用户数(包括玩家和电脑)
|
||
/// </summary>
|
||
[Key("userCount")]
|
||
public int UserCount = 0;
|
||
|
||
/// <summary>
|
||
/// 房间最大允许容纳的用户数
|
||
/// </summary>
|
||
private int _maxUserCount = 0;
|
||
|
||
/// <summary>
|
||
/// 随机数种子,每个房间唯一
|
||
/// </summary>
|
||
[Key("randomSeed")]
|
||
public string RandomSeed { get; set; } = new Random().NextDouble().ToString();
|
||
|
||
//[Key("listIdx")]
|
||
//public long ListIdx { get; set; } = 0;
|
||
|
||
/// <summary>
|
||
/// 房间用户ID列表
|
||
/// </summary>
|
||
[Key("uidList")]
|
||
public List<string> UIdList { get; set; } = new List<string>();
|
||
|
||
/// <summary>
|
||
/// 创建时间,单位(毫秒)
|
||
/// </summary>
|
||
[Key("createTimeMs")]
|
||
public long CreateTimeMs { get; set; } = 0;
|
||
|
||
/// <summary>
|
||
/// 此局倒计时,单位(毫秒)
|
||
/// </summary>
|
||
[Key("coolDownMs")]
|
||
public long CoolDownMs { get; set; } = 0;
|
||
|
||
/// <summary>
|
||
/// 是否已开局
|
||
/// </summary>
|
||
[Key("isStartGame")]
|
||
public bool IsStartGame { get; set; }
|
||
|
||
/// <summary>
|
||
/// 房间席位状态
|
||
/// </summary>
|
||
[Key("sets")]
|
||
public List<bool> Sets { get; set; } = new List<bool>();
|
||
|
||
/// <summary>
|
||
/// 房间最大允许容纳的用户数
|
||
/// </summary>
|
||
[Key("maxUserCount")]
|
||
public int MaxUserCount
|
||
{
|
||
get => _maxUserCount;
|
||
set
|
||
{
|
||
_maxUserCount = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 刚开始建主时候的主机PlayerID
|
||
/// </summary>
|
||
[Key("initHostPlayerId")]
|
||
public string InitHostPlayerID { get; set; } = string.Empty;
|
||
|
||
|
||
[Key("roomImageUrl")]
|
||
public string RoomImageUrl { get; set; } = string.Empty;
|
||
|
||
[Key("isHandleWillGameOverMessage")]
|
||
public bool IsHandleWillGameOverMessage { get; set; } = false;
|
||
|
||
[Key("isAIAllAttackMode")]
|
||
public bool IsAIAllAttackMode { get; set; } = false;
|
||
|
||
/// <summary>
|
||
/// 初始化席位状态
|
||
/// </summary>
|
||
public void InitSets(bool isSetFirst)
|
||
{
|
||
Sets.Clear();
|
||
if (_maxUserCount > 0)
|
||
{
|
||
for (int i = 0; i < _maxUserCount; i++)
|
||
{
|
||
Sets.Add(false);
|
||
}
|
||
if (isSetFirst)
|
||
{
|
||
Sets[0] = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
//public void ResetInitValue()
|
||
//{
|
||
// RoomName = string.Empty;
|
||
// UserCount = 1;
|
||
// IsRunning = false;
|
||
// ListIdx = 0;
|
||
// UidList = new List<string>();
|
||
//}
|
||
|
||
|
||
/// <summary>
|
||
/// 判断用户id是否存在,不存在,则加入此UidList
|
||
/// </summary>
|
||
/// <param name="uid"></param>
|
||
public void AddOrUpdateUidToList(string uid)
|
||
{
|
||
if (UIdList.IndexOf(uid) == -1)
|
||
{
|
||
UIdList.Add(uid);
|
||
}
|
||
}
|
||
}
|
||
}
|