using NeonSprawl.Server.Game.Mastery;

namespace NeonSprawl.Server.Game.Skills;

/// <summary>
/// NEO-42: E3.M2 craft/refine success should call <see cref="GrantOnSuccessfulCraftOrRefine"/> so XP uses the same path as
/// <c>POST …/skill-progression</c>. Outcome is ignored on success paths (mirror gather interact); use
/// <see cref="SkillProgressionGrantOperations.TryApplyGrant"/> directly when callers need deny envelopes.
/// </summary>
public static class RefineActivitySkillXpGrant
{
    /// <summary>Applies one <c>refine</c> + <c>activity</c> grant if the catalog allowlist permits it.</summary>
    /// <remarks>Pass a normalized <paramref name="playerId"/> (e.g. route-trimmed), matching <c>InteractionApi</c> gather hook callers.</remarks>
    public static void GrantOnSuccessfulCraftOrRefine(
        string playerId,
        ISkillDefinitionRegistry registry,
        IPlayerSkillProgressionStore xpStore,
        ISkillLevelCurve levelCurve,
        PerkUnlockEngine perkUnlockEngine)
    {
        _ = SkillProgressionGrantOperations.TryApplyGrant(
            playerId,
            RefineSkillXpConstants.RefineSkillId,
            RefineSkillXpConstants.ActivityXpPerCraftRefineCompletion,
            RefineSkillXpConstants.ActivitySourceKind,
            registry,
            xpStore,
            levelCurve,
            perkUnlockEngine);
    }
}
