using NeonSprawl.Server.Game.Items; namespace NeonSprawl.Server.Game.Encounters; /// /// NEO-106: wires ability-cast combat outcomes to encounter activation, defeat progress, and completion grants. /// Best-effort on the cast accept path — outcome does not change AbilityCastResponse JSON. /// public static class EncounterCombatWiring { /// /// On damaging hits, activates encounter progress; on lethal hits, records defeat and may grant rewards. /// public static void TryProcessCastOutcome( string playerId, string targetNpcInstanceId, int damageDealt, bool targetDefeated, IEncounterDefinitionRegistry encounterRegistry, IRewardTableDefinitionRegistry rewardTableRegistry, IEncounterProgressStore progressStore, IEncounterCompletionStore completionStore, IEncounterCompleteEventStore completeEventStore, IItemDefinitionRegistry itemRegistry, IPlayerInventoryStore inventoryStore, TimeProvider timeProvider, ILogger? logger = null) { if (damageDealt > 0) { EncounterProgressOperations.TryActivateOnFirstEngagement( playerId, targetNpcInstanceId, encounterRegistry, progressStore, completionStore); } if (!targetDefeated) { return; } if (!EncounterProgressOperations.TryMarkTargetDefeated( playerId, targetNpcInstanceId, encounterRegistry, progressStore, completionStore)) { return; } if (!EncounterProgressOperations.TryResolveEncounterForNpc( targetNpcInstanceId, encounterRegistry, out var encounterId, out _)) { return; } if (!EncounterProgressOperations.IsAllRequiredTargetsDefeated( playerId, encounterId, encounterRegistry, progressStore)) { return; } var completion = EncounterCompletionOperations.TryCompleteAndGrant( playerId, encounterId, encounterRegistry, rewardTableRegistry, progressStore, completionStore, completeEventStore, itemRegistry, inventoryStore, timeProvider); if (!completion.Success) { logger?.LogDebug( "Encounter completion grant skipped for player {PlayerId} encounter {EncounterId} ({ReasonCode})", playerId, encounterId, completion.ReasonCode); } // encounter_complete / reward_attribution hooks: EncounterCompletionOperations.TryCompleteAndGrant (NEO-109). } }