From f3b3fd9d7cc6645448836fb0a6913fa8d79361b9 Mon Sep 17 00:00:00 2001 From: floty Date: Tue, 9 Oct 2007 21:19:22 +0000 Subject: [PATCH] checkMyAction() --- src/engine/local_engine/localbero.cpp | 1 + src/engine/local_engine/localplayer.cpp | 54 +++++++++++++++++++++++++ src/engine/local_engine/localplayer.h | 2 + 3 files changed, 57 insertions(+) diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index 517d4970..3bd27b3f 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -381,6 +381,7 @@ void LocalBeRo::run() { myHand->getGuiInterface()->meInAction(); } else { + //Gegner sind dran myHand->getGuiInterface()->beRoAnimation2(myBeRoID); } diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index aab74948..499128f4 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -934,6 +934,11 @@ void LocalPlayer::setHand(HandInterface* br) { actualHand = br; } void LocalPlayer::action() { +// int myOldCash = myCash; +// int oldHighestSet = actualHand->getCurrentBeRo()->getHighestSet(); +// int oldMinimumRaise = actualHand->getCurrentBeRo()->getMinimumRaise(); +// int myOldSet = mySet; + switch(actualHand->getActualRound()) { case 0: { @@ -974,6 +979,9 @@ void LocalPlayer::action() { default: {} } +// cout << checkMyAction(myAction, mySet - myOldSet, myOldSet, myOldCash, oldHighestSet, oldMinimumRaise, actualHand->getSmallBlind()) << endl; + + myTurn = 0; // cout << "jetzt" << endl; @@ -986,6 +994,52 @@ 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) { + + switch(targetAction) { + case PLAYER_ACTION_FOLD: { + return 0; + } break; + case PLAYER_ACTION_CHECK: { + if(alreadySet == highestSet) { + return 0; + } + } break; + case PLAYER_ACTION_CALL: { + if(alreadySet < highestSet && targetBet <= myCash) { + // not all in + if(myCash + alreadySet >= highestSet && targetBet == highestSet - alreadySet) { + return 0; + } + // all in + if(myCash + alreadySet <= highestSet) { + return 0; + } + } + } break; + case PLAYER_ACTION_BET: { + if(highestSet == 0 && targetBet <= myCash && targetBet >= 2*smallBlind) { + return 0; + } + } break; + case PLAYER_ACTION_RAISE: { + if(highestSet > 0 && targetBet >= minimumRaise && targetBet <= myCash) { + return 0; + } + } break; + case PLAYER_ACTION_ALLIN: { + if(targetBet == myCash) { + return 0; + } + } break; + default: { + + } + } + + return 1; + +} void LocalPlayer::preflopEngine() { diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index 30a3e43e..8dfdc9f1 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -150,6 +150,8 @@ public: void action(); + + int checkMyAction(int targetAction, int targetBet, int alreadySet, int myCash, int highestSet, int minimumRaise, int smallBlind); void preflopEngine(); void flopEngine();