Esempio n. 1
0
        private void PreparePlayerForGame(Player player)
        {
            var sps = new ShipPlacementService(player.Grid.Height, player.Grid.Width);

            CoordinateTask = new TaskCompletionSource <Coordinate>();

            bool[] ShouldHaveContent = new bool[] { true, false };

            BFS.FillWithButtons(GW.PlayerBoxGrid, player.Grid, ShouldHaveContent[1], GW.SetShipClick);
            BFS.FillWithButtons(GW.PlayerGuessBoxGrid, player.GuessGrid, ShouldHaveContent[0], null);

            SetShips(player, sps);
        }
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();
        }
Esempio n. 3
0
        public void GivenOneFreeSpacePlaceShip(Point[] emptySquares)
        {
            var shipPlacementService = new ShipPlacementService();
            var boardSize            = new Size(4, 4);

            var gameBoard = new GameBoard()
            {
                Squares = BuildSquares(emptySquares, boardSize),
                Size    = boardSize,
            };

            shipPlacementService.PlaceShips(new[] {
                new Ship
                {
                    Type = "TestShip",
                    Size = 2,
                }
            }, gameBoard);

            var testShipPoints = gameBoard.Squares.Where(x => x.Value.Ship.Type == "TestShip").Select(x => x.Key).ToList();

            testShipPoints.Should().BeEquivalentTo(emptySquares);
        }
 public void SetUp()
 {
     _boardService         = new BoardMicroservice();
     _shipPlacementService = new ShipPlacementService();
     (_player1, _player2, _board1, _board2, _gameMode) = _boardService.SetupPvEBoards();
 }