diff --git a/FunGame.Core/Api/Data/SQLHelper.cs b/FunGame.Core/Api/Data/SQLHelper.cs
index f76dfaf..b09707d 100644
--- a/FunGame.Core/Api/Data/SQLHelper.cs
+++ b/FunGame.Core/Api/Data/SQLHelper.cs
@@ -7,10 +7,13 @@ using System.Threading.Tasks;
using Milimoe.FunGame.Core.Interface.Base;
using Milimoe.FunGame.Core.Library.Common.Network;
using Milimoe.FunGame.Core.Library.Constant;
-using Milimoe.FunGame.Core.Service;
namespace Milimoe.FunGame.Core.Api.Data
{
+ ///
+ /// 需要在Server中继承此类实现。
+ /// Milimoe.FunGame.Core.Service.SQLManager也是
+ ///
public class SQLHelper : ISQLHelper
{
public string Script { get; set; } = "";
@@ -39,17 +42,9 @@ namespace Milimoe.FunGame.Core.Api.Data
this.UpdateRows = rows;
}
- public SQLResult Execute()
+ public virtual SQLResult Execute()
{
- switch (EntityType)
- {
- case EntityType.NotEntity:
- SQLManager SQLManager = new(this);
- return SQLManager.Execute(Script);
- default:
- break;
- }
- return Result;
+ return SQLResult.NotFound;
}
}
}
diff --git a/FunGame.Core/Api/Utility/Singleton.cs b/FunGame.Core/Api/Utility/Singleton.cs
index 104affe..8a2e908 100644
--- a/FunGame.Core/Api/Utility/Singleton.cs
+++ b/FunGame.Core/Api/Utility/Singleton.cs
@@ -15,11 +15,22 @@ namespace Milimoe.FunGame.Core.Api.Utility
{
private static readonly Hashtable SingletonTable = new();
- public static bool IsExist(string key)
+ ///
+ /// 查询目标的类是否已经有实例
+ ///
+ /// 单例对象
+ ///
+ public static bool IsExist(object single)
{
- return SingletonTable.ContainsKey(key);
+ return SingletonTable.ContainsKey(single.GetType().ToString());
}
+ ///
+ /// 将目标和目标的类添加至单例表
+ ///
+ /// 单例对象
+ ///
+ /// 添加单例到单例表时遇到错误
public static bool Add(object single)
{
string type = single.GetType().ToString();
@@ -38,6 +49,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
return false;
}
+ ///
+ /// 将目标和目标的类从单例表中移除
+ ///
+ /// 单例对象
+ ///
public static bool Remove(object single)
{
string type = single.GetType().ToString();
@@ -52,6 +68,12 @@ namespace Milimoe.FunGame.Core.Api.Utility
}
}
+ ///
+ /// 获取单例对象
+ ///
+ /// 目标类
+ ///
+ /// 不能从单例表中获取到指定的单例
public static T? Get()
{
T? single = default;
@@ -70,15 +92,21 @@ namespace Milimoe.FunGame.Core.Api.Utility
}
return single;
}
-
- public static object? Get(string key)
+
+ ///
+ /// 获取单例对象
+ ///
+ /// 目标类
+ ///
+ /// 不能从单例表中获取到指定的单例
+ public static object? Get(Type type)
{
object? single = default;
- if (SingletonTable.ContainsKey(key))
+ if (SingletonTable.ContainsKey(type))
{
try
{
- single = SingletonTable[key];
+ single = SingletonTable[type];
}
catch
{
diff --git a/FunGame.Core/Interface/Base/BaseSQLService.cs b/FunGame.Core/Interface/Base/BaseSQLService.cs
deleted file mode 100644
index 3fde255..0000000
--- a/FunGame.Core/Interface/Base/BaseSQLService.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Milimoe.FunGame.Core.Library.Constant;
-
-namespace Milimoe.FunGame.Core.Interface.Base
-{
- internal abstract class BaseSQLService
- {
- internal abstract SQLResult Execute();
- internal abstract SQLResult Execute(StringBuilder sql);
- internal abstract SQLResult Execute(string sql);
- internal abstract int Update(StringBuilder sql, ref SQLResult result);
- internal abstract int Remove(StringBuilder sql, ref SQLResult result);
- internal abstract int Add(StringBuilder sql, ref SQLResult result);
- internal abstract int Update(string sql, ref SQLResult result);
- internal abstract int Remove(string sql, ref SQLResult result);
- internal abstract int Add(string sql, ref SQLResult result);
- internal abstract object Query(EntityType type, StringBuilder sql);
- internal abstract T Query(StringBuilder sql);
- internal abstract object Query(EntityType type, string sql);
- internal abstract T Query(string sql);
- }
-}
diff --git a/FunGame.Core/Interface/General/IClient.cs b/FunGame.Core/Interface/General/IClient.cs
index b8c1008..4ad5b76 100644
--- a/FunGame.Core/Interface/General/IClient.cs
+++ b/FunGame.Core/Interface/General/IClient.cs
@@ -1,14 +1,14 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Milimoe.FunGame.Core.Interface
+namespace Milimoe.FunGame.Core.Interface
{
public interface IClient
{
+ public string FunGameIcon { get; }
+ public string FunGameBackGround { get; }
+ public string FunGameMainMusic { get; }
+ public string FunGameMusic1 { get; }
+ public string FunGameMusic2 { get; }
+ public string FunGameMusic3 { get; }
+
public string RemoteServerIP();
}
}
diff --git a/FunGame.Core/Library/Constant/ConstantSet.cs b/FunGame.Core/Library/Constant/ConstantSet.cs
index 1f1eaac..02d9e6d 100644
--- a/FunGame.Core/Library/Constant/ConstantSet.cs
+++ b/FunGame.Core/Library/Constant/ConstantSet.cs
@@ -29,6 +29,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
public const int MaxConnection_General = 20;
public const int MaxConnection_4C4G = 40;
+ public const string Socket = "Socket";
public const string Unknown = "Unknown";
public const string Connect = "Connect";
public const string GetNotice = "GetNotice";
diff --git a/FunGame.Core/Library/Constant/General.cs b/FunGame.Core/Library/Constant/General.cs
index e1c5df6..4eb3e31 100644
--- a/FunGame.Core/Library/Constant/General.cs
+++ b/FunGame.Core/Library/Constant/General.cs
@@ -11,7 +11,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
{
// Static Variable
public static Empty EntityInstance { get; } = new();
- public static Encoding DEFAULT_ENCODING { get; } = Encoding.UTF8;
+ public static Encoding DefaultEncoding { get; } = Encoding.UTF8;
// Const
public const int MaxRetryTimes = 20;
diff --git a/FunGame.Core/Library/Constant/TypeEnum.cs b/FunGame.Core/Library/Constant/TypeEnum.cs
index 72d6b03..d1912e0 100644
--- a/FunGame.Core/Library/Constant/TypeEnum.cs
+++ b/FunGame.Core/Library/Constant/TypeEnum.cs
@@ -131,8 +131,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
PassiveSkill,
GameStatistics,
Character,
- CharacterStatistics,
- NotEntity
+ CharacterStatistics
}
public enum TimeType
diff --git a/FunGame.Core/Service/SQLManager.cs b/FunGame.Core/Service/SQLManager.cs
index 59c9f14..c7999f6 100644
--- a/FunGame.Core/Service/SQLManager.cs
+++ b/FunGame.Core/Service/SQLManager.cs
@@ -5,12 +5,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Milimoe.FunGame.Core.Api.Data;
-using Milimoe.FunGame.Core.Interface.Base;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Service
{
- internal class SQLManager : BaseSQLService
+ ///
+ /// 需要在Server中继承此类实现
+ ///
+ public class SQLManager
{
internal SQLHelper SQLHelper { get; }
@@ -19,69 +21,69 @@ namespace Milimoe.FunGame.Core.Service
this.SQLHelper = SQLHelper;
}
- internal override int Add(StringBuilder sql, ref SQLResult result)
+ protected virtual int Add(StringBuilder sql, ref SQLResult result)
{
- throw new NotImplementedException();
+ return 0;
}
- internal override int Add(string sql, ref SQLResult result)
+ protected virtual int Add(string sql, ref SQLResult result)
{
- throw new NotImplementedException();
+ return 0;
}
- internal override SQLResult Execute()
+ protected virtual SQLResult Execute()
{
- throw new NotImplementedException();
+ return SQLResult.NotFound;
}
- internal override SQLResult Execute(StringBuilder sql)
+ protected virtual SQLResult Execute(StringBuilder sql)
{
- throw new NotImplementedException();
+ return SQLResult.NotFound;
}
- internal override SQLResult Execute(string sql)
+ protected virtual SQLResult Execute(string sql)
{
- throw new NotImplementedException();
+ return SQLResult.NotFound;
}
- internal override object Query(EntityType type, StringBuilder sql)
+ protected virtual object Query(EntityType type, StringBuilder sql)
{
- throw new NotImplementedException();
+ return General.EntityInstance;
}
- internal override T Query(StringBuilder sql)
+ protected virtual T? Query(StringBuilder sql)
{
- throw new NotImplementedException();
+ return default;
}
- internal override object Query(EntityType type, string sql)
+ protected virtual object Query(EntityType type, string sql)
{
- throw new NotImplementedException();
+ return General.EntityInstance;
}
- internal override T Query(string sql)
+ protected virtual T? Query(string sql)
{
- throw new NotImplementedException();
+ return default;
}
- internal override int Remove(StringBuilder sql, ref SQLResult result)
+ protected virtual int Remove(StringBuilder sql, ref SQLResult result)
{
- throw new NotImplementedException();
+ return 0;
}
- internal override int Remove(string sql, ref SQLResult result)
+ protected virtual int Remove(string sql, ref SQLResult result)
{
- throw new NotImplementedException();
+ return 0;
}
- internal override int Update(StringBuilder sql, ref SQLResult result)
+ protected virtual int Update(StringBuilder sql, ref SQLResult result)
{
- throw new NotImplementedException();
+ return 0;
}
- internal override int Update(string sql, ref SQLResult result)
+ protected virtual int Update(string sql, ref SQLResult result)
{
- throw new NotImplementedException();
+ return 0;
}
}
}
diff --git a/FunGame.Core/Service/SocketManager.cs b/FunGame.Core/Service/SocketManager.cs
index 8c90e1b..ce45e66 100644
--- a/FunGame.Core/Service/SocketManager.cs
+++ b/FunGame.Core/Service/SocketManager.cs
@@ -134,7 +134,7 @@ namespace Milimoe.FunGame.Core.Service
{
if (ClientSocket != null && objs != null && objs.Length > 0)
{
- if (ClientSocket.Send(General.DEFAULT_ENCODING.GetBytes(Library.Common.Network.JsonObject.GetString(type, token, objs))) > 0)
+ if (ClientSocket.Send(General.DefaultEncoding.GetBytes(Library.Common.Network.JsonObject.GetString(type, token, objs))) > 0)
{
return SocketResult.Success;
}
@@ -157,7 +157,7 @@ namespace Milimoe.FunGame.Core.Service
}
if (Socket != null)
{
- if (Socket.Send(General.DEFAULT_ENCODING.GetBytes(Library.Common.Network.JsonObject.GetString(type, token, objs))) > 0)
+ if (Socket.Send(General.DefaultEncoding.GetBytes(Library.Common.Network.JsonObject.GetString(type, token, objs))) > 0)
{
return SocketResult.Success;
}
@@ -180,7 +180,7 @@ namespace Milimoe.FunGame.Core.Service
int length = Socket.Receive(buffer);
if (length > 0)
{
- string msg = General.DEFAULT_ENCODING.GetString(buffer, 0, length);
+ string msg = General.DefaultEncoding.GetString(buffer, 0, length);
Library.Common.Network.JsonObject? json = Library.Common.Network.JsonObject.GetObject(msg);
if (json != null)
{
@@ -207,7 +207,7 @@ namespace Milimoe.FunGame.Core.Service
int length = ClientSocket.Receive(buffer);
if (length > 0)
{
- string msg = General.DEFAULT_ENCODING.GetString(buffer, 0, length);
+ string msg = General.DefaultEncoding.GetString(buffer, 0, length);
Library.Common.Network.JsonObject? json = Library.Common.Network.JsonObject.GetObject(msg);
if (json != null)
{
diff --git a/FunGame.Desktop/Controller/LoginController.cs b/FunGame.Desktop/Controller/LoginController.cs
index 4e8138c..b16462a 100644
--- a/FunGame.Desktop/Controller/LoginController.cs
+++ b/FunGame.Desktop/Controller/LoginController.cs
@@ -3,10 +3,24 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Milimoe.FunGame.Desktop.Library.Interface;
+using Milimoe.FunGame.Desktop.Model;
+using Milimoe.FunGame.Desktop.UI;
namespace Milimoe.FunGame.Desktop.Controller
{
- public class LoginController
+ public class LoginController : ILogin
{
+ LoginModel LoginModel { get; }
+
+ public LoginController(Login Login)
+ {
+ LoginModel = new LoginModel(Login);
+ }
+
+ public bool LoginAccount()
+ {
+ return LoginModel.LoginAccount();
+ }
}
}
diff --git a/FunGame.Desktop/Controller/MainController.cs b/FunGame.Desktop/Controller/MainController.cs
index 001aa8e..10c9a15 100644
--- a/FunGame.Desktop/Controller/MainController.cs
+++ b/FunGame.Desktop/Controller/MainController.cs
@@ -7,23 +7,29 @@ using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Library.Common.Event;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Library.Exception;
+using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Library.Component;
+using Milimoe.FunGame.Desktop.Library.Interface;
using Milimoe.FunGame.Desktop.Model;
-using Milimoe.FunGame.Desktop.Others;
using Milimoe.FunGame.Desktop.UI;
namespace Milimoe.FunGame.Desktop.Controller
{
- public class MainController
+ public class MainController : IMain
{
private MainModel MainModel { get; }
+ public bool Connected => Do(MainControllerSet.Connected);
+
public MainController(Main Main)
{
MainModel = new MainModel(Main);
}
- public T Do(string DoType)
+ /**
+ * 从内部去调用Model的方法,并记录日志。
+ */
+ private T Do(string DoType)
{
object result = new();
switch(DoType)
@@ -35,8 +41,7 @@ namespace Milimoe.FunGame.Desktop.Controller
result = MainModel.Connect();
break;
case MainControllerSet.Connected:
- if (MainModel.Socket is null) result = false;
- else result = MainModel.Socket.Connected;
+ result = MainModel.Connected;
break;
case MainControllerSet.Disconnect:
MainModel.Disconnect();
@@ -61,9 +66,6 @@ namespace Milimoe.FunGame.Desktop.Controller
case MainControllerSet.LogOut:
result = MainModel.Logout();
break;
- case MainControllerSet.LogIn:
- result = MainModel.Login();
- break;
case MainControllerSet.Close:
result = MainModel.Close();
break;
@@ -72,5 +74,70 @@ namespace Milimoe.FunGame.Desktop.Controller
}
return (T)result;
}
+
+ public bool GetServerConnection()
+ {
+ return Do(MainControllerSet.GetServerConnection);
+ }
+
+ public ConnectResult Connect()
+ {
+ return Do(MainControllerSet.Connect);
+ }
+
+ public void Disconnect()
+ {
+ Do