using NeonSprawl.Server.Game.Npc;
namespace NeonSprawl.Server.Game.Combat;
/// Deterministic NPC telegraph-complete damage resolve (NEO-95).
public static class NpcAttackOperations
{
///
/// Applies catalog to when
/// the threat row still names that holder for .
///
public static bool TryResolveTelegraphComplete(
string npcInstanceId,
string holderPlayerId,
int attackDamage,
IPlayerCombatHealthStore playerHealthStore,
IThreatStateStore threatStore)
{
if (attackDamage <= 0)
{
return true;
}
if (string.IsNullOrWhiteSpace(holderPlayerId) ||
!threatStore.TryGet(npcInstanceId, out var threat) ||
string.IsNullOrEmpty(threat.AggroHolderPlayerId) ||
!string.Equals(threat.AggroHolderPlayerId, holderPlayerId, StringComparison.Ordinal))
{
return false;
}
if (!playerHealthStore.TryApplyDamage(holderPlayerId, attackDamage, out var snapshot))
{
return false;
}
if (snapshot.Defeated)
{
// TODO(E9.M1): player_death
}
return true;
}
}