Exemple #1
0
    //Looks at each diagonal movements and sees if it is a legal movement and adds it to a list of PieceMoves
    public List <PieceMove> getLegalMoves(BoardLocation boardLocation)
    {
        List <PieceMove> legalMoves = new List <PieceMove>();

        if (!boardLocation.isEmpty())         //if there is a piece at this location

        {
            PieceHandler ph = boardLocation.piece.GetComponent <PieceHandler>();
            if (ph.player == currentPlayer)
            {
                int i = boardLocation.i;
                int j = boardLocation.j;

                calculateLegalMoves(ref i, ref j, ref legalMoves, ref ph, 1, 1);                  //if the NE space is empty
                calculateLegalMoves(ref i, ref j, ref legalMoves, ref ph, 1, -1);                 //if the NW space is empty
                if (ph.king == true)
                {
                    calculateLegalMoves(ref i, ref j, ref legalMoves, ref ph, -1, 1);                      //if the SE space is empty
                    calculateLegalMoves(ref i, ref j, ref legalMoves, ref ph, -1, -1);                     //if the SW space is empty
                }
            }
            selectedPiece = boardLocation;
        }

        currentLegalMoves = legalMoves;
        displayLegalMoves(legalMoves);
        return(legalMoves);
    }
Exemple #2
0
 public void BoardLocationConstructors()
 {
     // Use the Assert class to test conditions.
     Assert.AreEqual(null, BL1.piece);
     Assert.AreEqual(1, BL1.i);
     Assert.AreEqual(2, BL1.j);
     Assert.IsTrue(BL1.isEmpty());
     Assert.AreNotEqual(null, BL2.piece);
     Assert.AreEqual(1, BL2.i);
     Assert.AreEqual(2, BL2.j);
     Assert.IsFalse(BL2.isEmpty());
 }
Exemple #3
0
    //Checks if a location is empty.
    public bool isLocationEmpty(string location)
    {
        BoardLocation boardLocation = getLocation(location);

        return(boardLocation.isEmpty());
    }