mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
PluginConfig 添加文件目录的属性;添加 UpdateUser 查询常量;修复回合日志不能正常显示特效描述的问题;添加 Inventory_MarketDelist;修复插件清理时出现的问题
This commit is contained in:
parent
d4084caf60
commit
e233479c5b
@ -537,7 +537,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// </summary>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateRandomString(int length = 18)
|
||||
public static string GenerateRandomString(int length = 32)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+=-`~[]\\{}|;':\",./<>?";
|
||||
byte[] data = RandomNumberGenerator.GetBytes(length);
|
||||
|
||||
@ -6,15 +6,20 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <summary>
|
||||
/// 简易的插件配置文件生成器<para/>
|
||||
/// 仅支持部分基本类型(<see cref="long"/>, <see cref="double"/>, <see cref="decimal"/>, <see cref="string"/>, <see cref="bool"/>)及其数组(<see cref="List{T}">List<long>, List<double>, List<decimal>, List<string>, List<bool></see>和<see cref="Array">long[], double[], decimal[], string[], bool[]</see>)
|
||||
/// <para/>文件会保存为:程序目录/configs/<see cref="PluginName"/>/<see cref="FileName"/>.json
|
||||
/// <para/>文件会保存为:程序目录/<see cref="RootPath"/>(通常是 configs)/<see cref="PluginName"/>/<see cref="FileName"/>.json
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 新建一个配置文件,文件会保存为:程序目录/configs/<paramref name="plugin_name"/>/<paramref name="file_name"/>.json
|
||||
/// 新建一个配置文件,文件会保存为:程序目录/<see cref="RootPath"/>(通常是 configs)/<paramref name="plugin_name"/>/<paramref name="file_name"/>.json
|
||||
/// </remarks>
|
||||
/// <param name="plugin_name"></param>
|
||||
/// <param name="file_name"></param>
|
||||
public class PluginConfig(string plugin_name, string file_name) : Dictionary<string, object>
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置文件存放的根目录
|
||||
/// </summary>
|
||||
public static string RootPath { get; set; } = "configs";
|
||||
|
||||
/// <summary>
|
||||
/// 插件的名称
|
||||
/// </summary>
|
||||
@ -105,7 +110,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// </summary>
|
||||
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<string, object>)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))
|
||||
{
|
||||
|
||||
@ -115,6 +115,7 @@ namespace Milimoe.FunGame.Core.Controller
|
||||
_sqlPolling = null;
|
||||
}
|
||||
_cts?.Dispose();
|
||||
_cts = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -116,6 +116,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
||||
Inventory_Use,
|
||||
Inventory_StoreSell,
|
||||
Inventory_MarketSell,
|
||||
Inventory_MarketDelist,
|
||||
Inventory_UpdateMarketPrice,
|
||||
Inventory_GetOffer,
|
||||
Inventory_MakeOffer,
|
||||
|
||||
@ -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)";
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user