mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
更新构造方法
This commit is contained in:
parent
3575600161
commit
57417a33ac
@ -5,9 +5,9 @@ namespace Milimoe.FunGame.Core.Api.Factory
|
||||
{
|
||||
internal class RoomFactory
|
||||
{
|
||||
internal static Room GetInstance(DataSet? DataSet)
|
||||
internal static Room GetInstance(DataSet? DsRoom, DataSet? DsUser)
|
||||
{
|
||||
return new Room(DataSet);
|
||||
return new Room(DsRoom, DsUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
||||
public abstract string Script { get; set; }
|
||||
public abstract CommandType CommandType { get; set; }
|
||||
public abstract SQLResult Result { get; }
|
||||
public abstract bool Success { get; }
|
||||
public abstract SQLServerInfo ServerInfo { get; }
|
||||
public abstract int UpdateRows { get; }
|
||||
public abstract DataSet DataSet { get; }
|
||||
|
||||
@ -14,26 +14,27 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <para>若无法找到T,返回唯一的空对象</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Entity类</typeparam>
|
||||
/// <param name="DataSet">使用DataSet构造对象(真香)</param>
|
||||
/// <param name="DataSets">使用DataSet构造对象(真香)</param>
|
||||
/// <returns></returns>
|
||||
public static T GetInstance<T>(DataSet? DataSet)
|
||||
public static T GetInstance<T>(params DataSet?[] DataSets)
|
||||
{
|
||||
if (DataSets is null || DataSets.Length == 0) throw new GetInstanceException();
|
||||
object instance = General.EntityInstance;
|
||||
if (typeof(T) == typeof(User))
|
||||
{
|
||||
instance = UserFactory.GetInstance(DataSet);
|
||||
instance = UserFactory.GetInstance(DataSets[0]);
|
||||
}
|
||||
else if (typeof(T) == typeof(Skill) || typeof(T) == typeof(PassiveSkill))
|
||||
{
|
||||
instance = SkillFactory.GetInstance(DataSet);
|
||||
instance = SkillFactory.GetInstance(DataSets[0]);
|
||||
}
|
||||
else if (typeof(T) == typeof(ActiveSkill))
|
||||
{
|
||||
instance = SkillFactory.GetInstance(DataSet, SkillType.Active);
|
||||
instance = SkillFactory.GetInstance(DataSets[0], SkillType.Active);
|
||||
}
|
||||
else if (typeof(T) == typeof(Room))
|
||||
{
|
||||
instance = RoomFactory.GetInstance(DataSet);
|
||||
instance = RoomFactory.GetInstance(DataSets[0], DataSets[1]);
|
||||
}
|
||||
return (T)instance;
|
||||
}
|
||||
|
||||
@ -2,11 +2,13 @@
|
||||
using System.Collections;
|
||||
using Milimoe.FunGame.Core.Interface.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
public class Room : BaseEntity
|
||||
{
|
||||
public override long Id { get => base.Id ; set => base.Id = value; }
|
||||
public string Roomid { get; set; } = "";
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
public Hashtable PlayerList { get; set; } = new Hashtable();
|
||||
@ -25,11 +27,18 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
public string Password { get; set; } = "";
|
||||
public GameStatistics? Statistics { get; set; } = null;
|
||||
|
||||
internal Room(DataSet? DataSet)
|
||||
internal Room(DataSet? DsRoom, DataSet? DsUser)
|
||||
{
|
||||
if (DataSet != null && DataSet.Tables.Count > 0 && DataSet.Tables[0].Rows.Count > 0)
|
||||
if (DsRoom != null && DsRoom.Tables.Count > 0 && DsRoom.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
|
||||
DataRow row = DsRoom.Tables[0].Rows[0];
|
||||
Id = (long)row[RoomQuery.Column_ID];
|
||||
Roomid = (string)row[RoomQuery.Column_RoomID];
|
||||
CreateTime = (DateTime)row[RoomQuery.Column_CreateTime];
|
||||
RoomMaster = Api.Utility.Factory.GetInstance<User>(DsUser);
|
||||
RoomType = (RoomType)Convert.ToInt32(row[RoomQuery.Column_RoomType]);
|
||||
RoomState = (RoomState)Convert.ToInt32(row[RoomQuery.Column_RoomState]);
|
||||
Password = (string)row[RoomQuery.Column_Password];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
public class RoomQuery
|
||||
{
|
||||
public const string TableName = "Rooms";
|
||||
public const string Column_ID = "Id";
|
||||
public const string Column_RoomID = "Roomid";
|
||||
public const string Column_CreateTime = "CreateTime";
|
||||
public const string Column_RoomMaster = "RoomMaster";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user