using UnityEngine;

public class ResidentialBuilding : Building, ICardHolder
{
    private ResidentialBuildingData data;
    [SerializeField] private PeopleCardHoldArea residents;

    private void Awake()
    {
        residents.cardHolder = this;
        if (BuildingData != null)
        {
            Initiate(BuildingData);
            operational = true;
        }
    }

    public override void Initiate(BuildingData buildingData)
    {
        base.Initiate(buildingData);
        data = buildingData as ResidentialBuildingData;
    }

    public override void Build()
    {
        base.Build();
        Events.AddHome(data.MaxResidents);
    }

    public override void Demolish()
    {
        residents.DropCards();
        if (operational) Events.RemoveHome(data.MaxResidents);
        base.Demolish();
    }

    public bool CanAddCard(CardData card)
    {
        return operational && card.CardType == CardType.Person;
    }

    public void AddCard(CardData card) { }

    public void RemoveCard(CardData card) { }
}
