using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class Common : MonoBehaviour
{
    [SerializeField] TMP_Dropdown dAnimal;
    [SerializeField] TMP_Dropdown dSuitStyle;
    [SerializeField] TMP_Dropdown dSuitType;
    [SerializeField] TMP_Dropdown dRegion;
    // TODO 내부 저장 기능 만들기
    // TODO 버전 기능 까지 만들어서 버전 체크후 새로 다운받아오게 만들기.

    void Start()
    {
        NetworkManager.Instance.CreateRequest<List<CommonData>>("common/animalTypes", new object(), (data) =>
        {
           GameManager.Instance.animalTypes = data;
            List<string> strings = new List<string>();
            for(int n = 0; n < data.Count; n++)
            {
                strings.Add(data[n].code_nm);
            }
            dAnimal.AddOptions(strings);
        }, null, BestHTTP.HTTPMethods.Get);
        NetworkManager.Instance.CreateRequest<List<CommonData>>("common/suitStyle", new object(), (data) =>
        {
            GameManager.Instance.suitStyle = data;
            List<string> strings = new List<string>();
            for (int n = 0; n < data.Count; n++)
            {
                strings.Add(data[n].code_nm);
            }
            dSuitStyle.AddOptions(strings);
        }, null, BestHTTP.HTTPMethods.Get);
        NetworkManager.Instance.CreateRequest<List<CommonData>>("common/suitType", new object(), (data) =>
        {
            GameManager.Instance.suitType = data;
            List<string> strings = new List<string>();
            for (int n = 0; n < data.Count; n++)
            {
                strings.Add(data[n].code_nm);
            }
            dSuitType.AddOptions(strings);
        }, null, BestHTTP.HTTPMethods.Get);
        NetworkManager.Instance.CreateRequest<List<CommonData>>("common/region", new object(), (data) =>
        {
            GameManager.Instance.region = data;
            List<string> strings = new List<string>();
            for (int n = 0; n < data.Count; n++)
            {
                strings.Add(data[n].code_nm);
            }
            dRegion.AddOptions(strings);
        }, null, BestHTTP.HTTPMethods.Get);
    }

    public class CommonData
    {
        public string code_nm;
        public string code_id;
    }
}
