}
/** apply the players action : fold, check, call, raise */
private void applyPokerAction(PokerAction action, PokerPlayer currentPlayer) {
PokerController pc = (PokerController)controller_;
int callAmount = pc.getCurrentMaxContribution() - currentPlayer.getContribution();
switch (action.getActionName()) {
case FOLD :
currentPlayer.setFold(true);
break;
case CALL :
if (callAmount <= currentPlayer.getCash()) {
currentPlayer.contributeToPot(pc.getRound(), callAmount);
} else {
currentPlayer.setFold(true);
// if this happens it was probably because someone was allowed
// to raise by more than the all in amount.
assert false:"callAmount=" + callAmount +" currentPlayer cash="+currentPlayer.getCash();
}
break;
case RAISE :
currentPlayer.contributeToPot(pc.getRound(), callAmount);
int raise = action.getRaiseAmount();
currentPlayer.contributeToPot(pc.getRound(), raise);
break;
}
if (controller_.isOnlinePlayAvailable()) {
controller_.getServerConnection().playerActionPerformed(action);
}