public void PlacePiece(GamePieceTypeEnum gamePieceType, BoxPositionEnum boxPosition) { CheckNotAllowedMoves(gamePieceType, boxPosition); PlacePieceIntoBox(gamePieceType, boxPosition); SetLastGamePlacedPiece(gamePieceType); if (BoardIsFull()) { SetGameDrawResult(); } if (ThreePiecesOfSameTypeInARow(gamePieceType)) { SetGameWinResult(gamePieceType); } }
private void CheckNotAllowedMoves(GamePieceTypeEnum gamePieceType, BoxPositionEnum boxPosition) { if (FirstGamePlacedPieceIsWhite(gamePieceType)) { throw new WrongFirstPiecePlacedException(); } if (IsOcuppiedBox(boxPosition)) { throw new OcuppiedBoxException(); } if (LastPlacedPieceIsSameColor(gamePieceType)) { throw new WrongPiecePlacedException(); } }
private void PlacePieceIntoBox(GamePieceTypeEnum gamePieceType, BoxPositionEnum boxPosition) { _boxes[(int)boxPosition] = gamePieceType; }
private bool IsOcuppiedBox(BoxPositionEnum boxPosition) { return(_boxes[(int)boxPosition] != GamePieceTypeEnum.None); }