From e233479c5b486026d2fc775c576398a50e5f04b5 Mon Sep 17 00:00:00 2001 From: milimoe Date: Sun, 20 Apr 2025 16:01:46 +0800 Subject: [PATCH] =?UTF-8?q?PluginConfig=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9B=AE=E5=BD=95=E7=9A=84=E5=B1=9E=E6=80=A7=EF=BC=9B?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20UpdateUser=20=E6=9F=A5=E8=AF=A2=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=EF=BC=9B=E4=BF=AE=E5=A4=8D=E5=9B=9E=E5=90=88=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=89=B9=E6=95=88=E6=8F=8F=E8=BF=B0=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B=E6=B7=BB=E5=8A=A0=20Inventory=5FMarketDelist=EF=BC=9B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6=E6=B8=85=E7=90=86=E6=97=B6?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/Utility/General.cs | 2 +- Api/Utility/PluginConfig.cs | 13 +++++++++---- Controller/ServerAddonController.cs | 1 + Entity/Item/Item.cs | 4 +++- Library/Constant/ConstantSet.cs | 2 ++ Library/Constant/TypeEnum.cs | 1 + Library/SQLScript/Entity/UserQuery.cs | 18 +++++++++++++++--- Model/ActionQueue.cs | 5 ++++- 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Api/Utility/General.cs b/Api/Utility/General.cs index bfe00fa..acca331 100644 --- a/Api/Utility/General.cs +++ b/Api/Utility/General.cs @@ -537,7 +537,7 @@ namespace Milimoe.FunGame.Core.Api.Utility /// /// /// - public static string GenerateRandomString(int length = 18) + public static string GenerateRandomString(int length = 32) { const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+=-`~[]\\{}|;':\",./<>?"; byte[] data = RandomNumberGenerator.GetBytes(length); diff --git a/Api/Utility/PluginConfig.cs b/Api/Utility/PluginConfig.cs index c21bd3c..ff396e7 100644 --- a/Api/Utility/PluginConfig.cs +++ b/Api/Utility/PluginConfig.cs @@ -6,15 +6,20 @@ namespace Milimoe.FunGame.Core.Api.Utility /// /// 简易的插件配置文件生成器 /// 仅支持部分基本类型(, , , , )及其数组(List<long>, List<double>, List<decimal>, List<string>, List<bool>long[], double[], decimal[], string[], bool[]) - /// 文件会保存为:程序目录/configs//.json + /// 文件会保存为:程序目录/(通常是 configs)//.json /// /// - /// 新建一个配置文件,文件会保存为:程序目录/configs//.json + /// 新建一个配置文件,文件会保存为:程序目录/(通常是 configs)//.json /// /// /// public class PluginConfig(string plugin_name, string file_name) : Dictionary { + /// + /// 配置文件存放的根目录 + /// + public static string RootPath { get; set; } = "configs"; + /// /// 插件的名称 /// @@ -105,7 +110,7 @@ namespace Milimoe.FunGame.Core.Api.Utility /// public void LoadConfig() { - string dpath = $@"{AppDomain.CurrentDomain.BaseDirectory}configs/{PluginName}"; + string dpath = $@"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RootPath)}/{PluginName}"; string fpath = $@"{dpath}/{FileName}.json"; if (!Directory.Exists(dpath)) { @@ -130,7 +135,7 @@ namespace Milimoe.FunGame.Core.Api.Utility public void SaveConfig() { string json = NetworkUtility.JsonSerialize((Dictionary)this); - string dpath = $@"{AppDomain.CurrentDomain.BaseDirectory}configs/{PluginName}"; + string dpath = $@"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RootPath)}/{PluginName}"; string fpath = $@"{dpath}/{FileName}.json"; if (!Directory.Exists(dpath)) { diff --git a/Controller/ServerAddonController.cs b/Controller/ServerAddonController.cs index 0cb3cb4..cadb1fa 100644 --- a/Controller/ServerAddonController.cs +++ b/Controller/ServerAddonController.cs @@ -115,6 +115,7 @@ namespace Milimoe.FunGame.Core.Controller _sqlPolling = null; } _cts?.Dispose(); + _cts = null; } } } diff --git a/Entity/Item/Item.cs b/Entity/Item/Item.cs index d20aecb..20d1e47 100644 --- a/Entity/Item/Item.cs +++ b/Entity/Item/Item.cs @@ -322,6 +322,7 @@ namespace Milimoe.FunGame.Core.Entity } if (used) { + EntityState = EntityState.Modified; ReduceTimesAndRemove(); } return result && used; @@ -338,6 +339,7 @@ namespace Milimoe.FunGame.Core.Entity bool result = OnItemUsed(args); if (result) { + EntityState = EntityState.Modified; ReduceTimesAndRemove(); } return result; @@ -356,7 +358,7 @@ namespace Milimoe.FunGame.Core.Entity if (RemainUseTimes < 0) RemainUseTimes = 0; if (IsRemoveAfterUse && RemainUseTimes == 0) { - User.Inventory.Items.Remove(this); + EntityState = EntityState.Deleted; } } } diff --git a/Library/Constant/ConstantSet.cs b/Library/Constant/ConstantSet.cs index 3807ff1..bb97b20 100644 --- a/Library/Constant/ConstantSet.cs +++ b/Library/Constant/ConstantSet.cs @@ -165,6 +165,7 @@ namespace Milimoe.FunGame.Core.Library.Constant public const string Inventory_Use = "Inventory::Use"; public const string Inventory_StoreSell = "Inventory::StoreSell"; public const string Inventory_MarketSell = "Inventory::MarketSell"; + public const string Inventory_MarketDelist = "Inventory::MarketDelist"; public const string Inventory_UpdateMarketPrice = "Inventory::UpdateMarketPrice"; public const string Inventory_GetOffer = "Inventory::GetOffer"; public const string Inventory_MakeOffer = "Inventory::MakeOffer"; @@ -209,6 +210,7 @@ namespace Milimoe.FunGame.Core.Library.Constant DataRequestType.Inventory_Use => Inventory_Use, DataRequestType.Inventory_StoreSell => Inventory_StoreSell, DataRequestType.Inventory_MarketSell => Inventory_MarketSell, + DataRequestType.Inventory_MarketDelist => Inventory_MarketDelist, DataRequestType.Inventory_UpdateMarketPrice => Inventory_UpdateMarketPrice, DataRequestType.Inventory_GetOffer => Inventory_GetOffer, DataRequestType.Inventory_MakeOffer => Inventory_MakeOffer, diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index 875a570..a76f67f 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -116,6 +116,7 @@ namespace Milimoe.FunGame.Core.Library.Constant Inventory_Use, Inventory_StoreSell, Inventory_MarketSell, + Inventory_MarketDelist, Inventory_UpdateMarketPrice, Inventory_GetOffer, Inventory_MakeOffer, diff --git a/Library/SQLScript/Entity/UserQuery.cs b/Library/SQLScript/Entity/UserQuery.cs index 42e72b9..8e04dca 100644 --- a/Library/SQLScript/Entity/UserQuery.cs +++ b/Library/SQLScript/Entity/UserQuery.cs @@ -87,15 +87,27 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity return $"{Command_Update} {TableName} {Command_Set} {Column_GameTime} = {Column_GameTime} + @GameTimeMinutes {Command_Where} {Column_Username} = @Username"; } + public static string Update_User(SQLHelper SQLHelper, string Username, string NickName, string Email, bool IsAdmin, bool IsOperator, bool IsEnable, string AutoKey) + { + SQLHelper.Parameters["@Username"] = Username; + SQLHelper.Parameters["@Nickname"] = NickName; + SQLHelper.Parameters["@Email"] = Email; + SQLHelper.Parameters["@IsAdmin"] = IsAdmin ? 1 : 0; + SQLHelper.Parameters["@IsOperator"] = IsOperator ? 1 : 0; + SQLHelper.Parameters["@IsEnable"] = IsEnable ? 1 : 0; + SQLHelper.Parameters["@AutoKey"] = AutoKey; + return $"{Command_Update} {TableName} {Command_Set} {Column_Nickname} = @Nickname, {Column_Email} = @Email, {Column_IsAdmin} = @IsAdmin, {Column_IsOperator} = @IsOperator, {Column_IsEnable} = @IsEnable, {Column_AutoKey} = @AutoKey WHERE {Column_Username} = @Username"; + } + public static string Insert_Register(SQLHelper SQLHelper, string Username, string Password, string Email, string IP, string AutoKey = "") { - DateTime Now = DateTime.Now; + DateTime now = DateTime.Now; SQLHelper.Parameters["@Username"] = Username; SQLHelper.Parameters["@Nickname"] = Username; SQLHelper.Parameters["@Password"] = Password; SQLHelper.Parameters["@Email"] = Email; - SQLHelper.Parameters["@RegTime"] = Now; - SQLHelper.Parameters["@LastTime"] = Now; + SQLHelper.Parameters["@RegTime"] = now; + SQLHelper.Parameters["@LastTime"] = now; SQLHelper.Parameters["@LastIP"] = IP; SQLHelper.Parameters["@AutoKey"] = AutoKey; return $"{Command_Insert} {Command_Into} {TableName} ({Column_Username}, {Column_Nickname}, {Column_Password}, {Column_Email}, {Column_RegTime}, {Column_LastTime}, {Column_LastIP}, {Column_AutoKey}) {Command_Values} (@Username, @Nickname, @Password, @Email, @RegTime, @LastTime, @LastIP, @AutoKey)"; diff --git a/Model/ActionQueue.cs b/Model/ActionQueue.cs index e3a339b..bfee9cf 100644 --- a/Model/ActionQueue.cs +++ b/Model/ActionQueue.cs @@ -2486,7 +2486,10 @@ namespace Milimoe.FunGame.Core.Model skill.GamingQueue = this; skill.Character = character; skill.Level = 1; - LastRound.RoundRewards.Add(skill); + Skill record = skill.Copy(); + record.Character = character; + record.Level = skill.Level; + LastRound.RoundRewards.Add(record); WriteLine($"[ {character} ] 获得了回合奖励!{skill.Description}".Trim()); if (skill.IsActive) {