Package com.barrybecker4.game.multiplayer.poker.player

Examples of com.barrybecker4.game.multiplayer.poker.player.PokerPlayer


        // special case of no one raising
        int contrib = getCurrentMaxContribution(players);
        GameContext.log(0, "in roundover check max contrib=" + contrib);

        for (Player pp : players) {
            PokerPlayer p = (PokerPlayer) pp.getActualPlayer();
            if (!p.hasFolded()) {
                assert(p.getContribution() <= contrib) :
                       "contrib was supposed to be the max, but " + p + " contradicats that.";
                if (p.getContribution() != contrib) {
                    return false;
                }
            }
        }
View Full Code Here


        PokerHandScorer scorer = new PokerHandScorer();
        HandScore bestScore = scorer.getScore(bestHand);

        // find the best hand
        for (int i = first + 1; i < players.size(); i++) {
            PokerPlayer player = (PokerPlayer) players.get(i).getActualPlayer();
            HandScore score = scorer.getScore(player.getHand());
            if (!player.hasFolded() && score.compareTo(bestScore) > 0) {
                bestScore = score;
            }
        }

        // find all players with a hand that good (rare that there will be more than one
        for (int i = first; i < players.size(); i++) {
            PokerPlayer player = (PokerPlayer) players.get(i).getActualPlayer();
            if (!player.hasFolded() && scorer.getScore(player.getHand()).compareTo(bestScore) == 0) {
                winners.add(player);
            }
        }

        GameContext.log(0, "The winning players were " + winners);
View Full Code Here

    private boolean allButOneFolded(PlayerList players) {

        int numNotFolded = 0;
        for (final Player pp : players) {
            PokerPlayer player = (PokerPlayer) pp.getActualPlayer();
            if (!player.hasFolded()) {
                numNotFolded++;
            }
        }
        return (numNotFolded == 1);
    }
View Full Code Here

     * @return  number of active players.
     */
    private int getNumNonFoldedPlayers(PlayerList players) {
        int count = 0;
        for (final Player p : players) {
            PokerPlayer player = (PokerPlayer) p.getActualPlayer();
            if (!player.isOutOfGame())
               count++;
        }
        return count;
    }
View Full Code Here

        double rowRad = getNumRows() >> 1;
        double colRad = getNumCols() >> 1;
        reset();
        for (final Player p : players) {

            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

        Color newColor = MultiGamePlayer.getNewPlayerColor(getPlayers());

        PokerOptions options = (PokerOptions) getGameOptions();
        String name = "Robot " + (i+1);
        PokerPlayer robot = PokerRobotPlayer.getRandomRobotPlayer(name, options.getInitialCash(), newColor);
        //SurrogateMultiPlayer sp = new SurrogateMultiPlayer(robot);
        this.addPlayer(robot);
    }
View Full Code Here

                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

    public GameOverMessage(PlayerList players) {
        buf = new StringBuilder("Game Over\n");

        // find the player with the most money. That's the winner.
        int max = -1;
        PokerPlayer winner = null;
        for (final Player p : players) {
            PokerPlayer pp = (PokerPlayer) p;
            if (pp.getCash() > max) {
                max = pp.getCash();
                winner = pp;
            }
        }
        assert winner != null;
        buf.append(winner.getName()).append(" won the game with $").append(winner.getCash()).append('.');
View Full Code Here

     * @return message to show if on client.
     */
    @Override
    protected String applyAction(PlayerAction action,  Player player) {

        PokerPlayer p = (PokerPlayer) player;
        PokerAction act = (PokerAction) action;
        PokerController pc = (PokerController) controller_;

        String msg = null;
        int callAmount = pc.getCurrentMaxContribution() - p.getContribution();
        PokerRound round = pc.getRound();

        switch (act.getActionName()) {
            case FOLD :
                p.setFold(true);
                msg = p.getName() + " folded.";
                break;
            case CALL :
                // GameContext.log(0,"PGV: robot call amount = currentMaxContrib - robot.getContrib) = "
                //                   + pc.getCurrentMaxContribution()+" - "+robot.getContribution());
                if (callAmount <= p.getCash())  {
                    p.contributeToPot(round, callAmount);
                    msg = p.getName() + " has called by adding "+ callAmount + " to the pot.";
                } else {
                    p.setFold(true);
                    msg = p.getName() + " folded.";
                }
                break;
            case RAISE :
                p.contributeToPot(round, callAmount);
                int raise = act.getRaiseAmount();
                p.contributeToPot(round, raise);
                msg = p.getName() + " has met the " + callAmount + ", and rasied the pot by " + raise;
                break;
        }
        return msg;
    }
View Full Code Here

     */
    public void showRoundOver(List<PokerPlayer> winners, int winnings) {

        PlayerList players = controller_.getPlayers();
        for (final Player p : players) {
            PokerPlayer player = (PokerPlayer) p.getActualPlayer();
            player.getHand().setFaceUp(true);
        }
        refresh();

        RoundOverDialog roundOverDlg = new RoundOverDialog(null, winners, winnings);

View Full Code Here

TOP

Related Classes of com.barrybecker4.game.multiplayer.poker.player.PokerPlayer

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.