Package com.barrybecker4.game.multiplayer.poker

Examples of com.barrybecker4.game.multiplayer.poker.PokerController


     * @return done return true if the game is over after moving
     */
    @Override
    public boolean doComputerMove(Player player) {
        assert(!player.isHuman());
        GalacticRobotPlayer robot = (GalacticRobotPlayer)player;
        GalacticController gc = (GalacticController) controller_;
        GameContext.log(1, "now doing computer move. about to make orders");

        robot.makeOrders((Galaxy)getBoard(), gc.getNumberOfYearsRemaining());

        /* // records the result on the board.
        Move lastMove = getController().getLastMove();
        GalacticTurn gmove = GalacticTurn.createMove((lastMove==null)? 0 : lastMove.moveNumber + 1);
        gc.makeMove(gmove);
View Full Code Here


     * 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

        player_.setAction(new PokerAction(player_.getName(), actionName, raiseAmount_));
    }

    void showRaiseDialog() {
        // open a dlg to get an order
        PokerController pc = (PokerController)controller_;
        PokerOptions options = (PokerOptions)controller_.getOptions();
        RaiseDialog raiseDialog =
                new RaiseDialog((PokerPlayer)player_, callAmount_, pc.getAllInAmount(),
                                options.getMaxAbsoluteRaise(), options.getAnte());

        raiseDialog.setLocation((int)(this.getLocation().getX() + 40), (int)(this.getLocation().getY() +170));

        boolean canceled = raiseDialog.showDialog();
View Full Code Here

     */
    @Override
    public void actionPerformed(ActionEvent e) {

        if (e.getSource() == commandButton_) {
            PokerController pc = (PokerController)controller_;
            if (!pc.getCurrentPlayer().isHuman()) {
                JOptionPane.showMessageDialog(this, "It's not your turn", "Warning", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            gameChanged(null); // update the current player in the label

           // open the command dialog to get the players commands
           PokerPlayer currentPlayer = (PokerPlayer) pc.getCurrentPlayer().getActualPlayer();

           // if the current player has folded, then advance to the next player.
           if (currentPlayer.hasFolded())  {
               pc.advanceToNextPlayer();
           }

           BettingDialog bettingDialog = new BettingDialog(pc, getParent());

           boolean canceled = bettingDialog.showDialog();
           if ( !canceled ) {
               PokerAction action = (PokerAction)currentPlayer.getAction(pc);
               applyPokerAction(action, currentPlayer);

               pc.advanceToNextPlayer();
           }
        }
    }
View Full Code Here

    }

    /**  apply the players action : fold, check, call, raise */
    private void applyPokerAction(PokerAction action, PokerPlayer currentPlayer) {

         PokerController pc = (PokerController)controller_;
         int callAmount = pc.getCurrentMaxContribution() - currentPlayer.getContribution();

         switch (action.getActionName()) {
             case FOLD :
                 currentPlayer.setFold(true);
                 break;
             case CALL :
                 if (callAmount <= currentPlayer.getCash())  {
                     currentPlayer.contributeToPot(pc.getRound(), callAmount);
                 } else {
                     currentPlayer.setFold(true);
                     // if this happens it was probably because someone was allowed
                     // to raise by more than the all in amount.
                     assert false:"callAmount=" + callAmount +" currentPlayer cash="+currentPlayer.getCash();
                 }
                 break;
             case RAISE :
                 currentPlayer.contributeToPot(pc.getRound(), callAmount);
                 int raise = action.getRaiseAmount();
                 currentPlayer.contributeToPot(pc.getRound(), raise);
                 break;
        }
        if (controller_.isOnlinePlayAvailable())  {
            controller_.getServerConnection().playerActionPerformed(action);
        }
View Full Code Here

     */
    public PokerGameViewer() {}

    @Override
    protected PokerController createController() {
        return new PokerController();
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.multiplayer.poker.PokerController

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.