From 607d36e23ae5dcbf32f3795a58d5846f9c29ba94 Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 6 Sep 2025 03:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=A4=84=E4=BA=8E=E5=85=8D=E7=96=AB=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=98=9F=E5=8F=8B=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=A1=BA=E5=BA=8F=E8=A1=A8=E6=8E=92=E5=BA=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Skill/NormalAttack.cs | 2 +- Entity/Skill/Skill.cs | 3 +- Model/GamingQueue.cs | 56 ++++++++++++++---------------------- 3 files changed, 23 insertions(+), 38 deletions(-) diff --git a/Entity/Skill/NormalAttack.cs b/Entity/Skill/NormalAttack.cs index 4d9c6f1..1cf8c98 100644 --- a/Entity/Skill/NormalAttack.cs +++ b/Entity/Skill/NormalAttack.cs @@ -264,7 +264,7 @@ namespace Milimoe.FunGame.Core.Entity foreach (Character character in teammates) { - if (CanSelectTeammate && ((character.ImmuneType & ImmuneType.All) != ImmuneType.All || IgnoreImmune == ImmuneType.All)) + if (CanSelectTeammate) { selectable.Add(character); } diff --git a/Entity/Skill/Skill.cs b/Entity/Skill/Skill.cs index e66b614..01c8675 100644 --- a/Entity/Skill/Skill.cs +++ b/Entity/Skill/Skill.cs @@ -365,8 +365,7 @@ namespace Milimoe.FunGame.Core.Entity foreach (Character character in teammates) { IEnumerable effects = character.Effects.Where(e => e.IsInEffect); - if (CanSelectTeammate && ((character.ImmuneType & checkType) == ImmuneType.None || - effects.Any(e => e.IgnoreImmune == ImmuneType.All || e.IgnoreImmune == ImmuneType.Skilled || (IsMagic && e.IgnoreImmune == ImmuneType.Magical)))) + if (CanSelectTeammate) { selectable.Add(character); } diff --git a/Model/GamingQueue.cs b/Model/GamingQueue.cs index 26c9363..b4067c2 100644 --- a/Model/GamingQueue.cs +++ b/Model/GamingQueue.cs @@ -449,19 +449,25 @@ namespace Milimoe.FunGame.Core.Model // 确保角色不在队列中 _queue.RemoveAll(c => c == character); - // 插队机制:按硬直时间排序 - int insertIndex = _queue.FindIndex(c => _hardnessTimes[c] > hardnessTime); - double addHardnessTime = 0.01; - while (_hardnessTimes.Any(kv => kv.Key != character && kv.Value == hardnessTime)) + // 增加硬直时间直到唯一 + double ResolveConflict(double time, Character c) { - insertIndex++; - if (insertIndex != 0 && _queue.Count > insertIndex) + while (_hardnessTimes.Any(kv => kv.Key != c && kv.Value == time)) { - addHardnessTime += Calculation.Round2Digits(_hardnessTimes[_queue[insertIndex]] - _hardnessTimes[_queue[insertIndex - 1]]); + time = Calculation.Round2Digits(time + 0.01); } - hardnessTime = Calculation.Round2Digits(hardnessTime + addHardnessTime); + return time; } + // 初始插入索引:第一个硬直时间大于当前值的角色位置 + int insertIndex = _queue.FindIndex(c => _hardnessTimes[c] > hardnessTime); + + // 调整硬直时间以避免冲突 + hardnessTime = ResolveConflict(hardnessTime, character); + + // 重新计算插入索引 + insertIndex = _queue.FindIndex(c => _hardnessTimes[c] > hardnessTime); + if (isCheckProtected) { // 查找保护条件 被插队超过此次数便能获得插队补偿 即行动保护 @@ -481,35 +487,15 @@ namespace Milimoe.FunGame.Core.Model Character lastProtectedCharacter = list.Last().Character; double lastProtectedHardnessTime = _hardnessTimes[lastProtectedCharacter]; - // 查找与最后一个受保护角色相同硬直时间的其他角色 - var sameHardnessList = _queue - .Select((c, index) => new { Character = c, Index = index }) - .Where(x => _hardnessTimes[x.Character] == lastProtectedHardnessTime && x.Index > protectIndex); + // 设置新的硬直时间大于保护角色的硬直时间 + hardnessTime = lastProtectedHardnessTime + 0.01; + hardnessTime = ResolveConflict(hardnessTime, character); - // 如果找到了相同硬直时间的角色,更新 protectIndex 为它们中最后一个的索引 - if (sameHardnessList.Any()) - { - protectIndex = sameHardnessList.Select(x => x.Index).Last(); - } + // 重新计算插入索引 + insertIndex = _queue.FindIndex(c => _hardnessTimes[c] > hardnessTime); - // 判断是否需要插入到受保护角色的后面 - if (insertIndex != -1 && insertIndex <= protectIndex) - { - // 如果按硬直时间插入的位置在受保护角色之前或相同,则插入到受保护角色的后面一位 - insertIndex = protectIndex + 1; - hardnessTime = lastProtectedHardnessTime + 0.01; - while (_hardnessTimes.Any(kv => kv.Key != character && kv.Value == hardnessTime)) - { - if (insertIndex != 0 && _queue.Count > insertIndex) - { - addHardnessTime += Calculation.Round2Digits(_hardnessTimes[_queue[insertIndex]] - _hardnessTimes[_queue[insertIndex - 1]]); - } - hardnessTime = Calculation.Round2Digits(hardnessTime + addHardnessTime); - } - - // 列出受保护角色的名单 - WriteLine($"由于 [ {string.Join(" ],[ ", list.Select(x => x.Character))} ] 受到行动保护,因此角色 [ {character} ] 将插入至顺序表第 {insertIndex + 1} 位。"); - } + // 列出受保护角色的名单 + WriteLine($"由于 [ {string.Join(" ],[ ", list.Select(x => x.Character))} ] 受到行动保护,因此角色 [ {character} ] 将插入至顺序表第 {insertIndex + 1} 位。"); } }