public (int x, int y) ChooseTarget(GameGrid grid) { return(_rng.Next(0, grid.Size), _rng.Next(0, grid.Size)); }
private void ConductRound(IPlayer conductingPlayer, PlayerSrouceEnum playerSrouce, GameGrid enemyPlayerGrid) { var canContinue = true; while (canContinue) { // Ask player to choose target until they provide a valid one var validChoice = false; int x = 0, y = 0; while (!validChoice) { (x, y) = conductingPlayer.ChooseTarget(enemyPlayerGrid); validChoice = _shootingRule.IsAllowed(enemyPlayerGrid, x, y); } var hit = enemyPlayerGrid.Shoot(x, y); var anyShipsLeft = enemyPlayerGrid.Ships.Any(x => !x.Sunk); canContinue = hit && anyShipsLeft; Log(playerSrouce, x, y); } }