From 4f9a7b3ca76c5fd6488962154efc88c29c7a2852 Mon Sep 17 00:00:00 2001 From: milimoe Date: Mon, 16 Dec 2024 01:15:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E3=80=81=E6=9B=B4=E6=96=B0=E6=B8=B8=E6=88=8F=E5=B9=B3?= =?UTF-8?q?=E8=A1=A1=E5=B8=B8=E6=95=B0=E3=80=81=E6=B7=BB=E5=8A=A0=E7=BB=8F?= =?UTF-8?q?=E9=AA=8C=E5=80=BC=E6=98=BE=E7=A4=BA=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/Utility/TaskScheduler.cs | 87 ++++++++++++++++++++++++++++++++++- Entity/Character/Character.cs | 33 +++++++++---- Model/ActionQueue.cs | 7 ++- Model/EquilibriumConstant.cs | 52 +++++++-------------- 4 files changed, 128 insertions(+), 51 deletions(-) diff --git a/Api/Utility/TaskScheduler.cs b/Api/Utility/TaskScheduler.cs index d2c710d..f73a0f8 100644 --- a/Api/Utility/TaskScheduler.cs +++ b/Api/Utility/TaskScheduler.cs @@ -1,4 +1,5 @@ -using Milimoe.FunGame.Core.Model; +using Milimoe.FunGame.Core.Library.Constant; +using Milimoe.FunGame.Core.Model; namespace Milimoe.FunGame.Core.Api.Utility { @@ -33,7 +34,12 @@ namespace Milimoe.FunGame.Core.Api.Utility { lock (_lock) { - _tasks.Add(new ScheduledTask(name, timeOfDay, action)); + ScheduledTask task = new(name, timeOfDay, action); + if (DateTime.Now > DateTime.Today.Add(timeOfDay)) + { + task.LastRun = DateTime.Today.Add(timeOfDay); + } + _tasks.Add(task); } } @@ -72,6 +78,83 @@ namespace Milimoe.FunGame.Core.Api.Utility } } + /// + /// 获取任务计划上一次执行时间 + /// + /// + /// + /// + public DateTime GetLastTime(string name, bool recurring = false) + { + if (!recurring) + { + if (_tasks.FirstOrDefault(t => t.Name == name) is ScheduledTask task && task.LastRun.HasValue) + { + return task.LastRun.Value; + } + else if (_recurringTasks.FirstOrDefault(t => t.Name == name) is RecurringTask recurringTask && recurringTask.LastRun.HasValue) + { + return recurringTask.LastRun.Value; + } + } + else if (_recurringTasks.FirstOrDefault(t => t.Name == name) is RecurringTask recurringTask && recurringTask.LastRun.HasValue) + { + return recurringTask.LastRun.Value; + } + return DateTime.MinValue; + } + + /// + /// 获取任务计划下一次执行时间 + /// + /// + /// + /// + public DateTime GetNextTime(string name, bool recurring = false) + { + if (!recurring) + { + if (_tasks.FirstOrDefault(t => t.Name == name) is ScheduledTask task) + { + DateTime today = DateTime.Today.Add(task.TimeOfDay); + return task.IsTodayRun ? today.AddDays(1) : today; + } + else if (_recurringTasks.FirstOrDefault(t => t.Name == name) is RecurringTask recurringTask) + { + return recurringTask.NextRun; + } + } + else if (_recurringTasks.FirstOrDefault(t => t.Name == name) is RecurringTask recurringTask) + { + return recurringTask.NextRun; + } + return DateTime.MaxValue; + } + + public string GetRunTimeInfo(string name) + { + DateTime last = GetLastTime(name); + DateTime next = GetNextTime(name); + string msg = ""; + if (last != DateTime.MinValue) + { + msg += $"上次运行时间:{last.ToString(General.GeneralDateTimeFormat)}\r\n"; + } + if (next != DateTime.MaxValue) + { + msg += $"下次运行时间:{next.ToString(General.GeneralDateTimeFormat)}\r\n"; + } + if (msg != "") + { + msg = $"任务计划:{name}\r\n{msg}"; + } + else + { + msg = $"任务计划 {name} 不存在!"; + } + return msg.Trim(); + } + /// /// 执行任务 /// diff --git a/Entity/Character/Character.cs b/Entity/Character/Character.cs index dc1596a..d96fee6 100644 --- a/Entity/Character/Character.cs +++ b/Entity/Character/Character.cs @@ -69,31 +69,31 @@ namespace Milimoe.FunGame.Core.Entity { get { - if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdSUpperLimit) + if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["S"]) { return RoleRating.X; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdAPlusUpperLimit && Promotion <= General.GameplayEquilibriumConstant.PromotionThresholdSUpperLimit) + else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["A+"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["S"]) { return RoleRating.S; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdAUpperLimit && Promotion <= General.GameplayEquilibriumConstant.PromotionThresholdAPlusUpperLimit) + else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["A"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["A+"]) { return RoleRating.APlus; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdBUpperLimit && Promotion <= General.GameplayEquilibriumConstant.PromotionThresholdAUpperLimit) + else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["B"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["A"]) { return RoleRating.A; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdCUpperLimit && Promotion <= General.GameplayEquilibriumConstant.PromotionThresholdBUpperLimit) + else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["C"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["B"]) { return RoleRating.B; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdDUpperLimit && Promotion <= General.GameplayEquilibriumConstant.PromotionThresholdCUpperLimit) + else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["D"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["C"]) { return RoleRating.C; } - else if (Promotion > General.GameplayEquilibriumConstant.PromotionThresholdEUpperLimit && Promotion <= General.GameplayEquilibriumConstant.PromotionThresholdDUpperLimit) + else if (Promotion > General.GameplayEquilibriumConstant.PromotionsUpperLimit["E"] && Promotion <= General.GameplayEquilibriumConstant.PromotionsUpperLimit["D"]) { return RoleRating.D; } @@ -1215,11 +1215,16 @@ namespace Milimoe.FunGame.Core.Entity /// 获取角色的详细信息 /// /// - public string GetInfo(bool showUser = true, bool showGrowth = true) + public string GetInfo(bool showUser = true, bool showGrowth = true, bool showEXP = false) { StringBuilder builder = new(); builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); + if (showEXP) + { + builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}"); + builder.AppendLine($"经验值:{EXP}{(Level > 0 && Level <= General.GameplayEquilibriumConstant.EXPUpperLimit.Keys.Max() ? " / " + General.GameplayEquilibriumConstant.EXPUpperLimit[Level] : "")}"); + } double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; @@ -1338,11 +1343,16 @@ namespace Milimoe.FunGame.Core.Entity /// 获取角色的简略信息 /// /// - public string GetSimpleInfo(bool showUser = true, bool showGrowth = true) + public string GetSimpleInfo(bool showUser = true, bool showGrowth = true, bool showEXP = false) { StringBuilder builder = new(); builder.AppendLine(showUser ? ToStringWithLevel() : ToStringWithLevelWithOutUser()); + if (showEXP) + { + builder.AppendLine($"等级:{Level} / {General.GameplayEquilibriumConstant.MaxLevel}"); + builder.AppendLine($"经验值:{EXP}{(Level > 0 && Level <= General.GameplayEquilibriumConstant.EXPUpperLimit.Keys.Max() ? " / " + General.GameplayEquilibriumConstant.EXPUpperLimit[Level] : "")}"); + } double exHP = ExHP + ExHP2 + ExHP3; builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "")); double exMP = ExMP + ExMP2 + ExMP3; @@ -1586,8 +1596,10 @@ namespace Milimoe.FunGame.Core.Entity EP = EP, InitialATK = InitialATK, ExATK2 = ExATK2, + ExATKPercentage = ExATKPercentage, InitialDEF = InitialDEF, ExDEF2 = ExDEF2, + ExDEFPercentage = ExDEFPercentage, MDF = MDF.Copy(), PhysicalPenetration = PhysicalPenetration, MagicalPenetration = MagicalPenetration, @@ -1602,6 +1614,9 @@ namespace Milimoe.FunGame.Core.Entity ExSTR = ExSTR, ExAGI = ExAGI, ExINT = ExINT, + ExSTRPercentage = ExSTRPercentage, + ExAGIPercentage = ExAGIPercentage, + ExINTPercentage = ExINTPercentage, STRGrowth = STRGrowth, AGIGrowth = AGIGrowth, INTGrowth = INTGrowth, diff --git a/Model/ActionQueue.cs b/Model/ActionQueue.cs index d3ddbce..3555681 100644 --- a/Model/ActionQueue.cs +++ b/Model/ActionQueue.cs @@ -684,7 +684,6 @@ namespace Milimoe.FunGame.Core.Model } else { - decided = true; WriteLine("[ " + character + $" ] 完全行动不能!"); type = CharacterActionType.None; } @@ -995,19 +994,19 @@ namespace Milimoe.FunGame.Core.Model { character.HP += reallyReHP; character.MP += reallyReMP; - WriteLine($"角色 {character.NickName} 回血:{recoveryHP:0.##} / 回蓝:{recoveryMP:0.##}"); + WriteLine($"角色 {character.Name} 回血:{recoveryHP:0.##} [{character.HP:0.##} / {character.MaxHP:0.##}] / 回蓝:{recoveryMP:0.##} [{character.MP:0.##} / {character.MaxMP:0.##}]"); } else { if (reallyReHP > 0) { character.HP += reallyReHP; - WriteLine($"角色 {character.NickName} 回血:{recoveryHP:0.##}"); + WriteLine($"角色 {character.Name} 回血:{recoveryHP:0.##} [{character.HP:0.##} / {character.MaxHP:0.##}]"); } if (reallyReMP > 0) { character.MP += reallyReMP; - WriteLine($"角色 {character.NickName} 回蓝:{recoveryMP:0.##}"); + WriteLine($"角色 {character.Name} 回蓝:{recoveryMP:0.##} [{character.MP:0.##} / {character.MaxMP:0.##}]"); } } diff --git a/Model/EquilibriumConstant.cs b/Model/EquilibriumConstant.cs index d76d3b9..935e210 100644 --- a/Model/EquilibriumConstant.cs +++ b/Model/EquilibriumConstant.cs @@ -18,42 +18,17 @@ /// /// 晋升点数上限 /// - public int PromotionThresholdXUpperLimit { get; set; } = 999; - - /// - /// 角色评级 S 的晋升点数上限 - /// - public int PromotionThresholdSUpperLimit { get; set; } = 998; - - /// - /// 角色评级 A+ 的晋升点数上限 - /// - public int PromotionThresholdAPlusUpperLimit { get; set; } = 850; - - /// - /// 角色评级 A 的晋升点数上限 - /// - public int PromotionThresholdAUpperLimit { get; set; } = 700; - - /// - /// 角色评级 B 的晋升点数上限 - /// - public int PromotionThresholdBUpperLimit { get; set; } = 550; - - /// - /// 角色评级 C 的晋升点数上限 - /// - public int PromotionThresholdCUpperLimit { get; set; } = 400; - - /// - /// 角色评级 D 的晋升点数上限 - /// - public int PromotionThresholdDUpperLimit { get; set; } = 300; - - /// - /// 角色评级 E 的晋升点数上限 - /// - public int PromotionThresholdEUpperLimit { get; set; } = 200; + public Dictionary PromotionsUpperLimit { get; set; } = new() + { + { "X", 999 }, + { "S", 998 }, + { "A+", 850 }, + { "A", 700 }, + { "B", 550 }, + { "C", 400 }, + { "D", 300 }, + { "E", 200 }, + }; /// /// 初始生命值 @@ -70,6 +45,11 @@ /// public int MaxLevel { get; set; } = 60; + /// + /// 经验值上限 + /// + public Dictionary EXPUpperLimit { get; set; } = []; + /// /// 魔法最高等级 ///