private Game(SetupBoard playerOneSetup, SetupBoard playerTwoSetup) { if (!playerOneSetup.IsValid) { throw new ArgumentException("Player One setup board is not valid.", nameof(playerOneSetup)); } if (!playerTwoSetup.IsValid) { throw new ArgumentException("Player Two setup board is not valid.", nameof(playerTwoSetup)); } m_PlayerOneSetup = playerOneSetup; m_PlayerTwoSetup = playerTwoSetup; Turn = Players.PlayerOne; }
private static FireResult GetResult(GridSquare target, SetupBoard targetBoard, ShotState[,] shotRecorder) { var isHit = targetBoard.ShipsByOccupationPoints.ContainsKey(target.Point); shotRecorder[target.Point.X, target.Point.Y] = isHit ? ShotState.Hit : ShotState.Miss; if (!isHit) { return(new FireResult(target)); } var hitShip = targetBoard.ShipsByOccupationPoints[target.Point]; var isSunk = hitShip.Hit(target.Point); var haveWon = isSunk ? targetBoard.AllSunk : false; return(new FireResult(target, isSunk, isSunk ? hitShip : null, haveWon)); }
internal Game(SetupBoard setupBoard, SetupBoard opponentsSetupBoard, IComputerStrategy computerStrategy) : this(setupBoard, opponentsSetupBoard) { m_ComputerStrategy = computerStrategy; }
public Game(SetupBoard setupBoard) : this(setupBoard, new SetupBoard().GenerateRandom()) { m_ComputerStrategy = new ShipSeekingEfficientStrategy(); }