using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Artilleries
{
    internal class MapsCollection
    {
        readonly Dictionary<string, MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>> _mapsStorage;
        public List<string> Keys => _mapsStorage.Keys.ToList();

        private readonly int _pictureWidth;
        private readonly int _pictureHeight;

        public MapsCollection(int pictureWidth, int pictureHeight)
        {
            _mapsStorage = new Dictionary<string, MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>>();
            _pictureWidth = pictureWidth;
            _pictureHeight = pictureHeight;
        }

        public void AddMap(string name, AbstractMap map)
        {
            if (!_mapsStorage.ContainsKey(name))
            {
                _mapsStorage.Add(name, new MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>(_pictureWidth, _pictureHeight, map));
            }
        }

        public void DelMap(string name)
        {
            if (_mapsStorage.ContainsKey(name))
            {
                _mapsStorage.Remove(name);
            }
        }

        public MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap> this[string index]
        {
            get
            {
                return _mapsStorage.ContainsKey(index) ? _mapsStorage[index] : null;
            }
        }
    }
}