// 리듬게임 점수/콤보/판정수 누적 (Unity 비의존 순수 로직 - 테스트하기 쉬움)
public class RhythmScore
{
    // 판정별 기본 점수
    private const int PerfectPoint = 100;
    private const int GoodPoint = 50;
    private const int BadPoint = 10;

    public int Score { get; private set; }
    public int Combo { get; private set; }
    public int MaxCombo { get; private set; }

    public int PerfectCount { get; private set; }
    public int GoodCount { get; private set; }
    public int BadCount { get; private set; }
    public int MissCount { get; private set; }

    public int TotalJudged => PerfectCount + GoodCount + BadCount + MissCount;

    // 판정 하나를 점수에 반영
    public void Apply(Result result)
    {
        switch (result)
        {
            case Result.Perfect:
                PerfectCount++;
                Combo++;
                Score += PerfectPoint + Combo;   // 콤보가 쌓일수록 보너스 (연속 보상)
                break;
            case Result.Good:
                GoodCount++;
                Combo++;
                Score += GoodPoint + Combo;
                break;
            case Result.Bad:
                BadCount++;
                Combo = 0;                       // 콤보 끊김
                Score += BadPoint;
                break;
            case Result.Miss:
                MissCount++;
                Combo = 0;                       // 콤보 끊김
                break;
        }

        if (Combo > MaxCombo) MaxCombo = Combo;
    }

    public void Reset()
    {
        Score = 0;
        Combo = 0;
        MaxCombo = 0;
        PerfectCount = 0;
        GoodCount = 0;
        BadCount = 0;
        MissCount = 0;
    }
}
