using Predictalytics.Domain.Enums;

namespace Predictalytics.Domain.ValueObjects;

/// <summary>
/// Encapsulates a trader's calculated priority score with all component scores.
/// </summary>
public record PriorityScore(
    decimal ActivityScore,
    decimal QualityScore,
    decimal VolumeScore,
    decimal TimingScore,
    decimal CombinedScore,
    int? ManualOverride = null
)
{
    /// <summary>
    /// The effective score, considering any manual override.
    /// </summary>
    public decimal EffectiveScore => ManualOverride.HasValue
        ? ManualOverride.Value
        : CombinedScore;

    /// <summary>
    /// Determine tier based on effective score.
    /// To reach Diamond, the score must be exceptionally high (top 1%).
    /// </summary>
    public TraderTier DetermineTier() => EffectiveScore switch
    {
        >= 95 => TraderTier.Diamond,
        >= 85 => TraderTier.Platinum,
        >= 70 => TraderTier.Gold,
        >= 50 => TraderTier.Silver,
        >= 30 => TraderTier.Bronze,
        _ => TraderTier.Unknown
    };
}
