public void CheckOperatorEquals() { Coordinates fCoord = new Coordinates(2,3); Coordinates sCoord = new Coordinates(2,3); bool check = fCoord == sCoord; Assert.IsTrue(check); }
public void TestChestPieceConstructorY() { char excpected = 'K'; Coordinates newCoordinates = new Coordinates(2, 3); int x = newCoordinates.XCoord; int y = newCoordinates.YCoord; ChessPiece testPiece = new ChessPiece(excpected, newCoordinates); Assert.AreEqual(y, testPiece.YCoord); }
public void TestCoordConstructor() { int checkX = 2; int checkY = 3; Coordinates fCoord = new Coordinates(2, 3); bool testX = fCoord.XCoord == checkX; bool testY = fCoord.YCoord == checkY; Assert.IsTrue(testX && testY); }
public void CheckOperatorSummary() { Coordinates fCoord = new Coordinates(2, 3); Coordinates sCoord = new Coordinates(2, 3); Coordinates sumCoord = fCoord + sCoord; bool Xchack = sumCoord.XCoord == 4; bool Ycheck = sumCoord.YCoord == 6; Assert.IsTrue(Xchack&&Ycheck); }
/// <summary> /// Moves a chess piece, to designated coordinates. /// </summary> /// <param name="currentPiece">A char value, indicating the current chess piece.</param> /// <param name="newCoords">The new coordinates.</param> private void MovePiece(char currentPiece, Coordinates newCoords) { chessPieces[currentPiece].Coordinates = newCoords; }
/// <summary> /// Checks if the cell at the input coordinates is occupied by another chess piece. /// </summary> /// <param name="coordinates">The input coordinates.</param> /// <returns>A bool value, indicating whether the coordinates are occupied or not.</returns> private bool IsOccupied(Coordinates coordinates) { foreach (var piece in chessPieces) { if (piece.Value.Coordinates == coordinates) { return true; } } return false; }
/// <summary> /// Checks if the king has any valid moves left. Otherwise the game should end, with a win for the pawns. /// </summary> /// <returns>A bool value, indicating whether the king is blocked.</returns> private bool IsKingBlocked() { Coordinates kingCoords = chessPieces[KingSymbol].Coordinates; foreach (var direction in directions) { Coordinates newCoords = new Coordinates(kingCoords.XCoord + direction.Value.XCoord, kingCoords.YCoord + direction.Value.YCoord); bool valid = AreValidCoordinates(newCoords); bool occupied = IsOccupied(newCoords); if (valid && !occupied) { return false; } } return true; }
/// <summary> /// Checks if the input coordinates are in the board. /// </summary> /// <param name="coordinates">The input coordinates.</param> /// <returns>A bool value, indicating whether the coordinates are valid.</returns> private bool AreValidCoordinates(Coordinates coordinates) { bool isWidthInScreen = (0 <= coordinates.XCoord) && (coordinates.XCoord < boardRenderer.Size); bool isHeightInScreen = (0 <= coordinates.YCoord) && (coordinates.YCoord < boardRenderer.Size); return isWidthInScreen && isHeightInScreen; }