using UnityEngine;

public class CardHolderBuilding : Building, ICardHolder
{
    [SerializeField] private CardHoldArea cardHoldArea;
    [SerializeField] private bool cardRemoved = false;

    private void Awake()
    {
        cardHoldArea.cardHolder = this;
    }

    private void Update()
    {
        if (cardRemoved && MapManager.Instance.CheckIfBuildingTopIsOpen(transform.position, BuildingData))
        {
            MapManager.Instance.RemoveBuilding(transform.position, BuildingData);
            Demolish();
        }
    }

    public bool CanAddCard(CardData card) => !cardRemoved;
    
    public void AddCard(CardData card) { }
    
    public void RemoveCard(CardData card)
    {
        cardRemoved = true;
    }
}
