using UnityEngine.UIElements;

namespace LiveOpsExamples
{
  public class LeaderboardRowView
  {
    private readonly Label rankLabel;
    private readonly Label playerLabel;
    private readonly Label scoreLabel;

    public LeaderboardRowView(VisualElement root)
    {
      rankLabel = root.Q<Label>("lb-rank");
      playerLabel = root.Q<Label>("lb-player");
      scoreLabel = root.Q<Label>("lb-score");
    }

    public void Set(int rank, string playerName, int score)
    {
      rankLabel.text = rank > 0 ? $"#{rank}" : "—";
      playerLabel.text = playerName;
      scoreLabel.text = score.ToString();
    }
  }
}
