<?php

namespace App\Actions\TopUp;

use App\DTOs\GoldCalculationData;

final class CalculateGoldAction
{
    public function handle(
        int $amount,
        int $goldRate,
        float $factionBonusPercentage = 0,
        int $promoBonusGold = 0,
        int $streamerBonusGold = 0,
    ): GoldCalculationData {
        $baseGold = (int) floor($amount / $goldRate);
        $factionBonusGold = (int) floor($baseGold * ($factionBonusPercentage / 100));

        return new GoldCalculationData(
            baseGold: $baseGold,
            factionBonusGold: $factionBonusGold,
            promoBonusGold: $promoBonusGold,
            streamerBonusGold: $streamerBonusGold,
            totalGold: $baseGold + $factionBonusGold + $promoBonusGold + $streamerBonusGold,
        );
    }
}
