using System.Collections.Generic;

namespace CounterDrone.Core
{
    public static class DefaultFormations
    {
        private static List<FormationTemplate> _cache;

        public static List<FormationTemplate> GetAll()
        {
            if (_cache != null) return _cache;
            _cache = new List<FormationTemplate>
            {
                new() { Id = "single", Name = "单机", FormationMode = 0, LateralCount = 1, LongitudinalCount = 1 },
                new() { Id = "line-abreast-3", Name = "3机横队", FormationMode = 1, LateralCount = 3, LongitudinalCount = 1,
                    LateralSpacing = 50 },
                new() { Id = "line-abreast-5", Name = "5机横队", FormationMode = 1, LateralCount = 5, LongitudinalCount = 1,
                    LateralSpacing = 50 },
                new() { Id = "column-3", Name = "3机纵队", FormationMode = 1, LateralCount = 1, LongitudinalCount = 3,
                    LongitudinalSpacing = 100 },
                new() { Id = "box-2x2", Name = "2×2方队", FormationMode = 1, LateralCount = 2, LongitudinalCount = 2,
                    LateralSpacing = 50, LongitudinalSpacing = 100 },
                new() { Id = "swarm-10", Name = "蜂群(10架)", FormationMode = 2, LateralCount = 10, LongitudinalCount = 1,
                    LateralSpacing = 30 },
            };
            return _cache;
        }

        public static FormationTemplate GetById(string id) => GetAll().Find(t => t.Id == id);
    }

    public class FormationTemplate
    {
        public string Id { get; set; } = "";
        public string Name { get; set; } = "";
        public int FormationMode { get; set; }
        public int LateralCount { get; set; } = 1;
        public int LongitudinalCount { get; set; } = 1;
        public double LateralSpacing { get; set; }
        public double LongitudinalSpacing { get; set; }
    }
}
