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

public class StorageTank
{
    // タンクID, タンク内のフレーバーID, フレーバーの個数
    public int Id;
    public int Capacity;
    public int FlavorId;
    public int Stock
    {
        get => Stocks.Sum(x => x.Stock);
        set => SetStock(ProductRarity.Normal, value);
    }
    public List<ProductStockData> Stocks = new List<ProductStockData>();
    public bool IsEmpty => Stock == 0;
    public bool IsFull => Stock == Capacity;

    public void SetStock(ProductRarity rarity, int stock)
    {
        
    }
    
    public void AddStock(ProductRarity rarity, int stock)
    {
        var stockData = Stocks.FirstOrDefault(x => x.Rarity == rarity);
        if (stockData is default(ProductStockData))
        {
            Stocks.Add(new ProductStockData{FlavorId = FlavorId, Rarity = rarity, Stock = stock});
            return;
        }
        stockData.Stock += stock;
    }

    public void ClearStock()
    {
        Stocks.Clear();
    }
}

public class ProductStockData
{
    public int FlavorId;
    public ProductRarity Rarity;
    public int Stock;
}