diff --git a/src/engine/local_engine/cardsvalue.cpp b/src/engine/local_engine/cardsvalue.cpp index 9b35dd41..b748d509 100755 --- a/src/engine/local_engine/cardsvalue.cpp +++ b/src/engine/local_engine/cardsvalue.cpp @@ -71,7 +71,7 @@ int CardsValue::holeCardsClass(int one, int two) { } } } break; - //König + //K�ig case 13: { if((one-1)/13 == (two-1)/13) { switch((one-1)%13-(two-1)%13) { @@ -164,15 +164,16 @@ int CardsValue::holeCardsClass(int one, int two) { } -int CardsValue::cardsValue(int *cards) { +int CardsValue::cardsValue(int* cards, int* position) { -int array[7][2]; - int j1, j2, j3, j4, j5, k1, k2, ktemp[2]; +int array[7][3]; + int j1, j2, j3, j4, j5, k1, k2, ktemp[3]; - // Kartenwerte umwandeln (z.B. [ 11 (Karo König) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) + // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) for(j1=0; j1<7; j1++) { array[j1][0] = cards[j1]/13; array[j1][1] = cards[j1]%13; + array[j1][2] = j1; } // Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo @@ -181,49 +182,76 @@ int array[7][2]; if(array[k1][0] 8*100000000+3*1000000 + // Straight Flush mit 5 als h�ste Karte -> 8*100000000+3*1000000 + if(position) { + // Position-Array fuellen + position[0] = array[j1][2]; + for(j3=1; j3<5; j3++) { + position[j3] = array[j2+j3][2]; + } + } return 800000000+3*1000000; } } @@ -234,23 +262,32 @@ int array[7][2]; // auf Flush (Klasse 5) testen for(j1=0; j1<3; j1++) { if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) { - // Flush -> 5*10000000 + höhste Flush Karten mit absteigender Wertung + // Flush -> 5*10000000 + h�ste Flush Karten mit absteigender Wertung + if(position) { + // Position-Array fuellen + for(j2=0; j2<5; j2++) { + position[j2] = array[j1+j2][2]; + } + } return 500000000+array[j1][1]*1000000+array[j1+1][1]*10000+array[j1+2][1]*100+array[j1+3][1]*10+array[j1+4][1]; } } - // Karten für den Vierling-, Full-House-, Drilling- und Paartest umsortieren + // Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren for(k1=0; k1<7; k1++) { for(k2=k1+1; k2<7; k2++) { if(array[k1][1]setMyCards(tempPlayerArray); - playerArray[i]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray)); + playerArray[i]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,playerArray[i]->getMyBestHandPosition())); + // myBestHandPosition auf Fehler ueberpruefen + for(j=0; j<5; j++) { + if((playerArray[i]->getMyBestHandPosition())[i] == -1) { + cout << "FEHLER bei myBestHandPosition-Ermittlung!!!" << endl; + } + } } // Karten austeilen diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index c88950d7..63721a02 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -25,6 +25,12 @@ using namespace std; LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, int sC, bool aS, int mB) : PlayerInterface(), actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myName(name), myDude(0), myCardsValueInt(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), myAverageSets(0) { + // myBestHandPosition mit -1 initialisieren + int i; + for(i=0; i<5; i++) { + myBestHandPosition[i] = -1; + } + Tools myTool; // Dude zuweisen @@ -314,8 +320,8 @@ void LocalPlayer::flopEngine() { tempOpponentCardsArray[6] = l; tempMyCardsArray[5] = k; tempMyCardsArray[6] = l; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray); + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; @@ -484,8 +490,8 @@ void LocalPlayer::turnEngine() { tempOpponentCardsArray[1] = j; tempOpponentCardsArray[6] = k; tempMyCardsArray[6] = k; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray); + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; } @@ -650,8 +656,8 @@ void LocalPlayer::riverEngine() { tempOpponentCardsArray[0] = i; tempOpponentCardsArray[1] = j; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray); + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; } diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index 3a683033..faa49ffb 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -74,6 +74,8 @@ public: void setMyCardsValueInt(const int& theValue) { myCardsValueInt = theValue;} int getMyCardsValueInt() const { return myCardsValueInt; } + int* getMyBestHandPosition() { return myBestHandPosition; } + void setMyRoundStartCash(const int& theValue) { myRoundStartCash = theValue;} int getMyRoundStartCash() const { return myRoundStartCash; } @@ -87,6 +89,7 @@ public: void turnEngine(); void riverEngine(); + @@ -106,6 +109,7 @@ private: // Laufvariablen int myCards[2]; int myCardsValueInt; + int myBestHandPosition[5]; int myCash; int mySet; int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin diff --git a/src/engine/playerinterface.h b/src/engine/playerinterface.h index 42abadd2..25ddaaa6 100644 --- a/src/engine/playerinterface.h +++ b/src/engine/playerinterface.h @@ -63,6 +63,8 @@ public: virtual void setMyCardsValueInt(const int& theValue) =0; virtual int getMyCardsValueInt() const =0; + virtual int* getMyBestHandPosition() =0; + virtual void setMyRoundStartCash(const int& theValue) =0; virtual int getMyRoundStartCash() const =0;