public ShotReport Shot(string location) { ShotReport shotReport = new ShotReport(); if (Map.ContainsKey(location)) { Coord coord = Map[location]; coord.Hit = true; shotReport.Hit = true; shotReport.Sunk = Map.Where(a => a.Value.Ship == coord.Ship).Where(b => b.Value.Hit == false).Count() == 0; shotReport.Description = coord.Ship.Description; if (shotReport.Sunk) { foreach (string key in Map.Where(a => a.Value.Ship == coord.Ship).Select(b => b.Key).ToList()) { Map.Remove(key); } } return(shotReport); } else { return(shotReport); } }
public bool HasShips() { return(Map.Where(a => a.Value.Hit == false).Count() > 0); }