Example #1
0
 @Override
 public void joinedTable(TableType type, int bigBlind, List<Player> players) {
   for (Player player : players) {
     PlayerPanel playerPanel = playerPanels.get(player.getName());
     if (playerPanel != null) {
       playerPanel.update(player);
     }
   }
 }
Example #2
0
 @Override
 public void playerUpdated(Player player) {
   PlayerPanel playerPanel = playerPanels.get(player.getName());
   if (playerPanel != null) {
     playerPanel.update(player);
   }
 }
Example #3
0
 @Override
 public void playerActed(Player player) {
   String name = player.getName();
   PlayerPanel playerPanel = playerPanels.get(name);
   if (playerPanel != null) {
     playerPanel.update(player);
     Action action = player.getAction();
     if (action != null) {
       boardPanel.setMessage(String.format("%s %s.", name, action.getVerb()));
       if (player.getClient() != this) {
         boardPanel.waitForUserInput();
       }
     }
   } else {
     throw new IllegalStateException(String.format("No PlayerPanel found for player '%s'", name));
   }
 }
Example #4
0
  /** Constructor. */
  public Main() {
    super("Texas Hold'em poker");

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().setBackground(UIConstants.TABLE_COLOR);
    setLayout(new GridBagLayout());

    gc = new GridBagConstraints();

    controlPanel = new ControlPanel(TABLE_TYPE);

    boardPanel = new BoardPanel(controlPanel);
    addComponent(boardPanel, 1, 1, 1, 1);

    players = new LinkedHashMap<String, Player>();
    humanPlayer = new Player("Player", STARTING_CASH, this);
    players.put("Player", humanPlayer);
    players.put("Joe", new Player("Joe", STARTING_CASH, new BasicBot(0, 75)));
    players.put("Mike", new Player("Mike", STARTING_CASH, new BasicBot(25, 50)));
    players.put("Eddie", new Player("Eddie", STARTING_CASH, new BasicBot(50, 25)));

    table = new Table(TABLE_TYPE, BIG_BLIND);
    for (Player player : players.values()) {
      table.addPlayer(player);
    }

    playerPanels = new HashMap<String, PlayerPanel>();
    int i = 0;
    for (Player player : players.values()) {
      PlayerPanel panel = new PlayerPanel();
      playerPanels.put(player.getName(), panel);
      switch (i++) {
        case 0:
          // North position.
          addComponent(panel, 1, 0, 1, 1);
          break;
        case 1:
          // East position.
          addComponent(panel, 2, 1, 1, 1);
          break;
        case 2:
          // South position.
          addComponent(panel, 1, 2, 1, 1);
          break;
        case 3:
          // West position.
          addComponent(panel, 0, 1, 1, 1);
          break;
        default:
          // Do nothing.
      }
    }

    // Show the frame.
    pack();
    setResizable(false);
    setLocationRelativeTo(null);
    setVisible(true);

    // Start the game.
    table.run();
  }
Example #5
0
 @Override
 public Action act(int minBet, int currentBet, Set<Action> allowedActions) {
   boardPanel.setMessage("Please select an action:");
   return controlPanel.getUserInput(minBet, humanPlayer.getCash(), allowedActions);
 }
Example #6
0
 @Override
 public void actorRotated(Player actor) {
   setActorInTurn(false);
   actorName = actor.getName();
   setActorInTurn(true);
 }
Example #7
0
 @Override
 public void handStarted(Player dealer) {
   setDealer(false);
   dealerName = dealer.getName();
   setDealer(true);
 }