using System;
using UnityEngine;

[CreateAssetMenu(fileName = "factions_data_provider", menuName = "Factions data")]
public sealed class FactionDataProvider : ScriptableObject
{
    [SerializeField]
    private FactionData defaultFaction = new FactionData();
    [SerializeField]
    private FactionData[] factions = null;

    [Serializable]
    public sealed class FactionData {
        [SerializeField] private Color color = Color.white;
        [SerializeField] private string name = string.Empty;

        public Color Color => color;
        public string Name => name;
    }

    public FactionData this[int factionId] {
        get => GetFactionData(factionId);
    }

    public FactionData GetFactionData(int factionId)
    {
        if (factionId >= 0 && factionId < factions.Length)
            return factions[factionId];
        return defaultFaction;
    }
}
