Package com.barrybecker4.game.common.board

Examples of com.barrybecker4.game.common.board.BoardPosition


        if ( getRenderer().getDraggedPiece() == null )
            return; // nothing being dragged

        Board board = (Board)controller.getBoard();
        // get the original position.
        BoardPosition position = board.getPosition( getRenderer().getDraggedPiece().getLocation());

        // valid or not, we won't show the dragged piece after releasing the mouse
        getRenderer().setDraggedPiece(null);

        BoardPosition destp = board.getPosition( loc );
        if (customCheckFails(position, destp)) {
            invalidMove();
            return;
        }

        List possibleMoveList = getPossibleMoveList(position);

        // verify that the move is valid before allowing it to be made
        Iterator it = possibleMoveList.iterator();
        boolean found = false;

        TwoPlayerMove move = null;
        while ( it.hasNext() && !found ) {
            move = (TwoPlayerMove) it.next();
            if ( (move.getToRow() == destp.getRow()) && (move.getToCol() == destp.getCol()) )
                found = true;
        }

        if ( !found ) {
            invalidMove();
View Full Code Here


        int row, col;
        ChessBoard b = (ChessBoard)controller_.getBoard();
        boolean checked = false;
        for ( row = 1; row <= b.getNumRows(); row++ ) {
            for ( col = 1; col <= b.getNumCols(); col++ ) {
                BoardPosition pos = b.getPosition( row, col );
                assert (pos != null) : "pos at row="+row+" col="+col +" is null";
                if ( pos.isOccupied() && pos.getPiece().isOwnedByPlayer1() == m.isPlayer1() ) {
                    // @@ second arg is not technically correct. it should be last move, but I don't think it matters.
                    checked = b.isKingCheckedByPosition(pos, m);
                }
                if (checked) {
                    JOptionPane.showMessageDialog( this,
View Full Code Here

    public String getToolTipText( MouseEvent e ) {

        Location loc = getBoardRenderer().createLocation(e);
        StringBuilder sb = new StringBuilder( "<html><font=-3>" );

        BoardPosition space = ((IRectangularBoard) controller_.getBoard()).getPosition( loc );
        if ( space != null && space.isOccupied() && GameContext.getDebugMode() > 0 ) {
            sb.append( loc );
            sb.append("<br>");
            sb.append(space.toString());
        }
        sb.append( "</font></html>" );
        return sb.toString();
    }
View Full Code Here

        assert (move.getPiece() != null) : "piece for next move is null: " + move;

        g2.setColor(getPieceColor(move.getPiece()));

        BoardPosition position = b.getPosition(move.getToRow(), move.getToCol());
        int pieceSize = (int)(NEXT_MOVE_SIZE_FRAC * getPieceSize(cellSize, move.getPiece()));
        Point pos = getPosition(position, cellSize, pieceSize, margin);
        g2.setFont(BASE_FONT);
        g2.fillOval( pos.x, pos.y, pieceSize, pieceSize );
        g2.setColor(move.isUrgent() ? URGENT_COLOR : Color.DARK_GRAY);
View Full Code Here

    @Override
    protected boolean makeInternalMove( Move move ) {

        TwoPlayerMove m = (TwoPlayerMove)move;
        if ( !m.isPassOrResignation() ) {
            BoardPosition pos = getPosition(m.getToLocation());
            assert(m.getPiece() != null) : "move's piece was null :" + m;
            pos.setPiece(m.getPiece());
            GamePiece piece = pos.getPiece();
            assert (piece != null):
                    "The piece was " + piece + ". Moved to " + m.getToRow() + ", " + m.getToCol();
            if ( GameContext.getDebugMode() > 0 ) {
                piece.setAnnotation( Integer.toString(getMoveList().getNumMoves()) );
            }
View Full Code Here

        TwoPlayerMove m = (TwoPlayerMove) getMoveList().getLastMove();

        for ( int i = 1; i <= nRows; i++ )   {
            boolean followingLastMove = false;
            for ( int j = 1; j <= nCols; j++ ) {
                BoardPosition pos = this.getPosition(i,j);
                if (pos.isOccupied()) {
                    if (pos.getLocation().equals(m.getToLocation())) {
                        bldr.append("[").append(pos.getPiece()).append("]");
                        followingLastMove = true;
                    }
                    else  {
                        bldr.append(followingLastMove?"":" ").append(pos.getPiece());
                        followingLastMove = false;
                    }
                }
                else {
                    bldr.append(followingLastMove?"":" " + "_");
View Full Code Here

        int nrows = board.getNumRows();
        int ncols = board.getNumCols();

        for (int i=1; i<=nrows; i++) {
            for (int j=1; j<=ncols; j++) {
                BoardPosition pos = board.getPosition(i, j);
                if (pos.isOccupied()) {
                    applyPositionToKey(new ByteLocation(i, j), board.getStateIndex(pos));
                }
            }
        }
        return currentKey;
View Full Code Here

            PokerPlayer pp = (PokerPlayer) p.getActualPlayer();

            int row = (int) (0.93 * rowRad + (RADIUS * rowRad) * (Math.sin(angle)));
            int col = (int) (0.9 * colRad + (RADIUS * colRad) * (Math.cos(angle)));

            BoardPosition position = getPosition(row, col);
            position.setPiece(pp.getPiece());
            pp.getPiece().setLocation(position.getLocation());
            angle += angleIncrement;
        }
    }
View Full Code Here

        if (viewer.get2PlayerController().isProcessing() || wallPlacingMode)
            return;

        Board board = viewer.getBoard();
        Location loc = getRenderer().createLocation(e);
        BoardPosition position = board.getPosition( loc );

        // if there is no piece, or out of bounds, then return without doing anything
        if ( (position == null) || (position.isUnoccupied()) ) {
            return;
        }
        GamePiece piece = position.getPiece();
        if ( viewer.get2PlayerController().isPlayer1sTurn() != piece.isOwnedByPlayer1() )
            return; // wrong players piece

        getRenderer().setDraggedPiece(position);
    }
View Full Code Here

        PathList opponentPaths = board.findAllOpponentShortestPaths(player1);

        List<BoardPosition> pawnLocations = new LinkedList<BoardPosition>();
        for ( int row = 1; row <= board.getNumRows(); row++ ) {
            for ( int col = 1; col <= board.getNumCols(); col++ ) {
                BoardPosition p = board.getPosition( row, col );
                if ( p.isOccupied() && p.getPiece().isOwnedByPlayer1() == player1 ) {
                    pawnLocations.add(p);
                    addMoves( p, moveList, opponentPaths, weights_ );
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.board.BoardPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.