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;
+1 -1
View File
@@ -151,7 +151,7 @@ public:
void action();
int checkMyAction(int targetAction, int targetBet, int alreadySet, int myCash, int highestSet, int minimumRaise, int smallBlind);
int checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind);
void preflopEngine();
void flopEngine();
@@ -395,6 +395,11 @@ ClientPlayer::action()
{
}
int
ClientPlayer::checkMyAction(int /*targetAction*/, int /*targetBet*/, int /*highestSet*/, int /*minimumRaise*/, int /*smallBlind*/)
{
return 0;
}
void
ClientPlayer::preflopEngine()
+2 -1
View File
@@ -105,7 +105,8 @@ public:
bool getMyWinnerState() const;
void action();
int checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind);
void preflopEngine();
void flopEngine();
void turnEngine();
+3 -2
View File
@@ -100,9 +100,10 @@ public:
virtual void setMyWinnerState ( bool theValue, int pot ) =0;
virtual bool getMyWinnerState() const =0;
virtual void action() =0;
virtual int checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind) = 0;
virtual void preflopEngine() =0;
virtual void flopEngine() =0;
virtual void turnEngine() =0;