57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using Battleship.DrawningObjects;
|
|
using Battleship.MovementStrategy;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Battleship.Generics
|
|
{
|
|
internal class ShipsGenericStorage
|
|
{
|
|
readonly Dictionary<string, ShipGenericCollection<DrawningShip,
|
|
DrawningObjectShip>> _shipStorages;
|
|
|
|
public List<string> Keys => _shipStorages.Keys.ToList();
|
|
|
|
private readonly int _pictureWidth;
|
|
|
|
private readonly int _pictureHeight;
|
|
|
|
public ShipsGenericStorage(int pictureWidth, int pictureHeight)
|
|
{
|
|
_shipStorages = new Dictionary<string,
|
|
ShipGenericCollection<DrawningShip, DrawningObjectShip>>();
|
|
_pictureWidth = pictureWidth;
|
|
_pictureHeight = pictureHeight;
|
|
}
|
|
|
|
public void AddSet(string name)
|
|
{
|
|
if (_shipStorages.ContainsKey(name))
|
|
return;
|
|
_shipStorages[name] = new ShipGenericCollection<DrawningShip, DrawningObjectShip>(_pictureWidth,_pictureHeight);
|
|
}
|
|
|
|
public void DelSet(string name)
|
|
{
|
|
if (!_shipStorages.ContainsKey(name))
|
|
return;
|
|
_shipStorages.Remove(name);
|
|
}
|
|
|
|
public ShipGenericCollection<DrawningShip, DrawningObjectShip>?
|
|
this[string ind]
|
|
{
|
|
get
|
|
{
|
|
if(_shipStorages.ContainsKey(ind))
|
|
return _shipStorages[ind];
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|