Examples of BlockadeBoardPosition


Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

    private BlockadeMove checkAndGetValidMove(BlockadeBoardPosition origPosition, Location placedLocation) {
        BlockadeController controller = (BlockadeController)viewer_.getController();
        BlockadeBoard board = (BlockadeBoard) controller.getBoard();
        List<BlockadeMove> possibleMoveList = controller.getPossibleMoveList(origPosition);

        BlockadeBoardPosition destpos = board.getPosition( placedLocation );
        if (customCheckFails(destpos)) {
            JOptionPane.showMessageDialog( viewer_, GameContext.getLabel("ILLEGAL_MOVE"));
            return null;
        }
        // verify that the move is valid before allowing it to be made.
        Iterator it = possibleMoveList.iterator();
        boolean found = false;

        BlockadeMove m = null;
        while ( it.hasNext() && !found ) {
            m = (BlockadeMove) it.next();
            if ( (m.getToRow() == destpos.getRow()) && (m.getToCol() == destpos.getCol()) )
                found = true;
        }

        if ( !found ) {
            return null; // it was not valid
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

        boolean blocked = false;

        int fromRow = move.getFromRow();
        int fromCol = move.getFromCol();
        BlockadeBoardPosition start = board.getPosition(fromRow, fromCol);
        BlockadeBoardPosition west = start.getNeighbor(Direction.WEST, board);
        BlockadeBoardPosition north = start.getNeighbor(Direction.NORTH, board);
        BlockadeBoardPosition south, east;

        switch (move.getDirection()) {
            case NORTH_NORTH :
                BlockadeBoardPosition northNorth = start.getNeighbor(Direction.NORTH_NORTH, board);
                if (northNorth.isSouthBlocked()) blocked = true;
            case NORTH :
                if (north.isSouthBlocked()) blocked = true;
                break;
            case WEST_WEST :
                BlockadeBoardPosition westWest = start.getNeighbor(Direction.WEST_WEST, board);
                if (westWest.isEastBlocked()) blocked = true;
            case WEST :
                if (west.isEastBlocked()) blocked = true;
                break;
            case EAST_EAST :
                east = start.getNeighbor(Direction.EAST, board);
                if (east.isEastBlocked()) blocked = true;
            case EAST :
                if (start.isEastBlocked()) blocked = true;
                break;
            case SOUTH_SOUTH :
                south = start.getNeighbor(Direction.SOUTH, board);
                if (south.isSouthBlocked()) blocked = true;
            case SOUTH :
                if (start.isSouthBlocked()) blocked = true;
                break;
            case NORTH_WEST :
                BlockadeBoardPosition northWest = start.getNeighbor(Direction.NORTH_WEST, board);
                if (!((west.isEastOpen() && northWest.isSouthOpen()) ||
                     (north.isSouthOpen() && northWest.isEastOpen()) ) )  {
                    blocked = true;
                }
                break;
            case NORTH_EAST :
                BlockadeBoardPosition northEast = start.getNeighbor(Direction.NORTH_EAST, board);
                if (!((start.isEastOpen() && northEast.isSouthOpen()) ||
                     (north.isSouthOpen() && north.isEastOpen()) ) )  {
                    blocked = true;
                }
                break;
            case SOUTH_WEST :
                BlockadeBoardPosition southWest = start.getNeighbor(Direction.SOUTH_WEST, board);
                if (!((west.isEastOpen() && west.isSouthOpen()) ||
                     (start.isSouthOpen() && southWest.isEastOpen()) ) )  {
                    blocked = true;
                }
                break;
            case SOUTH_EAST :
                south = start.getNeighbor(Direction.SOUTH, board);
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

        // make the move
        board.makeMove(firstStep);

        // after making the first move, the shortest paths may have changed somewhat.
        // unfortunately, I think we need to recalculate them.
        BlockadeBoardPosition newPos =
                board.getPosition(firstStep.getToRow(), firstStep.getToCol());
        PathList ourPaths = board.findShortestPaths(newPos);

        List<BlockadeMove> wallMoves = wallFinder.findWallPlacementsForMove(firstStep, ourPaths);
        GameContext.log(2, "num wall placements for Move = " + wallMoves.size());
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

    public String getConstructorString() {

        String wallCreator ="null";
        if ( getWall() != null) {
            Iterator<BlockadeBoardPosition> it = getWall().getPositions().iterator();
            BlockadeBoardPosition p1 = it.next();
            BlockadeBoardPosition p2 = it.next();
            wallCreator = "new BlockadeWall(new BlockadeBoardPosition(" + p1.getRow()  +", "+ p1.getCol() "), "
                                                             + "new BlockadeBoardPosition(" + p2.getRow()  +", "+ p2.getCol() +"))";
        }
        String pieceCreator = "null";
        if (getPiece() != null) {
            pieceCreator = "new GamePiece(" + getPiece().isOwnedByPlayer1() + ")";
        }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

        if (hasWallOverlap(wall)) {
            sError = GameContext.getLabel("CANT_OVERLAP_WALLS");
        }

        BlockadeBoardPosition pos = board.getPosition(location);
        if (sError == null && hasWallIntersection(wall)) {
             sError = GameContext.getLabel("CANT_INTERSECT_WALLS");
        }
        else if (sError == null && pos == null) {
            sError = GameContext.getLabel("INVALID_WALL_PLACEMENT");
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

     * @return error message if the new wall intersects an old one.
     */
    private boolean hasWallIntersection(BlockadeWall wall) {
         boolean vertical = wall.isVertical();
         // you cannot intersect one wall with another
         BlockadeBoardPosition pos = wall.getFirstPosition();

         BlockadeBoardPosition secondPos =
                    (vertical? board.getPosition(pos.getRow(), pos.getCol()+1) :
                               board.getPosition(pos.getRow()+1, pos.getCol()));
        return (vertical && pos.isSouthBlocked() && secondPos.isSouthBlocked())
                || (!vertical && pos.isEastBlocked()) && secondPos.isEastBlocked();
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

    private void drawWalls(Graphics2D g2, BlockadeBoard board) {

        for ( int i = 1; i <= board.getNumRows(); i++ )  {
            for ( int j = 1; j <= board.getNumCols(); j++ ) {
                BlockadeBoardPosition pos = board.getPosition( i, j );
                BlockadePieceRenderer.renderWallAtPosition(g2, pos, cellSize, getMargin());
            }
        }
        if ( draggedWall_ != null ) {
            drawDraggedWall(g2, cellSize);
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

    private void drawShortestPaths(Graphics2D g2, BlockadeBoard board) {
        int numPieces = 0;
        for ( int i = 1; i <= board.getNumRows(); i++ )  {
            for ( int j = 1; j <= board.getNumCols(); j++ ) {
                BlockadeBoardPosition pos = board.getPosition( i, j );
                if (pos.isOccupied())       {
                    pieceRenderer_.render(g2, pos, cellSize, getMargin(), board);
                    if (GameContext.getDebugMode() > 0)
                       PathRenderer.drawShortestPaths(g2, pos, board, cellSize);
                    numPieces++;
                }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

     */
    public BlockadeBoardPosition[] getCellLocations(int x, int y, Location loc, int cellSize) {

        int index = getWallIndexForPosition(x, y, loc, cellSize);

        BlockadeBoardPosition pos1 = null,  pos2 = null;

        switch (index) {
            case 0 :
                pos1 = board.getPosition(loc);
                pos2 = board.getPosition(loc.getRow()+1, loc.getCol());
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoardPosition

        if (piece != null)  {
            // render the piece as normal
            super.render( g2, position, cellSize, margin, b);
        }
        // render the south and east walls if present
        BlockadeBoardPosition bpos = (BlockadeBoardPosition)position;

        renderWallAtPosition(g2, bpos, cellSize, margin);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.