private static Game SetupGame() { Console.WriteLine("Setting up the game"); var gamePlayerBuilder = GameBuilderDirector .NewGame .AddPlayer(new Player(_gameConfiguration.Name)); Console.WriteLine("Setting ships randomly"); gamePlayerBuilder = gamePlayerBuilder.AddPlayer(new Player(_gameConfiguration.Opponent)); foreach (var shipLocation in _shipLocationGenerator.GenerateRandomShipLocations()) { gamePlayerBuilder.AddShip(shipLocation.Ship) .WithCoordinatesStartingAt(shipLocation.Coordinate) .AndDirection(shipLocation.Direction); } Console.WriteLine("Game has been setup"); Console.WriteLine(); Console.WriteLine("With given configuration"); Console.WriteLine(GameSettings.Instance.ToString()); Console.WriteLine(); Console.WriteLine("STARTING THE GAME!"); Console.WriteLine(); return(gamePlayerBuilder.Start()); }
public void CanGenerateRandomShipLocations() { var randomShipLocations = _shipLocationGenerator.GenerateRandomShipLocations(); Assert.AreEqual( numberOfShips, randomShipLocations.Count(s => s.ShipType == ShipType.Battle), "There should be generated the same number of ships as settings limit"); Assert.AreEqual( numberOfShips, randomShipLocations.Count(s => s.ShipType == ShipType.Destroyer), "There should be generated the same number of ships as settings limit"); }