Exemplo n.º 1
0
  @Override
  public void start() {
    // Close table
    setOpen(false);

    // Begin first phase
    phase = PokerPhase.PREFLOP;

    // Create pot
    pot = newPot(0, new HashSet<>(getPlayers()));

    // Post blinds
    blinds();

    // Deal 2 cards to each player
    deck.shuffle();
    for (PokerPlayer player : getPlayers()) {
      player.dealCard(deck.draw(player), deck.draw(player));
    }

    // Start betting with player left of big blind
    playerTurn = getPlayerCount() - 2;
    nextPlayer();
    for (PokerPlayer player : getPlayers()) {
      player.requireAction();
    }
    betting();
  }
Exemplo n.º 2
0
  @Override
  public void stop() {
    super.stop();

    deck.reset();
    phase = PokerPhase.STANDBY;
  }
Exemplo n.º 3
0
  /** Rotates dealer and blinds, eliminates players, and prepares table for next hand. */
  public void handEnd() {
    // Begin end hand phase
    phase = PokerPhase.HAND_END;

    // Eliminate players with no money
    for (PokerPlayer player : new ArrayList<>(getPlayers())) {
      if (player.getChips() == 0) {
        removePlayer(player);
      }
    }

    int playersLeft = getPlayers().size();
    if (playersLeft > 0) {
      // Rotate dealer, small blind, and big blind
      getPlayers().add(0, getPlayers().remove(getPlayerCount() - 1));

      // Eliminate players that can't afford blind
      while (playersLeft > 1) {
        PokerPlayer smallBlind = getSmallBlind();
        if (smallBlind.getChips() < settings.getSmallBlind()) {
          removePlayer(smallBlind);
          playersLeft--;
          continue;
        }
        break;
      }
      while (playersLeft > 2) {
        PokerPlayer bigBlind = getBigBlind();
        if (bigBlind.getChips() < settings.getBigBlind()) {
          removePlayer(bigBlind);
          playersLeft--;
          continue;
        }
        break;
      }
    }

    // Reset deck, open table, and wait to start next game
    deck.reset();
    tableCards.clear();
    for (PokerPlayer player : getPlayers()) {
      player.nextHand();
    }
    setOpen(true);
    phase = PokerPhase.STANDBY;
  }
Exemplo n.º 4
0
 /**
  * Deals cards to the table.
  *
  * @param cards The amount of cards to deal
  */
 public void dealTableCards(int cards) {
   for (int i = 0; i < cards; i++) {
     tableCards.add(deck.draw());
   }
 }