mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
添加Room类
This commit is contained in:
parent
3d5aee0a45
commit
3c2e26d67e
@ -1,27 +1,13 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using System.Data;
|
||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Api.Factory
|
namespace Milimoe.FunGame.Core.Api.Factory
|
||||||
{
|
{
|
||||||
internal class RoomFactory
|
internal class RoomFactory
|
||||||
{
|
{
|
||||||
internal static Milimoe.FunGame.Core.Entity.Room GetInstanceByRandomID(RoomType type, Milimoe.FunGame.Core.Entity.User? user)
|
internal static Room GetInstance(DataSet? DataSet)
|
||||||
{
|
{
|
||||||
Milimoe.FunGame.Core.Entity.Room room = new(user)
|
return new Room(DataSet);
|
||||||
{
|
|
||||||
RoomType = type,
|
|
||||||
RoomState = RoomState.Created
|
|
||||||
};
|
|
||||||
return room;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static Milimoe.FunGame.Core.Entity.Room GetInstanceByRoomID(RoomType type, string roomid, Milimoe.FunGame.Core.Entity.User? user)
|
|
||||||
{
|
|
||||||
Milimoe.FunGame.Core.Entity.Room room = new(roomid, user)
|
|
||||||
{
|
|
||||||
RoomType = type,
|
|
||||||
RoomState = RoomState.Created
|
|
||||||
};
|
|
||||||
return room;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,18 @@
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Api.Factory
|
namespace Milimoe.FunGame.Core.Api.Factory
|
||||||
{
|
{
|
||||||
internal class SkillFactory
|
internal class SkillFactory
|
||||||
{
|
{
|
||||||
internal static Skill? GetInstance(SkillType type, string Name)
|
internal static Skill GetInstance(DataSet? DataSet, SkillType type = SkillType.Passive)
|
||||||
{
|
{
|
||||||
Skill? skill = null;
|
Skill skill = type switch
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
case SkillType.Active:
|
SkillType.Active => new ActiveSkill(DataSet),
|
||||||
skill = new Milimoe.FunGame.Core.Entity.ActiveSkill(Name);
|
_ => new PassiveSkill(DataSet)
|
||||||
break;
|
};
|
||||||
case SkillType.Passive:
|
|
||||||
skill = new Milimoe.FunGame.Core.Entity.PassiveSkill(Name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,6 @@ namespace Milimoe.FunGame.Core.Api.Factory
|
|||||||
{
|
{
|
||||||
internal class UserFactory
|
internal class UserFactory
|
||||||
{
|
{
|
||||||
internal static User GetInstance()
|
|
||||||
{
|
|
||||||
return new User();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static User GetInstance(DataSet? DataSet)
|
internal static User GetInstance(DataSet? DataSet)
|
||||||
{
|
{
|
||||||
return new User(DataSet);
|
return new User(DataSet);
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
|
using Milimoe.FunGame.Core.Api.Factory;
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Api.Utility
|
namespace Milimoe.FunGame.Core.Api.Utility
|
||||||
{
|
{
|
||||||
public class Factory
|
public class Factory
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取一个可能为NULL的实例
|
/// 获取一个不为NULL的实例
|
||||||
/// <para>Item默认返回PassiveItem</para>
|
/// <para>Item默认返回PassiveItem</para>
|
||||||
/// <para>Skill默认返回PassiveSkill</para>
|
/// <para>Skill默认返回PassiveSkill</para>
|
||||||
/// <para>若无法找到T,返回唯一的空对象</para>
|
/// <para>若无法找到T,返回唯一的空对象</para>
|
||||||
@ -20,11 +21,15 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
object instance = General.EntityInstance;
|
object instance = General.EntityInstance;
|
||||||
if (typeof(T) == typeof(User))
|
if (typeof(T) == typeof(User))
|
||||||
{
|
{
|
||||||
instance = Api.Factory.UserFactory.GetInstance(DataSet);
|
instance = UserFactory.GetInstance(DataSet);
|
||||||
}
|
}
|
||||||
else if (typeof(T) == typeof(Skill))
|
else if (typeof(T) == typeof(Skill) || typeof(T) == typeof(PassiveSkill))
|
||||||
{
|
{
|
||||||
|
instance = SkillFactory.GetInstance(DataSet);
|
||||||
|
}
|
||||||
|
else if (typeof(T) == typeof(ActiveSkill))
|
||||||
|
{
|
||||||
|
instance = SkillFactory.GetInstance(DataSet, SkillType.Active);
|
||||||
}
|
}
|
||||||
return (T)instance;
|
return (T)instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace Milimoe.FunGame.Core.Entity
|
using System.Data;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Core.Entity
|
||||||
{
|
{
|
||||||
public class ActiveSkill : Skill
|
public class ActiveSkill : Skill
|
||||||
{
|
{
|
||||||
@ -15,15 +17,9 @@
|
|||||||
public decimal Reference9 { get; set; } = 0;
|
public decimal Reference9 { get; set; } = 0;
|
||||||
public decimal Reference10 { get; set; } = 0;
|
public decimal Reference10 { get; set; } = 0;
|
||||||
|
|
||||||
internal ActiveSkill()
|
internal ActiveSkill(DataSet? DataSet)
|
||||||
{
|
{
|
||||||
Active = true;
|
Active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ActiveSkill(string Name)
|
|
||||||
{
|
|
||||||
Active = true;
|
|
||||||
this.Name = Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace Milimoe.FunGame.Core.Entity
|
using System.Data;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Core.Entity
|
||||||
{
|
{
|
||||||
public class PassiveSkill : Skill
|
public class PassiveSkill : Skill
|
||||||
{
|
{
|
||||||
@ -13,15 +15,9 @@
|
|||||||
public decimal Reference9 { get; set; } = 0;
|
public decimal Reference9 { get; set; } = 0;
|
||||||
public decimal Reference10 { get; set; } = 0;
|
public decimal Reference10 { get; set; } = 0;
|
||||||
|
|
||||||
internal PassiveSkill()
|
internal PassiveSkill(DataSet? DataSet)
|
||||||
{
|
{
|
||||||
Active = false;
|
Active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal PassiveSkill(string Name)
|
|
||||||
{
|
|
||||||
Active = false;
|
|
||||||
this.Name = Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
using Milimoe.FunGame.Core.Interface.Entity;
|
using Milimoe.FunGame.Core.Interface.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Entity
|
namespace Milimoe.FunGame.Core.Entity
|
||||||
{
|
{
|
||||||
public class Room : BaseEntity
|
public class Room : BaseEntity
|
||||||
{
|
{
|
||||||
public string Roomid { get; set; } = "";
|
public string Roomid { get; set; } = "";
|
||||||
public DateTime Time { get; set; } = DateTime.Now;
|
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||||
public Hashtable PlayerList { get; set; } = new Hashtable();
|
public Hashtable PlayerList { get; set; } = new Hashtable();
|
||||||
public User? RoomMaster { get; set; }
|
public User? RoomMaster { get; set; }
|
||||||
public RoomType RoomType { get; set; }
|
public RoomType RoomType { get; set; }
|
||||||
@ -24,15 +25,12 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
public string Password { get; set; } = "";
|
public string Password { get; set; } = "";
|
||||||
public GameStatistics? Statistics { get; set; } = null;
|
public GameStatistics? Statistics { get; set; } = null;
|
||||||
|
|
||||||
internal Room(User? master = null)
|
internal Room(DataSet? DataSet)
|
||||||
{
|
{
|
||||||
if (master != null) RoomMaster = master;
|
if (DataSet != null && DataSet.Tables.Count > 0 && DataSet.Tables[0].Rows.Count > 0)
|
||||||
}
|
{
|
||||||
|
|
||||||
internal Room(string roomid, User? master = null)
|
}
|
||||||
{
|
|
||||||
Roomid = roomid;
|
|
||||||
if (master != null) RoomMaster = master;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(Room other)
|
public bool Equals(Room other)
|
||||||
|
|||||||
@ -9,14 +9,19 @@
|
|||||||
public const string Command_Update = "Update";
|
public const string Command_Update = "Update";
|
||||||
public const string Command_Delete = "Delete";
|
public const string Command_Delete = "Delete";
|
||||||
public const string Command_Insert = "Insert";
|
public const string Command_Insert = "Insert";
|
||||||
public const string Command_Set = "Set";
|
|
||||||
public const string Command_Where = "Where";
|
|
||||||
public const string Command_From = "From";
|
public const string Command_From = "From";
|
||||||
public const string Command_All = "*";
|
public const string Command_Set = "Set";
|
||||||
public const string Command_Into = "Into";
|
public const string Command_Into = "Into";
|
||||||
|
public const string Command_Where = "Where";
|
||||||
|
public const string Command_All = "*";
|
||||||
public const string Command_Values = "Values";
|
public const string Command_Values = "Values";
|
||||||
public const string Command_And = "And";
|
public const string Command_And = "And";
|
||||||
public const string Command_Or = "Or";
|
public const string Command_Or = "Or";
|
||||||
|
public const string Command_As = "As";
|
||||||
|
public const string Command_LeftJoin = "Left Join";
|
||||||
|
public const string Command_InnerJoin = "Inner Join";
|
||||||
|
public const string Command_RightJoin = "Right Join";
|
||||||
|
public const string Command_On = "On";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
FunGame.Core/Library/SQLScript/Entity/RoomQuery.cs
Normal file
17
FunGame.Core/Library/SQLScript/Entity/RoomQuery.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace Milimoe.FunGame.Core.Library.SQLScript.Entity
|
||||||
|
{
|
||||||
|
public class RoomQuery
|
||||||
|
{
|
||||||
|
public const string TableName = "Rooms";
|
||||||
|
public const string Column_RoomID = "Roomid";
|
||||||
|
public const string Column_CreateTime = "CreateTime";
|
||||||
|
public const string Column_RoomMaster = "RoomMaster";
|
||||||
|
public const string Column_RoomMasterName = "RoomMasterName";
|
||||||
|
public const string Column_RoomType = "RoomType";
|
||||||
|
public const string Column_RoomState = "RoomState";
|
||||||
|
public const string Column_HasPass = "HasPass";
|
||||||
|
public const string Column_Password = "Password";
|
||||||
|
public const string Select_Rooms = $"{Constant.Command_Select} {TableName}.{Constant.Command_All}, {UserQuery.TableName}.{UserQuery.Column_Username} {Constant.Command_As} {Column_RoomMasterName} " +
|
||||||
|
$"{Constant.Command_From} {TableName} {Constant.Command_LeftJoin} {UserQuery.TableName} {Constant.Command_On} {UserQuery.TableName}.{UserQuery.Column_UID} = {TableName}.{Column_RoomMaster}";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user