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

namespace Grid {
    public class GridObject {
        public GridObject(GridSystemHex<GridObject> gridSystemHex, GridPosition gridPosition) {
            GridSystemHex = gridSystemHex;
            GridPosition = gridPosition;
            UnitList = new();
        }

        private GridSystemHex<GridObject> GridSystemHex { get; }
        private GridPosition GridPosition { get; }
        public List<Unit> UnitList { get; }
        public IInteractable Interactable { get; set; }

        public override string ToString() {
            string unitString = UnitList.Aggregate("", (current, unit) => current + (unit + "\n"));
            return $"{GridPosition.ToString()}\n{unitString}";
        }

        public Unit GetUnit() => UnitList.Count > 0 ? UnitList[0] : null;
    }
}