using System.Collections.Generic;
using UnityEngine;

namespace Core.Domain
{
    public static class MapPatterns
    {
        public static List<Vector2Int> GenerateSquare(int width, int height)
        {
            var positions = new List<Vector2Int>();
            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    positions.Add(new Vector2Int(x, y));
                }
            }
            return positions;
        }
        
        public static List<Vector2Int> GenerateCircle(int diameter)
        {
            var positions = new List<Vector2Int>();
            var radius = diameter / 2.0f;
            var center = new Vector2(radius, radius);
            
            for (var x = 0; x < diameter; x++)
            {
                for (var y = 0; y < diameter; y++)
                {
                    if (Vector2.Distance(new Vector2(x, y), center) <= radius)
                    {
                        positions.Add(new Vector2Int(x, y));
                    }
                }
            }
            return positions;
        }

        public static List<Vector2Int> GenerateDonut(int diameter, int holeSize)
        {
            var positions = new List<Vector2Int>();
            var radius = diameter / 2.0f;
            var holeRadius = holeSize / 2.0f;
            var center = new Vector2(radius, radius);

            for (var x = 0; x < diameter; x++)
            {
                for (var y = 0; y < diameter; y++)
                {
                    var dist = Vector2.Distance(new Vector2(x, y), center);
                    if (dist <= radius && dist >= holeRadius)
                    {
                        positions.Add(new Vector2Int(x, y));
                    }
                }
            }
            return positions;
        }
    }
}