Added error handling for networking stuff. Now checking the player action.

This commit is contained in:
lotodore
2007-10-10 22:21:24 +00:00
parent de0f16a6fc
commit 253778bf30
15 changed files with 176 additions and 85 deletions
+8 -8
View File
@@ -994,41 +994,41 @@ void LocalPlayer::action() {
// cout << "playerID in action(): " << (*(actualHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl;
}
int LocalPlayer::checkMyAction(int targetAction, int targetBet, int alreadySet, int myCash, int highestSet, int minimumRaise, int smallBlind) {
int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind) {
switch(targetAction) {
case PLAYER_ACTION_FOLD: {
return 0;
} break;
case PLAYER_ACTION_CHECK: {
if(alreadySet == highestSet) {
if(getMySet() == highestSet) {
return 0;
}
} break;
case PLAYER_ACTION_CALL: {
if(alreadySet < highestSet && targetBet <= myCash) {
if(getMySet() < highestSet && targetBet <= getMyCash()) {
// not all in
if(myCash + alreadySet >= highestSet && targetBet == highestSet - alreadySet) {
if(getMyCash() + getMySet() >= highestSet && targetBet == highestSet - getMySet()) {
return 0;
}
// all in
if(myCash + alreadySet <= highestSet) {
if(getMyCash() + getMySet() <= highestSet) {
return 0;
}
}
} break;
case PLAYER_ACTION_BET: {
if(highestSet == 0 && targetBet <= myCash && targetBet >= 2*smallBlind) {
if(highestSet == 0 && targetBet <= getMyCash() && targetBet >= 2*smallBlind) {
return 0;
}
} break;
case PLAYER_ACTION_RAISE: {
if(highestSet > 0 && targetBet >= minimumRaise && targetBet <= myCash) {
if(highestSet > 0 && targetBet >= minimumRaise && targetBet <= getMyCash()) {
return 0;
}
} break;
case PLAYER_ACTION_ALLIN: {
if(targetBet == myCash) {
if(targetBet == getMyCash()) {
return 0;
}
} break;