Пример #1
0
    private bool handleHomeMovement(
        BoardPiece piece,
        PieceMovementData movementData,
        ref List <MovePath> result)
    {
        if (piece.boardPosition.type != PositionType.HOME)
        {
            return(false);
        }

        int  ownerIndex       = piece.ownerIndex;
        bool startingPegValid = true;

        BoardPosition startingPeg = _board.GetStartingPosition(ownerIndex);

        BoardPiece blockingPiece;

        if (_board.IsPositionOccupied(startingPeg, out blockingPiece))
        {
            startingPegValid = !blockingPiece.justLeftHome;
        }

        if (startingPegValid)
        {
            MovePath path = new MovePath();
            path.Add(startingPeg);
            result.Add(path);
        }

        return(result.Count > 0);
    }