修复召唤物击杀最后一个敌人时无法结算的问题

This commit is contained in:
milimoe 2026-04-09 01:00:52 +08:00
parent 4622d34cac
commit 4b5fcfccb1
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
2 changed files with 24 additions and 2 deletions

View File

@ -2058,7 +2058,7 @@ namespace Milimoe.FunGame.Core.Model
/// <param name="assists"></param> /// <param name="assists"></param>
protected virtual void AfterDeathCalculation(Character death, Character? killer, Character[] assists) protected virtual void AfterDeathCalculation(Character death, Character? killer, Character[] assists)
{ {
if (!_queue.Any(c => c != killer && (c.Master is null || c.Master != killer))) if (_queue.All(c => IsSameFactionAs(c, killer)))
{ {
// 没有其他的角色了,游戏结束 // 没有其他的角色了,游戏结束
if (killer != null) if (killer != null)
@ -3828,6 +3828,28 @@ namespace Milimoe.FunGame.Core.Model
return dp; return dp;
} }
/// <summary>
/// 判断两个角色是否是同一阵营(仅用于混战模式,团队模式下请用 <see cref="IsTeammate"/>
/// </summary>
/// <param name="character"></param>
/// <param name="target"></param>
/// <returns></returns>
public static bool IsSameFactionAs(Character character, Character? target)
{
if (target == null) return false;
// 双方互相为上级
if (character.Master == target || target.Master == character)
return true;
// 双方都没有上级
if (character.Master == null && target.Master == null)
return character == target;
// 是否是同一上级
return character.Master == target.Master;
}
#endregion #endregion
#region #region

View File

@ -23,7 +23,7 @@ namespace Milimoe.FunGame.Core.Model
.Select(kv => $"[ {kv.Key} ] {kv.Value.Kills} 分"))}\r\n剩余存活人数{_queue.Count}"); .Select(kv => $"[ {kv.Key} ] {kv.Value.Kills} 分"))}\r\n剩余存活人数{_queue.Count}");
} }
if (!_queue.Any(c => c != killer && (c.Master is null || c.Master != killer))) if (_queue.All(c => IsSameFactionAs(c, killer)))
{ {
// 没有其他的角色了,游戏结束 // 没有其他的角色了,游戏结束
EndGameInfo(killer); EndGameInfo(killer);