Package org.cspoker.common.api.shared.exception

Examples of org.cspoker.common.api.shared.exception.IllegalActionException


 
  @Override
  public void check(MutableSeatedPlayer player)
      throws IllegalActionException {
    if (!onTurn(player)) {
      throw new IllegalActionException(player.getName() + " can not check in this round. It should be your turn.");
    }
    if (someoneHasBet()) {
      throw new IllegalActionException(player.getName()
          + " can not check in this round. Someone has already bet.");
    }
    game.nextPlayer();
  }
View Full Code Here


 
  @Override
  public void bet(MutableSeatedPlayer player, int amount)
      throws IllegalActionException {
    if (!onTurn(player) || someoneHasBet() || onlyOneShowdownPlayerLeft() || onlyOnePlayerLeftBesidesAllInPlayers()) {
      throw new IllegalActionException(player.getName() + " can not bet " + amount + " chips in this round.");
    }
   
    // Check whether the bet is valid, according to the betting rules.
    if (!getBettingRules().isValidBet(amount, this)) {
      throw new IllegalActionException(player.toString() + "can not bet. "
          + getBettingRules().getLastBetErrorMessage());
    }
   
    // Can not bet with zero, it is equal to check. Please use check.
    if (amount == 0) {
      throw new IllegalActionException(player.toString() + " can not bet. "
          + "Can not bet with 0 chips. Did you mean check?");
    }
   
    if (amount >= player.getStack().getValue()) {
      allIn(player);
View Full Code Here

 
  @Override
  public void call(MutableSeatedPlayer player)
      throws IllegalActionException {
    if (!onTurn(player)) {
      throw new IllegalActionException(player.getName() + " can not call in this round. It's not his turn.");
    }
   
    if (!someoneHasBet()) {
      throw new IllegalActionException(player.getName() + " can not call in this round. No one has bet.");
    }
   
    if (getBet() == player.getBetChips().getValue()) {
      throw new IllegalActionException(player.getName()
          + " can not call in this round. He has already bet the amount.");
    }
   
    // Check whether the amount with which the bet chips pile
    // is increased exceeds the player's stack.
View Full Code Here

 
  @Override
  public void raise(MutableSeatedPlayer player, int amount)
      throws IllegalActionException {
    if (!onTurn(player)) {
      throw new IllegalActionException(player.getName() + " can not raise with $" + amount
          + " chips in this round because it's not his turn.");
    }
    if (!someoneHasBet()) {
      throw new IllegalActionException(player.getName() + " can not raise with $" + amount
          + " chips in this round because nobody has placed a bet yet.");
    }
    if (onlyOneShowdownPlayerLeft()) {
      throw new IllegalActionException(player.getName() + " can not raise with $" + amount
          + " chips in this round because there's only one player left.");
    }
    if (onlyOnePlayerLeftBesidesAllInPlayers()) {
      throw new IllegalActionException(player.getName() + " can not raise with $" + amount
          + " chips in this round because there's only one player left who's not all-in.");
    }
   
    // If the total number of chips needed for this raise,
    // exceeds or equals the stack of the player, the player should
    // go all-in.
    if ((amount + amountToIncreaseBetPileWith(player)) >= player.getStack().getValue()) {
      allIn(player);
      return;
    }
   
    // Check whether the raise is valid.
    if (!getBettingRules().isValidRaise(amount, this)) {
      throw new IllegalActionException(player.toString() + " can not raise with $"+amount+". "
          + getBettingRules().getLastRaiseErrorMessage());
    }
   
    // Can not raise with zero, it is equal to call. Please use call.
    if (amount == 0) {
      throw new IllegalActionException(player.toString() + " can not raise. "
          + "Can not raise with 0 chips. Did you mean call?");
    }
   
    // Try to transfer the amount to the bet pile.
   
View Full Code Here

 
  @Override
  public void fold(MutableSeatedPlayer player)
      throws IllegalActionException {
    if (!onTurn(player)) {
      throw new IllegalActionException(player.getName() + " can not fold. It should be his turn to do an action.");
    }
   
    foldAction(player);
  }
View Full Code Here

 
  @Override
  public void allIn(MutableSeatedPlayer player)
      throws IllegalActionException {
    if (!onTurn(player)) {
      throw new IllegalActionException(player.getName()
          + " can not go all-in. It isn't his turn to do an action.");
    }
    goAllIn(player);
  }
View Full Code Here

   * @throws IllegalActionException [must] The action performed is not a valid
   *             action.
   */
  public void check(MutableSeatedPlayer player)
      throws IllegalActionException {
    throw new IllegalActionException(player.getName() + " can not check in this round.");
  }
View Full Code Here

   * @throws IllegalActionException [must] The action performed is not a valid
   *             action.
   */
  public void bet(MutableSeatedPlayer player, int amount)
      throws IllegalActionException {
    throw new IllegalActionException(player.getName() + " can not bet " + amount + " chips in this round.");
  }
View Full Code Here

   * @throws IllegalActionException [must] The action performed is not a valid
   *             action.
   */
  public void call(MutableSeatedPlayer player)
      throws IllegalActionException {
    throw new IllegalActionException(player.getName() + " can not call in this round.");
  }
View Full Code Here

   * @throws IllegalActionException [must] The action performed is not a valid
   *             action.
   */
  public void raise(MutableSeatedPlayer player, int amount)
      throws IllegalActionException {
    throw new IllegalActionException(player.getName() + " can not raise with " + amount + " chips in this round.");
  }
View Full Code Here

TOP

Related Classes of org.cspoker.common.api.shared.exception.IllegalActionException

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.