public void PlaceShipTest()
 {
     Assert.IsTrue(_shipPlacementService.PlaceShip(_board1, "1-1-n", 5));           // Legit placement
     Assert.IsFalse(_shipPlacementService.PlaceShip(_board1, "0-0-s", 5));          // Outside map boundaray
     Assert.IsFalse(_shipPlacementService.PlaceShip(_board1, "5-1-w", 5));          // Ship collision
     Assert.IsFalse(_shipPlacementService.PlaceShip(_board1, "asdf-asdf-asdf", 5)); // Invalid input
 }
Esempio n. 2
0
        private async void SetShips(Player p, ShipPlacementService sps)
        {
            while (p.Ships.Count > sps.OccupiedCoordinates.Count)
            {
                var theShip = p.Ships[sps.OccupiedCoordinates.Count];

                GW.PCShotInfo.Text = $"Setting the coordinates for ship of size {theShip.Size}";
                Coordinate coordToUse = await GW.UserClickedOnCoordinateBoard();

                CoordinateTask = null;

                sps.PlaceShip(ShipOrientation, coordToUse, theShip);
                ColourTheShip(theShip.Placement);
            }

            GW.PlayerButtonsPanel.Children.Clear();
            GW.PCShotInfo.Text = null;
            GenerateStartButton();
        }