mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-22 12:09:34 +08:00
完善Room的构造函数和SQLScript (#65)
This commit is contained in:
parent
10d9a257f8
commit
a60b6d7b3f
@ -13,9 +13,9 @@ namespace Milimoe.FunGame.Core.Api.Factory
|
||||
return RoomFactory.Create();
|
||||
}
|
||||
|
||||
public static Room Create(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, string Password = "")
|
||||
public static Room Create(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, bool IsRank = false, string Password = "")
|
||||
{
|
||||
return new Room(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password);
|
||||
return new Room(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, IsRank, Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,11 +72,12 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <param name="GameMode">游戏模组</param>
|
||||
/// <param name="GameMap"></param>
|
||||
/// <param name="RoomState">房间状态</param>
|
||||
/// <param name="IsRank"></param>
|
||||
/// <param name="Password">房间密码</param>
|
||||
/// <returns></returns>
|
||||
public static Room GetRoom(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, string Password = "")
|
||||
public static Room GetRoom(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, bool IsRank = false, string Password = "")
|
||||
{
|
||||
return RoomFactory.Create(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password);
|
||||
return RoomFactory.Create(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, IsRank, Password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -98,8 +99,9 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
string GameMode = (string)DrRoom[RoomQuery.Column_GameMode];
|
||||
string GameMap = (string)DrRoom[RoomQuery.Column_GameMap];
|
||||
RoomState RoomState = (RoomState)Convert.ToInt32(DrRoom[RoomQuery.Column_RoomState]);
|
||||
bool IsRank = Convert.ToInt32(DrRoom[RoomQuery.Column_IsRank]) == 1;
|
||||
string Password = (string)DrRoom[RoomQuery.Column_Password];
|
||||
room = GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password);
|
||||
room = GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, IsRank, Password);
|
||||
}
|
||||
return room;
|
||||
}
|
||||
@ -136,8 +138,9 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
string GameMode = (string)DrRoom[RoomQuery.Column_GameMode];
|
||||
string GameMap = (string)DrRoom[RoomQuery.Column_GameMap];
|
||||
RoomState RoomState = (RoomState)Convert.ToInt32(DrRoom[RoomQuery.Column_RoomState]);
|
||||
bool IsRank = Convert.ToInt32(DrRoom[RoomQuery.Column_IsRank]) == 1;
|
||||
string Password = (string)DrRoom[RoomQuery.Column_Password];
|
||||
list.Add(GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password));
|
||||
list.Add(GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, IsRank, Password));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
@ -235,7 +235,7 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetRoom(System.Int64,System.String,System.Nullable{System.DateTime},Milimoe.FunGame.Core.Entity.User,Milimoe.FunGame.Core.Library.Constant.RoomType,System.String,System.String,Milimoe.FunGame.Core.Library.Constant.RoomState,System.String)">
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetRoom(System.Int64,System.String,System.Nullable{System.DateTime},Milimoe.FunGame.Core.Entity.User,Milimoe.FunGame.Core.Library.Constant.RoomType,System.String,System.String,Milimoe.FunGame.Core.Library.Constant.RoomState,System.Boolean,System.String)">
|
||||
<summary>
|
||||
获取房间实例
|
||||
</summary>
|
||||
@ -247,6 +247,7 @@
|
||||
<param name="GameMode">游戏模组</param>
|
||||
<param name="GameMap"></param>
|
||||
<param name="RoomState">房间状态</param>
|
||||
<param name="IsRank"></param>
|
||||
<param name="Password">房间密码</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
|
@ -24,14 +24,17 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
Statistics = new(this);
|
||||
}
|
||||
|
||||
internal Room(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, string Password = "")
|
||||
internal Room(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, bool IsRank = false, string Password = "")
|
||||
{
|
||||
this.Id = Id;
|
||||
this.Roomid = Roomid;
|
||||
this.CreateTime = CreateTime ?? General.DefaultTime;
|
||||
this.RoomMaster = RoomMaster ?? General.UnknownUserInstance;
|
||||
this.RoomType = RoomType;
|
||||
this.GameMode = GameMode;
|
||||
this.GameMap = GameMap;
|
||||
this.RoomState = RoomState;
|
||||
this.IsRank = IsRank;
|
||||
this.Password = Password;
|
||||
Statistics = new(this);
|
||||
}
|
||||
|
@ -66,6 +66,10 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
||||
room.RoomState = (RoomState)reader.GetInt64();
|
||||
break;
|
||||
|
||||
case RoomQuery.Column_IsRank:
|
||||
room.IsRank = reader.GetBoolean();
|
||||
break;
|
||||
|
||||
case RoomQuery.Column_Password:
|
||||
room.Password = reader.GetString() ?? "";
|
||||
break;
|
||||
|
@ -12,18 +12,19 @@
|
||||
public const string Column_GameMode = "GameMode";
|
||||
public const string Column_GameMap = "GameMap";
|
||||
public const string Column_RoomState = "RoomState";
|
||||
public const string Column_IsRank = "IsRank";
|
||||
public const string Column_HasPass = "HasPass";
|
||||
public const string Column_Password = "Password";
|
||||
public const string Select_Rooms = $"{Command_Select} {TableName}.{Command_All}, {UserQuery.TableName}.{UserQuery.Column_Username} {Command_As} {Column_RoomMasterName} " +
|
||||
$"{Command_From} {TableName} {Command_LeftJoin} {UserQuery.TableName} {Command_On} {UserQuery.TableName}.{UserQuery.Column_UID} = {TableName}.{Column_RoomMaster}";
|
||||
|
||||
public static string Insert_CreateRoom(string RoomID, long RoomMaster, Library.Constant.RoomType RoomType, string GameMode, string GameMap, string Password)
|
||||
public static string Insert_CreateRoom(string RoomID, long RoomMaster, Library.Constant.RoomType RoomType, string GameMode, string GameMap, bool IsRank, string Password)
|
||||
{
|
||||
Library.Constant.RoomState RoomState = Library.Constant.RoomState.Created;
|
||||
DateTime NowTime = DateTime.Now;
|
||||
bool HasPass = Password.Trim() != "";
|
||||
return $"{Command_Insert} {Command_Into} {TableName} ({Column_RoomID}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_GameMode}, {Column_GameMap}, {Column_RoomState}, {Column_HasPass}, {Column_Password})" +
|
||||
$" {Command_Values} ('{RoomID}', '{NowTime}', {RoomMaster}, {(int)RoomType}, '{GameMode}', '{GameMap}', {(int)RoomState}, {(HasPass ? 1 : 0)}, '{Password}')";
|
||||
return $"{Command_Insert} {Command_Into} {TableName} ({Column_RoomID}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_GameMode}, {Column_GameMap}, {Column_RoomState}, {Column_IsRank}, {Column_HasPass}, {Column_Password})" +
|
||||
$" {Command_Values} ('{RoomID}', '{NowTime}', {RoomMaster}, {(int)RoomType}, '{GameMode}', '{GameMap}', {(int)RoomState}, {(IsRank ? 1 : 0)}, {(HasPass ? 1 : 0)}, '{Password}')";
|
||||
}
|
||||
|
||||
public static string Delete_Rooms(params string[] roomids)
|
||||
|
Loading…
x
Reference in New Issue
Block a user