Package org.cspoker.client.common.playerstate

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


 
  public AllInState(final GameState gameState, final AllInEvent event) {
    super(gameState);
    this.event = event;
   
    final PlayerState player = super.getPlayer(event.getPlayerId());
    this.newPotSize = super.getRoundPotSize() + event.getMovedAmount();
   
    this.newBetSize = player.getBet() + event.getMovedAmount();
    int buildingRaise = newBetSize - super.getLargestBet();
    if (buildingRaise < 0) {
      buildingRaise = 0;
    }
    raise = buildingRaise;
View Full Code Here


  public BetState(final GameState gameState, final BetEvent event) {
    super(gameState);
    this.event = event;

    PlayerState oldPlayerState = super.getPlayer(event.getPlayerId());

    betAfterBlindCase = Round.PREFLOP.equals(gameState.getRound());
    if(betAfterBlindCase && gameState.getDeficit(event.getPlayerId())>0)
      throw new IllegalStateException("Can't bet in the preflop round when you have a deficit to pay.");
   

    final int newStack = oldPlayerState.getStack() - event.getAmount();
    this.newPotSize = super.getRoundPotSize() + event.getAmount();
    this.playerState = new ForwardingPlayerState(oldPlayerState) {

      @Override
      public int getStack() {
        return newStack;
      }

      @Override
      public int getBet() {
        if(betAfterBlindCase){
          return super.getBet()+BetState.this.event.getAmount();
        }
        return BetState.this.event.getAmount();
      }

      @Override
      public int getTotalInvestment() {
        return super.getTotalInvestment()+BetState.this.event.getAmount();
      }

      @Override
      public PlayerId getPlayerId() {
        return BetState.this.event.getPlayerId();
      }

      @Override
      public boolean hasFolded() {
        return false;
      }
     
      @Override
      public boolean hasBeenDealt() {
        return true;
      }

      /**
       * {@inheritDoc}
       */
       @Override
       public List<Integer> getBetProgression() {
         if(betAfterBlindCase){
           List<Integer> result = new ArrayList<Integer>();
           PlayerId lastBettorId = gameState.getLastBettor();
           PlayerState lastBettor = gameState.getPlayer(lastBettorId);
           List<Integer> previousBetProgression = lastBettor.getBetProgression();
           result.addAll(previousBetProgression);
           result.add(event.getAmount());
           return Collections.unmodifiableList(result);
         }
         return Collections.singletonList(getBet());
View Full Code Here

    Builder<PlayerId, PlayerState> playerStateBuilder = ImmutableMap.builder();
   
    Set<PlayerId> playersIds = gameState.getSeatMap().values();
   
    for (final PlayerId playerId : playersIds) {
      final PlayerState oldPlayerState = gameState.getPlayer(playerId);
     
      final EnumSet<Card> cards = oldPlayerState.getCards();
      final int stack = oldPlayerState.getStack();
      final boolean hasFolded = oldPlayerState.hasFolded();
      final boolean hasBeenDealt = oldPlayerState.hasBeenDealt();
      final SeatId seat = oldPlayerState.getSeatId();
      final int investment = oldPlayerState.getTotalInvestment();
     
      PlayerState playerState = new AbstractPlayerState() {
       
        @Override
        public String getName() {
          return oldPlayerState.getName();
        }
View Full Code Here

  private final PlayerState playerState;
 
  public RaiseState(final GameState gameState, final RaiseEvent event) {
    super(gameState);
    this.event = event;
    final PlayerState oldPlayerState = super.getPlayer(event.getPlayerId());
    this.newBetSize = super.getLargestBet() + event.getAmount();
    final int newStack = oldPlayerState.getStack() - event.getMovedAmount();
    this.newPotSize = super.getRoundPotSize() + event.getMovedAmount();
    playerState = new ForwardingPlayerState(oldPlayerState) {
     
      @Override
      public int getBet() {
View Full Code Here

  private final int newPotSize;

  public CheckState(final GameState gameState, final CheckEvent checkEvent) {
    super(gameState);
    this.checkEvent = checkEvent;
    final PlayerState player = gameState.getPlayer(checkEvent.getPlayerId());

    //case if big blind checks after all opponents called
    //OR if additional blind checks
    checkAfterBlindCase = Round.PREFLOP.equals(gameState.getRound());
    if(checkAfterBlindCase && gameState.getDeficit(checkEvent.getPlayerId())>0)
View Full Code Here

  private final PlayerState playerState;
 
  public FoldState(GameState gameState, FoldEvent event) {
    super(gameState);
    this.event = event;
    final PlayerState oldPlayerState = super.getPlayer(event.getPlayerId());
    playerState = new ForwardingPlayerState(oldPlayerState) {
     
      @Override
      public boolean hasFolded() {
        return true;
      }
     
      @Override
      public PlayerId getPlayerId() {
        return FoldState.this.event.getPlayerId();
      }
     
      @Override
      public boolean hasChecked() {
        return false;
      }
     
      @Override
      public boolean hasBeenDealt() {
        return true;
      }
     
      /**
       * {@inheritDoc}
       */
      @Override
      public List<Integer> getBetProgression() {
        return oldPlayerState.getBetProgression();
      }
     
    };
  }
View Full Code Here

    super(gameState);
    this.event = event;
   
    final int newBetSize = super.getLargestBet();
   
    final PlayerState player = super.getPlayer(event.getPlayerId());
    final int chipsMoved = newBetSize - player.getBet();
    final int newStack = player.getStack() - chipsMoved;
   
    this.newPotSize = super.getRoundPotSize() + chipsMoved;
   
    playerState = new ForwardingPlayerState(player) {
     
View Full Code Here

  private final PlayerState playerState;
 
  public BlindState(GameState gameState, BlindEvent event) {
    super(gameState);
    this.event = event;
    PlayerState oldPlayerState = super.getPlayer(event.getPlayerId());
    final int newStack = oldPlayerState.getStack() - event.getAmount();
    this.newPot = super.getRoundPotSize() + event.getAmount();
   
    playerState = new ForwardingPlayerState(oldPlayerState) {
     
      @Override
View Full Code Here

  }

  @Override
  public GameState getStateAfterAction() {
    GameState betState = getUnwrappedStateAfterAction();
    PlayerState nextToAct = betState.getNextActivePlayerAfter(actor);
    if (nextToAct != null) {
      return new NextPlayerState(betState, new NextPlayerEvent(nextToAct
          .getPlayerId()));
    }
    throw new IllegalStateException("Round can't be over after a bet.");
  }
View Full Code Here

  @Override
  public GameState getStateAfterAction() throws GameEndedException,
      DefaultWinnerException {
    boolean roundEnds = true;
    Set<PlayerState> players = gameState.getAllSeatedPlayers();
    PlayerState first = null;
    boolean noDefaultWinner = false;
    // TODO use getNbPlayers()
    forloop: for (PlayerState player : players) {
      if (roundEnds && player.isActivelyPlaying()
          && !player.getPlayerId().equals(actor)
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.