using eagle;
using Net.Eagle0.Eagle.Api;
using TMPro;
using UnityEngine;

public class WaitingGameItem : MonoBehaviour {
    public GameObject item;
    public TextMeshProUGUI gameIdField;
    public TextMeshProUGUI leaderField;
    public TextMeshProUGUI playerCountField;

    // Use this for initialization
    void Start() {}

    public void SetWaitingGame(long gameId, string playersString, AvailableLeader leader) {
        gameIdField.text = string.Format("{0:X}", gameId);
        playerCountField.text = playersString;

        // Use pre-resolved name from server if available, otherwise fall back to text lookup
        string leaderName;
        if (!string.IsNullOrEmpty(leader.Name)) {
            leaderName = leader.Name;
        } else {
            var textEntry = ClientTextProvider.Provider.GetTextEntry(leader.NameTextId);
            leaderName = textEntry != null ? textEntry.Text : "Hero";
        }
        leaderField.text = string.Format(
                "{0} ({1})",
                leaderName,
                DisplayNames.ProfessionNames[leader.Profession]);
    }
}
