예제 #1
0
        //Checks if the path for the King is Clear.
        public bool isKingClear(Vector curr, Vector src)
        {
            if (curr.x == 0 && curr.y == 0) //Reached the attacking King ?
                return true;

            Vector add = Vector.add(curr, src);
            if (!isEmpty(add)) //Is something blocking the way ?
                return false;

            return true && isKingClear(curr.stepBack(), src);
        }
예제 #2
0
 public bool validateMove(Piece srcPc, Vector src, Vector possMove)
 {
     return isKingClear(possMove.stepBack(), src);
 }
예제 #3
0
        public Vector findEnemy(Vector curr, Vector src)
        {
            if (curr.x == 0 && curr.y == 0) //Reached the attacking King ?
                return null;

            Vector add = Vector.add(curr, src); //it is the actual current position
            if (!isEmpty(add)) //if you found a piece
                if (!getPc(add).isHis(GamePlay.currPl)) //Found the enemy ?
                    return curr;
                else
                    return null; //Your Piece is blocking the way between the dest and enemy (if it existed)

            return findEnemy(curr.stepBack(), src);
        }