diff --git a/Api/Utility/TaskScheduler.cs b/Api/Utility/TaskScheduler.cs index 159a624..9f3b832 100644 --- a/Api/Utility/TaskScheduler.cs +++ b/Api/Utility/TaskScheduler.cs @@ -38,15 +38,13 @@ namespace Milimoe.FunGame.Core.Api.Utility /// public void AddTask(string name, TimeSpan timeOfDay, Action action, Action? error = null) { - lock (_lock) + using Lock.Scope scope = _lock.EnterScope(); + ScheduledTask task = new(name, timeOfDay, action, error); + if (DateTime.Now > DateTime.Today.Add(timeOfDay)) { - ScheduledTask task = new(name, timeOfDay, action, error); - if (DateTime.Now > DateTime.Today.Add(timeOfDay)) - { - task.LastRun = DateTime.Today.Add(timeOfDay); - } - _tasks.Add(task); + task.LastRun = DateTime.Today.Add(timeOfDay); } + _tasks.Add(task); } /// @@ -59,17 +57,15 @@ namespace Milimoe.FunGame.Core.Api.Utility /// public void AddRecurringTask(string name, TimeSpan interval, Action action, bool startNow = false, Action? error = null) { - lock (_lock) + using Lock.Scope scope = _lock.EnterScope(); + DateTime now = DateTime.Now; + now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0); + DateTime nextRun = startNow ? now : now.Add(interval); + RecurringTask recurringTask = new(name, interval, action, error) { - DateTime now = DateTime.Now; - now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0); - DateTime nextRun = startNow ? now : now.Add(interval); - RecurringTask recurringTask = new(name, interval, action, error) - { - NextRun = nextRun - }; - _recurringTasks.Add(recurringTask); - } + NextRun = nextRun + }; + _recurringTasks.Add(recurringTask); } /// @@ -78,11 +74,9 @@ namespace Milimoe.FunGame.Core.Api.Utility /// public void RemoveTask(string name) { - lock (_lock) - { - int removeTasks = _tasks.RemoveAll(t => t.Name == name); - int removeRecurringTasks = _recurringTasks.RemoveAll(t => t.Name == name); - } + using Lock.Scope scope = _lock.EnterScope(); + int removeTasks = _tasks.RemoveAll(t => t.Name == name); + int removeRecurringTasks = _recurringTasks.RemoveAll(t => t.Name == name); } /// @@ -167,56 +161,54 @@ namespace Milimoe.FunGame.Core.Api.Utility /// private void CheckAndRunTasks() { - lock (_lock) + using Lock.Scope scope = _lock.EnterScope(); + DateTime now = DateTime.Now; + + foreach (ScheduledTask task in _tasks) { - DateTime now = DateTime.Now; - - foreach (ScheduledTask task in _tasks) + if (!task.IsTodayRun) { - if (!task.IsTodayRun) + if (now.TimeOfDay >= task.TimeOfDay && now.TimeOfDay < task.TimeOfDay.Add(TimeSpan.FromSeconds(10))) { - if (now.TimeOfDay >= task.TimeOfDay && now.TimeOfDay < task.TimeOfDay.Add(TimeSpan.FromSeconds(10))) - { - task.LastRun = now; - Task.Run(() => - { - try - { - task.Action(); - } - catch (Exception ex) - { - task.Error = ex; - TXTHelper.AppendErrorLog(ex.ToString()); - task.ErrorHandler?.Invoke(ex); - } - }); - } - } - } - - foreach (RecurringTask recurringTask in _recurringTasks) - { - if (now >= recurringTask.NextRun) - { - recurringTask.LastRun = now; - recurringTask.NextRun = recurringTask.NextRun.Add(recurringTask.Interval); + task.LastRun = now; Task.Run(() => { try { - recurringTask.Action(); + task.Action(); } catch (Exception ex) { - recurringTask.Error = ex; + task.Error = ex; TXTHelper.AppendErrorLog(ex.ToString()); - recurringTask.ErrorHandler?.Invoke(ex); + task.ErrorHandler?.Invoke(ex); } }); } } } + + foreach (RecurringTask recurringTask in _recurringTasks) + { + if (now >= recurringTask.NextRun) + { + recurringTask.LastRun = now; + recurringTask.NextRun = recurringTask.NextRun.Add(recurringTask.Interval); + Task.Run(() => + { + try + { + recurringTask.Action(); + } + catch (Exception ex) + { + recurringTask.Error = ex; + TXTHelper.AppendErrorLog(ex.ToString()); + recurringTask.ErrorHandler?.Invoke(ex); + } + }); + } + } } } } diff --git a/Entity/Skill/NormalAttack.cs b/Entity/Skill/NormalAttack.cs index f8d39c5..0582aaa 100644 --- a/Entity/Skill/NormalAttack.cs +++ b/Entity/Skill/NormalAttack.cs @@ -40,28 +40,31 @@ namespace Milimoe.FunGame.Core.Entity { baseMultiplier = Character.EquipSlot.Weapon.WeaponType switch { - WeaponType.OneHandedSword => 1.0, - WeaponType.TwoHandedSword => 1.2, - WeaponType.Bow => 0.9, - WeaponType.Pistol => 0.8, - WeaponType.Rifle => 1.1, - WeaponType.DualDaggers => 0.85, - WeaponType.Talisman => 1.0, - WeaponType.Staff => 1.15, - WeaponType.Polearm => 0.95, - WeaponType.Gauntlet => 1.05, - WeaponType.HiddenWeapon => 0.9, + WeaponType.OneHandedSword => GameplayEquilibriumConstant.OneHandedSwordBaseMultiplier, + WeaponType.TwoHandedSword => GameplayEquilibriumConstant.TwoHandedSwordBaseMultiplier, + WeaponType.Bow => GameplayEquilibriumConstant.BowBaseMultiplier, + WeaponType.Pistol => GameplayEquilibriumConstant.PistolBaseMultiplier, + WeaponType.Rifle => GameplayEquilibriumConstant.RifleBaseMultiplier, + WeaponType.DualDaggers => GameplayEquilibriumConstant.DualDaggersBaseMultiplier, + WeaponType.Talisman => GameplayEquilibriumConstant.TalismanBaseMultiplier, + WeaponType.Staff => GameplayEquilibriumConstant.StaffBaseMultiplier, + WeaponType.Polearm => GameplayEquilibriumConstant.PolearmBaseMultiplier, + WeaponType.Gauntlet => GameplayEquilibriumConstant.GauntletBaseMultiplier, + WeaponType.HiddenWeapon => GameplayEquilibriumConstant.HiddenWeaponBaseMultiplier, _ => 1.0 }; double levelBonus = Character.EquipSlot.Weapon.WeaponType switch { - WeaponType.TwoHandedSword => 0.06, - WeaponType.Staff => 0.056, - WeaponType.Bow => 0.045, - WeaponType.Pistol => 0.0375, - WeaponType.DualDaggers => 0.0375, - WeaponType.Polearm => 0.044, - WeaponType.HiddenWeapon => 0.044, + WeaponType.OneHandedSword => GameplayEquilibriumConstant.OneHandedSwordLevelBonus, + WeaponType.TwoHandedSword => GameplayEquilibriumConstant.TwoHandedSwordLevelBonus, + WeaponType.Bow => GameplayEquilibriumConstant.BowLevelBonus, + WeaponType.Pistol => GameplayEquilibriumConstant.PistolLevelBonus, + WeaponType.Rifle => GameplayEquilibriumConstant.RifleLevelBonus, + WeaponType.DualDaggers => GameplayEquilibriumConstant.DualDaggersLevelBonus, + WeaponType.Staff => GameplayEquilibriumConstant.StaffLevelBonus, + WeaponType.Polearm => GameplayEquilibriumConstant.PolearmLevelBonus, + WeaponType.Gauntlet => GameplayEquilibriumConstant.GauntletLevelBonus, + WeaponType.HiddenWeapon => GameplayEquilibriumConstant.HiddenWeaponLevelBonus, _ => 0.05 }; baseMultiplier += levelBonus * (Level - 1); @@ -137,17 +140,17 @@ namespace Milimoe.FunGame.Core.Entity { ht = Character.EquipSlot.Weapon.WeaponType switch { - WeaponType.OneHandedSword => 8, - WeaponType.TwoHandedSword => 12, - WeaponType.Bow => 9, - WeaponType.Pistol => 6, - WeaponType.Rifle => 11, - WeaponType.DualDaggers => 7, - WeaponType.Talisman => 10, - WeaponType.Staff => 12, - WeaponType.Polearm => 10, - WeaponType.Gauntlet => 8, - WeaponType.HiddenWeapon => 7, + WeaponType.OneHandedSword => GameplayEquilibriumConstant.OneHandedSwordHardness, + WeaponType.TwoHandedSword => GameplayEquilibriumConstant.TwoHandedSwordHardness, + WeaponType.Bow => GameplayEquilibriumConstant.BowHardness, + WeaponType.Pistol => GameplayEquilibriumConstant.PistolHardness, + WeaponType.Rifle => GameplayEquilibriumConstant.RifleHardness, + WeaponType.DualDaggers => GameplayEquilibriumConstant.DualDaggersHardness, + WeaponType.Talisman => GameplayEquilibriumConstant.TalismanHardness, + WeaponType.Staff => GameplayEquilibriumConstant.StaffHardness, + WeaponType.Polearm => GameplayEquilibriumConstant.PolearmHardness, + WeaponType.Gauntlet => GameplayEquilibriumConstant.GauntletHardness, + WeaponType.HiddenWeapon => GameplayEquilibriumConstant.HiddenWeaponHardness, _ => 10, }; } diff --git a/Entity/System/RoundRecord.cs b/Entity/System/RoundRecord.cs index c7f5774..66866b0 100644 --- a/Entity/System/RoundRecord.cs +++ b/Entity/System/RoundRecord.cs @@ -68,7 +68,7 @@ namespace Milimoe.FunGame.Core.Entity if (ActorContinuousKilling.Count > 0) builder.AppendLine($"{string.Join("\r\n", ActorContinuousKilling)}"); if (Assists.Count > 0) builder.AppendLine($"本回合助攻:[ {string.Join(" ] / [ ", Assists)} ]"); } - + if (ActionType == CharacterActionType.PreCastSkill && Skill != null) { if (Skill.IsMagic) @@ -77,11 +77,17 @@ namespace Milimoe.FunGame.Core.Entity } else { - builder.AppendLine($"[ {Actor} ]:{Skill.Name}({SkillCost})-> "); + builder.Append($"[ {Actor} ] {Skill.Name}({SkillCost})-> "); builder.AppendLine(string.Join(" / ", GetTargetsState())); builder.AppendLine($"[ {Actor} ] 回合结束,硬直时间:{HardnessTime:0.##}"); } } + else if (ActionType == CharacterActionType.UseItem && Item != null) + { + builder.Append($"[ {Actor} ] {Item.Name}{(SkillCost != "" ? $"({SkillCost})" : " ")}-> "); + builder.AppendLine(string.Join(" / ", GetTargetsState())); + builder.AppendLine($"[ {Actor} ] 回合结束,硬直时间:{HardnessTime:0.##}"); + } else { builder.AppendLine($"[ {Actor} ] 回合结束,硬直时间:{HardnessTime:0.##}"); @@ -140,7 +146,9 @@ namespace Milimoe.FunGame.Core.Entity hasDamage = "免疫"; } string[] strs = [hasDamage, hasHeal, hasEffect]; - strings.Add($"[ {target}({string.Join(" / ", strs.Where(s => s != ""))})])"); + strs = [.. strs.Where(s => s != "")]; + if (strs.Length == 0) strings.Add($"[ {target} ])"); + else strings.Add($"[ {target}({string.Join(" / ", strs)})])"); } return strings; } diff --git a/Library/Constant/ConstantSet.cs b/Library/Constant/ConstantSet.cs index 06629e1..9ca1889 100644 --- a/Library/Constant/ConstantSet.cs +++ b/Library/Constant/ConstantSet.cs @@ -719,6 +719,7 @@ namespace Milimoe.FunGame.Core.Library.Constant EffectType.GrievousWound => "重伤", EffectType.WeakDispelling => "持续性弱驱散", EffectType.StrongDispelling => "持续性强驱散", + EffectType.Recovery => "恢复", _ => "未知效果" }; } @@ -776,6 +777,7 @@ namespace Milimoe.FunGame.Core.Library.Constant EffectType.Lifesteal => DispelledType.Weak, EffectType.GrievousWound => DispelledType.Weak, EffectType.WeakDispelling => DispelledType.Weak, + EffectType.Recovery => DispelledType.Weak, _ => DispelledType.Weak }; } @@ -831,6 +833,9 @@ namespace Milimoe.FunGame.Core.Library.Constant EffectType.EvadeBoost => false, EffectType.Lifesteal => false, EffectType.GrievousWound => true, + EffectType.WeakDispelling => false, + EffectType.StrongDispelling => false, + EffectType.Recovery => false, _ => false }; } diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index d734c85..d15a3b1 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -479,7 +479,12 @@ namespace Milimoe.FunGame.Core.Library.Constant /// /// 持续性强驱散 /// - StrongDispelling + StrongDispelling, + + /// + /// 恢复 + /// + Recovery } public enum ItemType diff --git a/Model/EquilibriumConstant.cs b/Model/EquilibriumConstant.cs index 53fdd74..04c550e 100644 --- a/Model/EquilibriumConstant.cs +++ b/Model/EquilibriumConstant.cs @@ -295,6 +295,171 @@ namespace Milimoe.FunGame.Core.Model /// public double TakenDamageGetEPMax { get; set; } = 15; + /// + /// 单手剑的基础伤害倍率 + /// + public double OneHandedSwordBaseMultiplier { get; set; } = 1.0; + + /// + /// 单手剑的基础伤害倍率成长 + /// + public double OneHandedSwordLevelBonus { get; set; } = 0.05; + + /// + /// 双手剑的基础伤害倍率 + /// + public double TwoHandedSwordBaseMultiplier { get; set; } = 1.2; + + /// + /// 双手剑的基础伤害倍率成长 + /// + public double TwoHandedSwordLevelBonus { get; set; } = 0.06; + + /// + /// 弓的基础伤害倍率 + /// + public double BowBaseMultiplier { get; set; } = 0.9; + + /// + /// 弓的基础伤害倍率成长 + /// + public double BowLevelBonus { get; set; } = 0.04; + + /// + /// 手枪的基础伤害倍率 + /// + public double PistolBaseMultiplier { get; set; } = 0.9; + + /// + /// 手枪的基础伤害倍率成长 + /// + public double PistolLevelBonus { get; set; } = 0.03; + + /// + /// 步枪的基础伤害倍率 + /// + public double RifleBaseMultiplier { get; set; } = 1.1; + + /// + /// 步枪的基础伤害倍率成长 + /// + public double RifleLevelBonus { get; set; } = 0.05; + + /// + /// 双持短刀的基础伤害倍率 + /// + public double DualDaggersBaseMultiplier { get; set; } = 0.85; + + /// + /// 双持短刀的基础伤害倍率成长 + /// + public double DualDaggersLevelBonus { get; set; } = 0.04; + + /// + /// 法器的基础伤害倍率 + /// + public double TalismanBaseMultiplier { get; set; } = 1.0; + + /// + /// 法器的基础伤害倍率成长 + /// + public double TalismanLevelBonus { get; set; } = 0.05; + + /// + /// 法杖的基础伤害倍率 + /// + public double StaffBaseMultiplier { get; set; } = 1.15; + + /// + /// 法杖的基础伤害倍率成长 + /// + public double StaffLevelBonus { get; set; } = 0.04; + + /// + /// 长柄武器的基础伤害倍率 + /// + public double PolearmBaseMultiplier { get; set; } = 0.95; + + /// + /// 长柄武器的基础伤害倍率成长 + /// + public double PolearmLevelBonus { get; set; } = 0.05; + + /// + /// 拳套的基础伤害倍率 + /// + public double GauntletBaseMultiplier { get; set; } = 1.05; + + /// + /// 拳套的基础伤害倍率成长 + /// + public double GauntletLevelBonus { get; set; } = 0.05; + + /// + /// 暗器的基础伤害倍率 + /// + public double HiddenWeaponBaseMultiplier { get; set; } = 0.9; + + /// + /// 暗器的基础伤害倍率成长 + /// + public double HiddenWeaponLevelBonus { get; set; } = 0.05; + + /// + /// 单手剑的硬直时间 + /// + public double OneHandedSwordHardness { get; set; } = 8; + + /// + /// 双手剑的硬直时间 + /// + public double TwoHandedSwordHardness { get; set; } = 12; + + /// + /// 弓的硬直时间 + /// + public double BowHardness { get; set; } = 9; + + /// + /// 手枪的硬直时间 + /// + public double PistolHardness { get; set; } = 6; + + /// + /// 步枪的硬直时间 + /// + public double RifleHardness { get; set; } = 11; + + /// + /// 双持短刀的硬直时间 + /// + public double DualDaggersHardness { get; set; } = 7; + + /// + /// 法器的硬直时间 + /// + public double TalismanHardness { get; set; } = 10; + + /// + /// 法杖的硬直时间 + /// + public double StaffHardness { get; set; } = 12; + + /// + /// 长柄武器的硬直时间 + /// + public double PolearmHardness { get; set; } = 10; + + /// + /// 拳套的硬直时间 + /// + public double GauntletHardness { get; set; } = 8; + + /// + /// 暗器的硬直时间 + /// + public double HiddenWeaponHardness { get; set; } = 7; + /// /// 应用此游戏平衡常数给实体 /// diff --git a/Model/GamingQueue.cs b/Model/GamingQueue.cs index f40ace3..28c5364 100644 --- a/Model/GamingQueue.cs +++ b/Model/GamingQueue.cs @@ -1730,7 +1730,10 @@ namespace Milimoe.FunGame.Core.Model CalculateCharacterDamageStatistics(actor, enemy, damage, damageType, actualDamage); // 计算助攻 - _assistDetail[actor][enemy, TotalTime] += damage; + if (actor != enemy && !IsTeammate(actor, enemy)) + { + _assistDetail[actor][enemy, TotalTime] += damage; + } } } else @@ -2875,7 +2878,7 @@ namespace Milimoe.FunGame.Core.Model { foreach (Character target in targets) { - if (character == target) continue; + if (character == target || IsTeammate(character, target)) continue; _assistDetail[character].NotDamageAssistLastTime[target] = TotalTime; } }