using System.Collections.Generic;
using UnityEngine;

public sealed class Faction
{
    public readonly string Name;
    public readonly Color Color;
    public readonly int ID;
    public readonly List<Base> Bases = new List<Base>();

    public int ResourceUnitCount { get; private set; } = 0;

    public readonly BuildQueue BuildQueue = new BuildQueue();

    public Faction(string name, int id, Color color)
    {
        Name = name;
        ID = id;
        Color = color;
    }

    public bool BuildProject(BuildProject project, int cost)
    {
        if (!SpentResources(cost))
            return false;
        BuildQueue.Add(project);
        return true;
    }

    public void AddResources(int count) {
        ResourceUnitCount += count;
    }

    public bool SpentResources(int count)
    {
        if (ResourceUnitCount < count)
            return false;
        ResourceUnitCount -= count;
        return true;
    }

    public void AddBase(Base baseController)
    {
        Bases.Add(baseController);
    }

    public void RemoveBase(Base baseController)
    {
        Bases.Remove(baseController);
    }
}
