Package com.barrybecker4.game.twoplayer.blockade.board

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


     * The dialog needs the user to dismiss it when done.
     * It is not shown if all computer players.
     * @param battle  the battle to show in a separate dialog
     */
    private void showBattle(BattleSimulation battle) {
        BattleDialog bDlg = new BattleDialog(parent_, battle, this);
        //bDlg.setLocationRelativeTo(this);

        Point p = this.getParent().getLocationOnScreen();
        // offset the dlg so the Galaxy grid is visible as a reference.
        bDlg.setLocation((int) (p.getX() + getParent().getWidth()),
                         (int) (p.getY() + 0.65 * getParent().getHeight()));
        bDlg.setModal(true);
        bDlg.setVisible(true);
    }
View Full Code Here


    }

    @Override
    protected NewGameDialog createNewGameDialog(Component parent, GameViewModel viewer )
    {
        return new GalacticNewGameDialog( parent, viewer );
    }
View Full Code Here

    }

    @Override
    protected GameOptionsDialog createOptionsDialog(Component parent, GameController controller )
    {
        return new GalacticOptionsDialog( parent, controller );
    }
View Full Code Here

     * display a dialog at the end of the game showing who won and other relevant
     * game specific information.
     */
    @Override
    public void showWinnerDialog() {
        GalacticTallyDialog tallyDialog = new GalacticTallyDialog(parent_, (GalacticController)controller_);
        tallyDialog.showDialog();
    }
View Full Code Here

     */
    private void showOrdersDialog(GalacticController gc) {

        GalacticPlayer currentPlayer = (GalacticPlayer)gc.getCurrentPlayer();

        OrdersDialog ordersDialog =
                new OrdersDialog(null, currentPlayer, gc.getNumberOfYearsRemaining());
        Point p = getParent().getLocationOnScreen();

        // offset the dlg so the Galaxy grid is visible as a reference
        ordersDialog.setLocation((int)(p.getX()+0.7*getParent().getWidth()), (int)(p.getY()+getParent().getHeight()/3.0));

        boolean canceled = ordersDialog.showDialog();
        if ( !canceled ) { // newGame a game with the newly defined options
            currentPlayer.setOrders( ordersDialog.getOrders() );
            gc.advanceToNextPlayer();
        }
    }
View Full Code Here

     * @param direction to move one space (one of EAST, WEST, NORTH, SOUTH).
     * @return the accumulated list of walls.
     */
    BlockadeWallList checkAddWallsForDirection(BlockadeBoardPosition pos, PathList paths,
                                                         Direction direction) {
        BlockadeBoard b = board;
        BlockadeWallList wallsToCheck = new BlockadeWallList();
        BlockadeBoardPosition westPos = pos.getNeighbor(Direction.WEST, b);
        BlockadeBoardPosition eastPos = pos.getNeighbor(Direction.EAST, b);
        BlockadeBoardPosition northPos = pos.getNeighbor(Direction.NORTH, b);
        BlockadeBoardPosition southPos = pos.getNeighbor(Direction.SOUTH, b);
View Full Code Here

        WallAccumulator accumulator = new WallAccumulator(board_);

        // 12 cases
        int fromRow = move.getFromRow();
        int fromCol = move.getFromCol();
        BlockadeBoard b = board_;
        BlockadeBoardPosition origPos = board_.getPosition(fromRow, fromCol);
        BlockadeBoardPosition westPos = origPos.getNeighbor(Direction.WEST, b);
        BlockadeBoardPosition eastPos = origPos.getNeighbor(Direction.EAST, b);
        BlockadeBoardPosition northPos = origPos.getNeighbor(Direction.NORTH, b);
        BlockadeBoardPosition southPos = origPos.getNeighbor(Direction.SOUTH, b);
View Full Code Here

    {
        BlockadeBoardViewer viewer = (BlockadeBoardViewer) viewer_;
        if (wallPlacingMode)  {

            // show the hovering wall
            BlockadeBoard board = (BlockadeBoard)viewer.getBoard();
            // now show it in the new location
            Location loc = getRenderer().createLocation(e);
            if (board.getPosition(loc)==null) {
                return// out of bounds
            }

            BlockadeBoardPosition[] positions =
                    wallPlacer.getCellLocations(e.getX(),  e.getY(), loc, getRenderer().getCellSize());
View Full Code Here

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

        BlockadeController controller = (BlockadeController)viewer_.getController();
        BlockadeBoard board = (BlockadeBoard) controller.getBoard();
        // get the original position.
        BlockadeBoardPosition position =
                board.getPosition(getRenderer().getDraggedPiece().getLocation());

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

        BlockadeMove m = checkAndGetValidMove(position, loc);
        if (m == null) {
            return false;
        }

        // make sure that the piece shows while we decide where to place the wall.
        currentMove = m;
        GameContext.log(1, "legal human move :" + m.toString());
        position.getPiece().setTransparency((short) 0);
        boolean isPlayer1 = position.getPiece().isOwnedByPlayer1();
        BlockadeBoardPosition newPosition =
                board.getPosition(currentMove.getToRow(), currentMove.getToCol());
        newPosition.setPiece(position.getPiece());
        position.setPiece(null);
        viewer_.refresh();

        if (newPosition.isHomeBase( !isPlayer1 )) {
View Full Code Here

     * @param placedLocation location dragged to.
     * @return the valid move else and error is shown and null is returned.
     */
    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.
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.blockade.board.BlockadeBoard

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.