using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public sealed class NavigationPoint
{
    public readonly string Name;
    public readonly int Id;
    public readonly Vector3 SystemPostition;
    public readonly SpaceStantion[] Stantions;
    public readonly int FactionId;
    public readonly List<StarShip> Ships = new List<StarShip>();

    public SpaceStantion Stantion => Stantions.First();

    public NavigationPoint(int id, int factionId, Vector3 position, SpaceStantion[] stantions = null)
    {
        SystemPostition = position;
        Id = id;
        Stantions = stantions ?? Array.Empty<SpaceStantion>();
        FactionId = factionId;
        var mainStantion = Stantions.FirstOrDefault();
        Name = mainStantion == null ? string.Empty : mainStantion.TypeId.Substring(0, 1).ToUpper();
    }

    public string GetMarkerLetter() => Name;

    public bool HavePirates() => Ships.Any(ship => ship.IsPirate());
}