冗余问题修复

This commit is contained in:
milimoe 2025-06-19 21:31:20 +08:00
parent 6bf3bb09a9
commit 496f5d0675
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
5 changed files with 86 additions and 34 deletions

View File

@ -1382,7 +1382,7 @@ namespace Milimoe.FunGame.Core.Entity
List<string> shield = [];
if (Shield.TotalPhysical > 0) shield.Add($"物理:{Shield.TotalPhysical:0.##}");
if (Shield.TotalMagicial > 0) shield.Add($"魔法:{Shield.TotalMagicial:0.##}");
if (Shield.Mix > 0) shield.Add($"混合:{Shield.Mix:0.##}");
if (Shield.TotalMix > 0) shield.Add($"混合:{Shield.TotalMix:0.##}");
builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "") + (shield.Count > 0 ? $"{string.Join("", shield)}" : ""));
double exMP = ExMP + ExMP2 + ExMP3;
builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : ""));
@ -1516,7 +1516,7 @@ namespace Milimoe.FunGame.Core.Entity
List<string> shield = [];
if (Shield.TotalPhysical > 0) shield.Add($"物理:{Shield.TotalPhysical:0.##}");
if (Shield.TotalMagicial > 0) shield.Add($"魔法:{Shield.TotalMagicial:0.##}");
if (Shield.Mix > 0) shield.Add($"混合:{Shield.Mix:0.##}");
if (Shield.TotalMix > 0) shield.Add($"混合:{Shield.TotalMix:0.##}");
builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "") + (shield.Count > 0 ? $"{string.Join("", shield)}" : ""));
double exMP = ExMP + ExMP2 + ExMP3;
builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : ""));
@ -1624,7 +1624,7 @@ namespace Milimoe.FunGame.Core.Entity
List<string> shield = [];
if (Shield.TotalPhysical > 0) shield.Add($"物理:{Shield.TotalPhysical:0.##}");
if (Shield.TotalMagicial > 0) shield.Add($"魔法:{Shield.TotalMagicial:0.##}");
if (Shield.Mix > 0) shield.Add($"混合:{Shield.Mix:0.##}");
if (Shield.TotalMix > 0) shield.Add($"混合:{Shield.TotalMix:0.##}");
builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "") + (shield.Count > 0 ? $"{string.Join("", shield)}" : ""));
double exMP = ExMP + ExMP2 + ExMP3;
builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : ""));
@ -1677,7 +1677,7 @@ namespace Milimoe.FunGame.Core.Entity
List<string> shield = [];
if (Shield.TotalPhysical > 0) shield.Add($"物理:{Shield.TotalPhysical:0.##}");
if (Shield.TotalMagicial > 0) shield.Add($"魔法:{Shield.TotalMagicial:0.##}");
if (Shield.Mix > 0) shield.Add($"混合:{Shield.Mix:0.##}");
if (Shield.TotalMix > 0) shield.Add($"混合:{Shield.TotalMix:0.##}");
builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "") + (shield.Count > 0 ? $"{string.Join("", shield)}" : ""));
double exMP = ExMP + ExMP2 + ExMP3;
builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : ""));
@ -1765,7 +1765,7 @@ namespace Milimoe.FunGame.Core.Entity
List<string> shield = [];
if (Shield.TotalPhysical > 0) shield.Add($"物理:{Shield.TotalPhysical:0.##}");
if (Shield.TotalMagicial > 0) shield.Add($"魔法:{Shield.TotalMagicial:0.##}");
if (Shield.Mix > 0) shield.Add($"混合:{Shield.Mix:0.##}");
if (Shield.TotalMix > 0) shield.Add($"混合:{Shield.TotalMix:0.##}");
builder.AppendLine($"生命值:{HP:0.##} / {MaxHP:0.##}" + (exHP != 0 ? $" [{BaseHP:0.##} {(exHP >= 0 ? "+" : "-")} {Math.Abs(exHP):0.##}]" : "") + (shield.Count > 0 ? $"{string.Join("", shield)}" : ""));
double exMP = ExMP + ExMP2 + ExMP3;
builder.AppendLine($"魔法值:{MP:0.##} / {MaxMP:0.##}" + (exMP != 0 ? $" [{BaseMP:0.##} {(exMP >= 0 ? "+" : "-")} {Math.Abs(exMP):0.##}]" : ""));

View File

@ -67,15 +67,20 @@ namespace Milimoe.FunGame.Core.Entity
/// </summary>
public double Mix { get; set; } = 0;
/// <summary>
/// 总计混合护盾
/// </summary>
public double TotalMix => Mix + ShieldOfEffects.Values.Where(soe => soe.ShieldType == ShieldType.Mix && soe.Shield > 0).Sum(soe => soe.Shield);
/// <summary>
/// 总计物理护盾
/// </summary>
public double TotalPhysical => Physical + ShieldOfEffects.Values.Where(soe => !soe.IsMagic && soe.Shield > 0).Sum(soe => soe.Shield);
public double TotalPhysical => Physical + ShieldOfEffects.Values.Where(soe => soe.ShieldType == ShieldType.Physical && soe.Shield > 0).Sum(soe => soe.Shield);
/// <summary>
/// 总计魔法护盾
/// </summary>
public double TotalMagicial => None + Starmark + PurityNatural + PurityContemporary + Bright + Shadow + Element + Aster + SpatioTemporal + ShieldOfEffects.Values.Where(soe => soe.IsMagic && soe.Shield > 0).Sum(soe => soe.Shield);
public double TotalMagicial => None + Starmark + PurityNatural + PurityContemporary + Bright + Shadow + Element + Aster + SpatioTemporal + ShieldOfEffects.Values.Where(soe => soe.ShieldType == ShieldType.Magical && soe.Shield > 0).Sum(soe => soe.Shield);
/// <summary>
/// 获取或设置护盾值
@ -212,13 +217,13 @@ namespace Milimoe.FunGame.Core.Entity
/// </summary>
/// <param name="effect"></param>
/// <param name="shield"></param>
/// <param name="isMagic"></param>
/// <param name="type"></param>
public class ShieldOfEffect(Effect effect, double shield, bool isMagic = false, MagicType type = MagicType.None)
/// <param name="shieldType"></param>
/// <param name="magicType"></param>
public class ShieldOfEffect(Effect effect, double shield, ShieldType shieldType, MagicType magicType = MagicType.None)
{
public Effect Effect { get; } = effect;
public bool IsMagic { get; set; } = isMagic;
public MagicType MagicType { get; set; } = type;
public ShieldType ShieldType { get; set; } = shieldType;
public MagicType MagicType { get; set; } = magicType;
public double Shield { get; set; } = shield;
public double Calculate(double damage)

View File

@ -347,19 +347,19 @@ namespace Milimoe.FunGame.Core.Entity
return false;
}
/// <summary>
/// 使用后减少使用次数或删除物品
/// </summary>
public void ReduceTimesAndRemove()
{
if (User != null)
if (IsReduceTimesAfterUse)
{
if (IsReduceTimesAfterUse)
{
RemainUseTimes--;
}
if (RemainUseTimes < 0) RemainUseTimes = 0;
if (IsRemoveAfterUse && RemainUseTimes == 0)
{
EntityState = EntityState.Deleted;
}
RemainUseTimes--;
}
if (RemainUseTimes < 0) RemainUseTimes = 0;
if (IsRemoveAfterUse && RemainUseTimes == 0)
{
EntityState = EntityState.Deleted;
}
}

View File

@ -448,8 +448,10 @@ namespace Milimoe.FunGame.Core.Entity
/// 返回技能的详细说明
/// </summary>
/// <param name="showOriginal"></param>
/// <param name="showCD"></param>
/// <param name="showHardness"></param>
/// <returns></returns>
public string GetInfo(bool showOriginal = false)
public string GetInfo(bool showOriginal = false, bool showCD = true, bool showHardness = true)
{
StringBuilder builder = new();
@ -505,8 +507,14 @@ namespace Milimoe.FunGame.Core.Entity
}
}
}
builder.AppendLine($"冷却时间:{RealCD:0.##}{(showOriginal && RealCD != CD ? $"{CD}" : "")}");
builder.AppendLine($"硬直时间:{RealHardnessTime:0.##}{(showOriginal && RealHardnessTime != HardnessTime ? $"{HardnessTime}" : "")}");
if (showCD && CD > 0)
{
builder.AppendLine($"冷却时间:{RealCD:0.##}{(showOriginal && RealCD != CD ? $"{CD}" : "")}");
}
if (showHardness && HardnessTime > 0)
{
builder.AppendLine($"硬直时间:{RealHardnessTime:0.##}{(showOriginal && RealHardnessTime != HardnessTime ? $"{HardnessTime}" : "")}");
}
}
return builder.ToString();
@ -518,6 +526,18 @@ namespace Milimoe.FunGame.Core.Entity
/// <returns></returns>
public override string ToString() => GetInfo(true);
/// <summary>
/// 返回技能的详细说明,有选项
/// </summary>
/// <param name="showOriginal"></param>
/// <param name="showCD"></param>
/// <param name="showHardness"></param>
/// <returns></returns>
public string ToString(bool showOriginal, bool showCD, bool showHardness)
{
return GetInfo(showOriginal, showCD, showHardness);
}
/// <summary>
/// 判断两个技能是否相同 检查Id.Name
/// </summary>

View File

@ -285,8 +285,22 @@ namespace Milimoe.FunGame.Core.Model
_original.Add(original.Guid, original);
}
// 获取 HP 小于等于 0 的角色
List<Character> deadCharacters = [.. characters.Where(c => c.HP <= 0)];
foreach (Character death in deadCharacters)
{
if (MaxRespawnTimes != 0 || (MaxRespawnTimes != -1 && _respawnTimes.TryGetValue(death, out int times) && times < MaxRespawnTimes))
{
// 进入复活倒计时
double respawnTime = 5;
_respawnCountdown.TryAdd(death, respawnTime);
WriteLine($"[ {death} ] 进入复活倒计时:{respawnTime:0.##} {GameplayEquilibriumConstant.InGameTime}");
}
}
// 初始排序:按速度排序
List<IGrouping<double, Character>> groupedBySpeed = [.. characters
.Where(c => c.HP > 0)
.GroupBy(c => c.SPD)
.OrderByDescending(g => g.Key)];
@ -623,7 +637,7 @@ namespace Milimoe.FunGame.Core.Model
// 如果特效具备临时驱散或者持续性驱散的功能
if (effect.Source != null && (effect.EffectType == EffectType.WeakDispelling || effect.EffectType == EffectType.StrongDispelling))
{
effect.Dispel(effect.Source, character, IsTeammate(character, effect.Source));
effect.Dispel(effect.Source, character, !IsTeammate(character, effect.Source) && character != effect.Source);
}
// 自身被动不会考虑
@ -1495,7 +1509,19 @@ namespace Milimoe.FunGame.Core.Model
foreach (Effect effect in effects)
{
ShieldOfEffect soe = enemy.Shield.ShieldOfEffects[effect];
if (soe.IsMagic == (damageType == DamageType.Magical) && (damageType == DamageType.Physical || soe.MagicType == magicType) && soe.Shield > 0)
bool checkType = false;
switch (damageType)
{
case DamageType.Physical:
checkType = soe.ShieldType == ShieldType.Physical || soe.ShieldType == ShieldType.Mix;
break;
case DamageType.Magical:
checkType = (soe.ShieldType == ShieldType.Magical && soe.MagicType == magicType) || soe.ShieldType == ShieldType.Mix;
break;
default:
break;
}
if (checkType && soe.Shield > 0)
{
double effectShield = soe.Shield;
// 判断护盾余额
@ -1573,9 +1599,9 @@ namespace Milimoe.FunGame.Core.Model
}
// 检查混合护盾
if (remain > 0 && enemy.Shield.Mix > 0)
if (remain > 0 && enemy.Shield.TotalMix > 0)
{
shield = enemy.Shield.Mix;
shield = enemy.Shield.TotalMix;
shield -= remain;
if (shield > 0)
{
@ -1590,8 +1616,8 @@ namespace Milimoe.FunGame.Core.Model
}
else
{
WriteLine($"[ {enemy} ] 的混合护盾抵消了 {enemy.Shield.Mix:0.##} 点{damageTypeString}并破碎!");
remain -= enemy.Shield.Mix;
WriteLine($"[ {enemy} ] 的混合护盾抵消了 {enemy.Shield.TotalMix:0.##} 点{damageTypeString}并破碎!");
remain -= enemy.Shield.TotalMix;
enemy.Shield.Mix = 0;
effects = [.. characters.SelectMany(c => c.Effects.Where(e => e.IsInEffect)).Distinct()];
foreach (Effect effect in effects)
@ -2465,7 +2491,7 @@ namespace Milimoe.FunGame.Core.Model
}
/// <summary>
/// 判断目标对于某个角色是否是队友
/// 判断目标对于某个角色是否是队友(不包括自己)
/// </summary>
/// <param name="character"></param>
/// <param name="target"></param>
@ -2477,7 +2503,7 @@ namespace Milimoe.FunGame.Core.Model
}
/// <summary>
/// 获取目标对于某个角色是否是友方的字典
/// 获取目标对于某个角色是否是友方的字典(包括自己)
/// </summary>
/// <param name="character"></param>
/// <param name="targets"></param>
@ -2488,7 +2514,8 @@ namespace Milimoe.FunGame.Core.Model
List<Character> teammates = GetTeammates(character);
foreach (Character target in targets)
{
dict[target] = teammates.Contains(target);
if (character == target) dict[target] = true;
else dict[target] = teammates.Contains(target);
}
return dict;
}