Package org.cspoker.client.common.playerstate

Examples of org.cspoker.client.common.playerstate.PlayerState


    }
   
    if (roundEnds) {
      return getNewRoundState(state);
    } else {
      PlayerState nextActivePlayerAfter = state
          .getNextActivePlayerAfter(actor);
      if (nextActivePlayerAfter == null) {
        // BigBlind is all-in
        return getNewRoundState(state);
      }
      return new NextPlayerState(state, new NextPlayerEvent(
          nextActivePlayerAfter.getPlayerId()));
    }
  }
View Full Code Here


      }
    }
  }

  public double getUpperWinBound(){
    PlayerState bot = gameState.getPlayer(botId);
    int botStack = bot.getStack();
    //TODO check what if bot allin and 2 other players?
    int stealable = 0;
    Set<PlayerState> players = gameState.getAllSeatedPlayers();
    double rakeFactor = 1-gameState.getTableConfiguration().getRake();
    for(PlayerState p:players){
View Full Code Here

    return new CheckState(gameState, new CheckEvent(actor));
  }
 
  @Override
  public GameState getStateAfterAction() throws GameEndedException {
    PlayerState nextToAct = gameState.getNextActivePlayerAfter(actor);
    // if bigblind is all-in, he shouldn't check again, so we're safe
    boolean newRound = nextToAct.hasChecked()
        || gameState.getRound().equals(Round.PREFLOP)
        && actor.equals(gameState.getBigBlind())
        && gameState.getLargestBet() <= gameState
            .getTableConfiguration().getBigBlind();

    GameState checkState = getUnwrappedStateAfterAction();
    if (!newRound) {
      return new NextPlayerState(checkState, new NextPlayerEvent(
          nextToAct.getPlayerId()));
    }
    return getNewRoundState(checkState);
  }
View Full Code Here

    @Override
    public void onPlayerChips(PlayerChips playerChips) {
      try {
        //update sitting players
        PlayerId id = getId(playerChips);
        PlayerState player = getGameState().getPlayer(id);
        if(player!= null && inWinnerZone.get()){
          int prevStack = player.getStack();
          if(prevStack != playerChips.getMoney()){
            dispatch(new WinnerEvent(ImmutableSet.of(new Winner(id,playerChips.getMoney()-prevStack))));
          }
        }

        //refresh state
        player = getGameState().getPlayer(id);
        //sanity checks
        if(player!=null){
          if(player.getStack()!=playerChips.getMoney()){
            String msg = "Stack of "+id+" is "+player.getStack()+" but should be "+playerChips.getMoney();
            throw new IllegalStateException(msg);
          }
          if(!endLastRound.get() && player.getBet()!=playerChips.getBet()){
            String msg = "Bet of "+id+" is "+player.getBet()+" but should be "+playerChips.getBet();
            throw new IllegalStateException(msg);
          }
        }

        ///update arrivedPlayers
View Full Code Here

    public void onDealer(Dealer dealer) {
      List<SeatedPlayer> players = new ArrayList<SeatedPlayer>();
      PlayerId dealerId = null;
      //only send players that actually sit in AND are ingame in the new deal event.
      for(int i:dealtTo){
        PlayerState p = getGameState().getPlayer(new PlayerId(i));
        players.add(new SeatedPlayer(p.getPlayerId(),p.getSeatId(),p.getName(),p.getStack(), p.getBet(), true, false));
        if(p.getSeatId().getId() == dealer.getDealer()){
          dealerId = p.getPlayerId();
        }
      }
      if(dealerId == null) throw new IllegalSelectorException();
      blindsDone.set(false);
      endLastRound.set(false);
View Full Code Here

  public final int getDeficit(PlayerId playerId) {
    return getLargestBet() - getPlayer(playerId).getBet();
  }

  public final int getCallValue(PlayerId playerId) {
    PlayerState player = getPlayer(playerId);
    return Math.min(getLargestBet() - player.getBet(), player.getStack());
  }
View Full Code Here

    PlayerState player = getPlayer(playerId);
    return Math.min(getLargestBet() - player.getBet(), player.getStack());
  }

  public final boolean isAllowedToRaise(PlayerId playerId) {
    PlayerState player = getPlayer(playerId);
    if (getLargestBet() - player.getBet() >= player.getStack()) {
      return false;
    }
    Set<PlayerState> otherPlayers = getAllSeatedPlayers();
    for (PlayerState otherPlayer : otherPlayers) {
      // check whether we are the only active player left in the game.
View Full Code Here

    }
    return false;
  }

  public final int getLowerRaiseBound(PlayerId playerId) {
    PlayerState player = getPlayer(playerId);
    return Math.max(0,
        Math.min(
            getMinNextRaise(),
            player.getStack()-(getLargestBet() - player.getBet())));
  }
View Full Code Here

            getMinNextRaise(),
            player.getStack()-(getLargestBet() - player.getBet())));
  }

  public final int getUpperRaiseBound(PlayerId playerId) {
    PlayerState player = getPlayer(playerId);
    PlayerState tempPlayer;
    PlayerId tempId = playerId;
    int maxOtherBettableChips=0;
    loop: do{
      //TODO fix infinite loop on double BB
      tempPlayer = getNextActivePlayerAfter(tempId);
      if(tempPlayer==null){
        break loop;
      }
      tempId = tempPlayer.getPlayerId();
      if(!tempPlayer.getPlayerId().equals(playerId)){
        maxOtherBettableChips = Math.max(maxOtherBettableChips, tempPlayer.getBet()+tempPlayer.getStack());
      }else{
        break loop;
      }
    }while(true);
    int betableChips = Math.min(player.getStack()+player.getBet(),maxOtherBettableChips);
View Full Code Here

  }

  @Override
  public final PlayerState getDefaultWinner() {
    Set<PlayerId> ids = getSeatMap().values();
    PlayerState first = null;
    for (PlayerId id : ids) {
      PlayerState state = getPlayer(id);
      if(!state.hasFolded()){
        if(first!=null){
          return null;
        }else{
          first = state;
        }
View Full Code Here

TOP

Related Classes of org.cspoker.client.common.playerstate.PlayerState

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.