@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.