Example #1
0
        public Ship Spawn(ShipSpecification spec, Position p)
        {
            var ship = new Ship();

            ship.Initialize(spec);
            ship.Position = p;
            ship.ShipId   = 1;
            if (AllShips.Any())
            {
                ship.ShipId = AllShips.Max(x => x.ShipId) + 1;
            }
            AllShips.Add(ship);
            return(ship);
        }
Example #2
0
        public virtual List <Tuple <char, int> > SetShip(List <Square> board)
        {
            List <Tuple <char, int> > Right(Tuple <char, int> selectedPoint)
            {
                char nextColumn = selectedPoint.Item1;

                nextColumn += (char)Size;
                var endPoint = new Tuple <char, int>(nextColumn, selectedPoint.Item2);

                List <Tuple <char, int> > tempList = new List <Tuple <char, int> >();

                for (char i = selectedPoint.Item1; i <= endPoint.Item1; i++)
                {
                    var square = new Tuple <char, int>(i, selectedPoint.Item2);
                    if (board.Any(r => r.Position.Equals(square) && r.ShipType is null && !AllShips.Any(r => r.Any(rr => rr.Equals(square)))))
                    {
                        tempList.Add(new Tuple <char, int>(i, selectedPoint.Item2));
                    }