diff --git a/src/engine/local_engine/arraydata.cpp b/src/engine/local_engine/arraydata.cpp index e3d2f4e8..30c1abe3 100644 --- a/src/engine/local_engine/arraydata.cpp +++ b/src/engine/local_engine/arraydata.cpp @@ -1017,13 +1017,6 @@ static const calcHandsData handChancePreflop[] = { #define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData)) #define NUM_HAND_CHANCE_PREFLOP (sizeof(handChancePreflop)/sizeof(calcHandsData)) -ArrayData::ArrayData() -{ -} - -ArrayData::~ArrayData() -{ -} void ArrayData::getHandChancePreflop(int handCode, int** values) { diff --git a/src/engine/local_engine/arraydata.h b/src/engine/local_engine/arraydata.h index ef53df74..743be56c 100644 --- a/src/engine/local_engine/arraydata.h +++ b/src/engine/local_engine/arraydata.h @@ -27,12 +27,8 @@ class ArrayData { public: - ArrayData(); - - ~ArrayData(); - - void getHandChancePreflop(int, int**); - std::vector< std::vector > getHandChancePreflop(int); + static void getHandChancePreflop(int, int**); + static std::vector< std::vector > getHandChancePreflop(int); }; #endif diff --git a/src/engine/local_engine/cardsvalue.cpp b/src/engine/local_engine/cardsvalue.cpp index acff6a7c..00e51e2c 100755 --- a/src/engine/local_engine/cardsvalue.cpp +++ b/src/engine/local_engine/cardsvalue.cpp @@ -21,16 +21,7 @@ using namespace std; -CardsValue::CardsValue() -{ -} - - -CardsValue::~CardsValue() -{ -} - -int CardsValue::holeCardsClass(int one, int two) const +int CardsValue::holeCardsClass(int one, int two) { if((one-1)%13<(two-1)%13) { @@ -214,7 +205,7 @@ int CardsValue::holeCardsClass(int one, int two) const } -int CardsValue::holeCardsToIntCode(int* cards) const +int CardsValue::holeCardsToIntCode(int* cards) { // Code der HoleCards ermitteln @@ -238,7 +229,8 @@ int CardsValue::holeCardsToIntCode(int* cards) const } -int* CardsValue::intCodeToHoleCards(int code) const +/* DO NOT USE, THIS MAY LEAK MEMORY +int* CardsValue::intCodeToHoleCards(int code) { // one possibility !!! @@ -256,9 +248,9 @@ int* CardsValue::intCodeToHoleCards(int code) const return cards; -} +}*/ -int CardsValue::cardsValue(int* cards, int* position) const +int CardsValue::cardsValue(int* cards, int* position) { int array[7][3]; @@ -637,7 +629,7 @@ int CardsValue::cardsValue(int* cards, int* position) const } -vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards) const +vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards) { int i,j; @@ -660,11 +652,8 @@ vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerC switch(beRoID) { case GAME_STATE_PREFLOP: { - ArrayData* myArrayData = new ArrayData; - chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards)); - - delete myArrayData; + chance = ArrayData::getHandChancePreflop(holeCardsToIntCode(playerCards)); } break; diff --git a/src/engine/local_engine/cardsvalue.h b/src/engine/local_engine/cardsvalue.h index 5c6f5b83..1e4bed78 100755 --- a/src/engine/local_engine/cardsvalue.h +++ b/src/engine/local_engine/cardsvalue.h @@ -31,18 +31,14 @@ class CardsValue { public: - CardsValue(); + static int holeCardsClass(int, int); + static int cardsValue(int*, int*); - ~CardsValue(); + static int holeCardsToIntCode(int*); + static int* intCodeToHoleCards(int); - int holeCardsClass(int, int) const; - int cardsValue(int*, int*) const; - - int holeCardsToIntCode(int*) const; - int* intCodeToHoleCards(int) const; - - std::vector< std::vector > calcCardsChance(GameState, int*, int*) const; - //int** showdown(GameState, int**, int); + static std::vector< std::vector > calcCardsChance(GameState, int*, int*); + //static int** showdown(GameState, int**, int); }; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 2f1b3007..c99eb9cc 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -847,7 +847,7 @@ static const RoundData FlopValues[] = { #define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData)) LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) - : PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0), myWinnerState(false), m_actionTimeoutCounter(0) + : PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0), myWinnerState(false), m_actionTimeoutCounter(0) { // !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!! @@ -934,10 +934,10 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty // cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl; // Dude4 zuweisen - int interval = 7; - int count = 4; + const int interval = 7; + const int count = 4; - int *tempArray = new int[count]; + int tempArray[count]; Tools::getRandNumber(0, 2*interval, count, tempArray, 0); for(i=0; iholeCardsToIntCode(myCards); + handCode = CardsValue::holeCardsToIntCode(myCards); // übergang solange preflopValue und flopValue noch nicht bereinigt int players = currentHand->getActivePlayerList()->size(); @@ -4117,8 +4110,8 @@ void LocalPlayer::calcMyOdds() tempOpponentCardsArray[1] = j; tempOpponentCardsArray[6] = k; tempMyCardsArray[6] = k; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; } @@ -4171,8 +4164,8 @@ void LocalPlayer::calcMyOdds() tempOpponentCardsArray[0] = i; tempOpponentCardsArray[1] = j; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; } @@ -4467,7 +4460,7 @@ void LocalPlayer::preflopEngine3() // cout << "preflop-bluff " << bluff << endl; // Potential - int potential = 10*(4*(myCardsValue->holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude; + int potential = 10*(4*(CardsValue::holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude; int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; @@ -4477,7 +4470,7 @@ void LocalPlayer::preflopEngine3() Tools::getRandNumber(2,3,1,&tempFold,0); // FOLD --> wenn Potential negativ oder HighestSet zu hoch - if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) { + if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && CardsValue::holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) { myAction=1; } else { // RAISE --> wenn hohes Potential @@ -4666,8 +4659,8 @@ void LocalPlayer::flopEngine3() tempOpponentCardsArray[6] = l; tempMyCardsArray[5] = k; tempMyCardsArray[6] = l; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; @@ -4835,8 +4828,8 @@ void LocalPlayer::turnEngine3() tempOpponentCardsArray[1] = j; tempOpponentCardsArray[6] = k; tempMyCardsArray[6] = k; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; } @@ -4999,8 +4992,8 @@ void LocalPlayer::riverEngine3() tempOpponentCardsArray[0] = i; tempOpponentCardsArray[1] = j; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempMyCardsValue = CardsValue::cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = CardsValue::cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; } diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index 8aa9835f..49dbcc82 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -26,7 +26,6 @@ #include -class CardsValue; class ConfigFile; class HandInterface; @@ -286,8 +285,6 @@ private: ConfigFile *myConfig; HandInterface *currentHand; - CardsValue *myCardsValue; - // Konstanten int myID; unsigned myUniqueID; diff --git a/src/engine/network_engine/clientplayer.cpp b/src/engine/network_engine/clientplayer.cpp index b67d9249..4cb5633d 100644 --- a/src/engine/network_engine/clientplayer.cpp +++ b/src/engine/network_engine/clientplayer.cpp @@ -23,7 +23,7 @@ using namespace std; ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) - : PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), + : PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false) diff --git a/src/engine/network_engine/clientplayer.h b/src/engine/network_engine/clientplayer.h index 9dd48fe5..8c9c3372 100644 --- a/src/engine/network_engine/clientplayer.h +++ b/src/engine/network_engine/clientplayer.h @@ -25,7 +25,6 @@ #include #include -class CardsValue; class ConfigFile; class HandInterface; @@ -149,8 +148,6 @@ private: ConfigFile *myConfig; HandInterface *currentHand; - CardsValue *myCardsValue; - // Konstanten const int myID; const unsigned myUniqueID; diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index cf143a79..4f42f59c 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -3536,8 +3536,6 @@ void gameTableImpl::refreshVotesMonitor(int currentVotes, int numVotesNeededToKi void gameTableImpl::refreshCardsChance(GameState bero) { - CardsValue myCardsValue; - if(myConfig->readConfigInt("ShowCardsChanceMonitor")) { boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); @@ -3548,7 +3546,7 @@ void gameTableImpl::refreshCardsChance(GameState bero) humanPlayer->getMyCards(holeCards); myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards); - label_chance->refreshChance(myCardsValue.calcCardsChance(bero, holeCards, boardCards)); + label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards)); } else { label_chance->resetChance(); }