using System.Collections;
using System.Collections.Generic;
using Nimblegorilla;
using UnityEngine;

public class BrokeragePanel : DetailsPanel
{
    public AttributePanel sterlings;
    public AttributePanel location;
    public AttributePanel cargo;

    // Update is called once per frame
    void Update()
    {
        sterlings.SetValue(airship.sterlings.ToString());
        location.SetValue(LocationString());
        cargo.SetValue(airship.CurrentCargo().ToString() + "/" + airship.cargoCapacity.ToString() + " tonnes");
    }

    string LocationString()
    {
        return airship.location.cityName + " Brokerage";
    }

    public override void Activate()
    {
        if (airship.location != null)
        {
            base.Activate();
        }
    }

    public void AddContract(Contract contract)
    {
        var panel = Utils.PrefabbedComponent<ContractPanel>("_prefabs/ContractPanel");
        panel.contract = contract;
        panel.transform.SetParent(transform, false);
    }

    public void ClearContracts()
    {
        foreach (var detailPanel in GetComponentsInChildren<ContractPanel>())
        {
            Destroy(detailPanel.gameObject);
        }
    }
}
