using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class TankRarityView : MonoBehaviour
{
    [SerializeField] private GameObject normalOn;
    [SerializeField] private GameObject normalOff;
    [SerializeField] private GameObject yellowOn;
    [SerializeField] private GameObject yellowOff;
    [SerializeField] private GameObject copperOn;
    [SerializeField] private GameObject copperOff;
    [SerializeField] private GameObject silverOn;
    [SerializeField] private GameObject silverOff;
    [SerializeField] private GameObject goldOn;
    [SerializeField] private GameObject goldOff;
    [SerializeField] private GameObject rainbowOn;
    [SerializeField] private GameObject rainbowOff;

    public void SetHasRarity(List<ProductStockData> stocks)
    {
        var rarities = stocks.Where(x => x.Stock > 0).Select(x => x.Rarity).ToList();
        normalOn.SetActive(rarities.Contains(ProductRarity.Normal));
        normalOff.SetActive(!rarities.Contains(ProductRarity.Normal));
        yellowOn.SetActive(rarities.Contains(ProductRarity.Yellow));
        yellowOff.SetActive(!rarities.Contains(ProductRarity.Yellow));
        copperOn.SetActive(rarities.Contains(ProductRarity.Copper));
        copperOff.SetActive(!rarities.Contains(ProductRarity.Copper));
        silverOn.SetActive(rarities.Contains(ProductRarity.Silver));
        silverOff.SetActive(!rarities.Contains(ProductRarity.Silver));
        goldOn.SetActive(rarities.Contains(ProductRarity.Gold));
        goldOff.SetActive(!rarities.Contains(ProductRarity.Gold));
        rainbowOn.SetActive(rarities.Contains(ProductRarity.Rainbow));
        rainbowOff.SetActive(!rarities.Contains(ProductRarity.Rainbow));
    }
}