using System.Collections.Generic;
using Assets.Data;
using TMPro;
using UnityEngine;

public class TraitSelectorManager : MonoBehaviour
{
    [SerializeField]
    private TMP_InputField _compositionSize;

    [SerializeField]
    private ChampionSelector _mandatorychampionSelector;

    [SerializeField]
    private ChampionSelector _acceptablechampionSelector;

    [SerializeField]
    private EmblemSelector _emblemSelector;

    [SerializeField]
    private int _traitThreshold = 7;

    private Dictionary<TraitsEnum, int> emblemList;
    
    public void ListAllActivableCompo()
    {
        emblemList = _emblemSelector.GetEmblems();
        var mandatoryChampions = ChampionUtils.ToLong(_mandatorychampionSelector.GetSelectedChampions());
        var acceptableChampions = ChampionUtils.ToLong(_acceptablechampionSelector.GetSelectedChampions());
        int compositionSize = _compositionSize.text == "" ? 1 : int.Parse(_compositionSize.text);
        var composition = TraitsMapping.GenerateCombinations(mandatoryChampions, acceptableChampions, compositionSize);
        Coroutine coroutine = StartCoroutine(TraitsMapping.DisplayCompositions(composition));
        //var coroutine = StartCoroutine(TraitsMapping.GetChampionSubsetsAsync(champList, compositionSize,emblemList, HandleCombination));

    }

    private void HandleCombination(long combination)
    {
        // var synergies = TraitsMapping.MergeEmblems(
        //         TraitsMapping.TraitCountInCompo(combination),
        //         emblemList
        //     );
        //     var activeSynergies = TraitsMapping.FilterActiveTraits(synergies);
        //     if (TraitUtils.TraitCountFromInt(activeSynergies) >= _traitThreshold)
        //     {
        //         var s = TraitsMapping.CompositionToString(combination, activeSynergies);
        //         Debug.Log(s);
        //     } else {
        //         Debug.LogWarning("Combination not valid");
        //     }            
    }
}
