namespace FishDice.LuckyDice
{
    public sealed class GrantRewardExecutor : IRollActionExecutor
    {
        public string ActionType => LuckyDiceKeys.GrantRewardAction;

        public RollActionResult Execute(RollActionContext context, RollActionSpec action)
        {
            return RollActionResult.Succeeded(
                action.ActionType,
                new RollEffect[] { new RewardEffect() });
        }
    }

    public sealed class AddMultiplierExecutor : IRollActionExecutor
    {
        public string ActionType => LuckyDiceKeys.AddMultiplierAction;

        public RollActionResult Execute(RollActionContext context, RollActionSpec action)
        {
            action.Params.TryGetValue("reason", out var reason);
            return RollActionResult.Succeeded(
                action.ActionType,
                new RollEffect[] { new MultiplierEffect(reason) });
        }
    }

    public sealed class TriggerLuckyDiceExecutor : IRollActionExecutor
    {
        public string ActionType => LuckyDiceKeys.TriggerLuckyDiceAction;

        public RollActionResult Execute(RollActionContext context, RollActionSpec action)
        {
            return RollActionResult.Succeeded(
                action.ActionType,
                new RollEffect[] { new LuckyDiceRequestedEffect() });
        }
    }
}
