refactoring Bugfix

This commit is contained in:
doitux
2007-08-11 14:36:20 +00:00
parent b18152c0b8
commit 851cce3e45
12 changed files with 182 additions and 104 deletions
+3
View File
@@ -34,6 +34,9 @@ public:
virtual void setHighestCardsValue(int theValue) =0;
virtual int getHighestCardsValue() const =0;
virtual void setLastActionPlayer( int theValue ) =0;
virtual int getLastActionPlayer() const =0;
virtual void resetFirstRun() =0;
virtual void nextPlayer() =0;
+5
View File
@@ -57,6 +57,9 @@ protected:
void setSmallBlind(int theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setLastActionPlayer ( int theValue ) { lastActionPlayer = theValue; }
int getLastActionPlayer() const { return lastActionPlayer; }
private:
@@ -79,6 +82,8 @@ private:
bool logBoardCardsDone;
int lastActionPlayer;
};
@@ -25,7 +25,7 @@
using namespace std;
LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_POST_RIVER)
LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_POST_RIVER), highestCardsValue(0)
{
}
+1 -1
View File
@@ -36,7 +36,7 @@ public:
void run();
void distributePot();
private:
int highestCardsValue;
+70 -64
View File
@@ -100,72 +100,78 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
// // int temp5Array[5];
// //
// // tempBoardArray[0] = 8;
// // tempBoardArray[1] = 9;
// // tempBoardArray[2] = 10;
// // tempBoardArray[3] = 11;
// // tempBoardArray[4] = 13;
// //
// // myBoard->setMyCards(tempBoardArray);
// //
// // tempPlayerAndBoardArray[2] = tempBoardArray[0];
// // tempPlayerAndBoardArray[3] = tempBoardArray[1];
// // tempPlayerAndBoardArray[4] = tempBoardArray[2];
// // tempPlayerAndBoardArray[5] = tempBoardArray[3];
// // tempPlayerAndBoardArray[6] = tempBoardArray[4];
// //
// // tempPlayerArray[0] = 13;
// // tempPlayerArray[1] = 25;
// // tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// // tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// //
// // playerArray[0]->setMyCards(tempPlayerArray);
// // playerArray[0]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
// //
// // playerArray[0]->setMyBestHandPosition(temp5Array);
// //
// // // for(i=0; i<5; i++) {
// // // cout << temp5Array[i] << " ";
// // // }
// // // cout << endl;
// //
// // tempPlayerArray[0] = 31;
// // tempPlayerArray[1] = 18;
// // tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// // tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// //
// // playerArray[1]->setMyCards(tempPlayerArray);
// // playerArray[1]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
// //
// // playerArray[1]->setMyBestHandPosition(temp5Array);
// //
// // tempPlayerArray[0] = 20;
// // tempPlayerArray[1] = 38;
// // tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// // tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// //
// // playerArray[2]->setMyCards(tempPlayerArray);
// // playerArray[2]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
// //
// // playerArray[2]->setMyBestHandPosition(temp5Array);
// //
// // tempPlayerArray[0] = 19;
// // tempPlayerArray[1] = 51;
// // tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// // tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// //
// // playerArray[3]->setMyCards(tempPlayerArray);
// // playerArray[3]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
// //
// // playerArray[3]->setMyBestHandPosition(temp5Array);
// //
// // // for(i=0; i<4; i++) {
// // // cout << i << ": " << playerArray[i]->getMyCardsValueInt() << endl;
// // // }
if(DEBUG_MODE) {
int temp5Array[5];
tempBoardArray[0] = 28;
tempBoardArray[1] = 45;
tempBoardArray[2] = 33;
tempBoardArray[3] = 4;
tempBoardArray[4] = 49;
myBoard->setMyCards(tempBoardArray);
tempPlayerAndBoardArray[2] = tempBoardArray[0];
tempPlayerAndBoardArray[3] = tempBoardArray[1];
tempPlayerAndBoardArray[4] = tempBoardArray[2];
tempPlayerAndBoardArray[5] = tempBoardArray[3];
tempPlayerAndBoardArray[6] = tempBoardArray[4];
tempPlayerArray[0] = 47;
tempPlayerArray[1] = 12;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
playerArray[0]->setMyCards(tempPlayerArray);
playerArray[0]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
playerArray[0]->setMyBestHandPosition(temp5Array);
// for(i=0; i<5; i++) {
// cout << temp5Array[i] << " ";
// }
// cout << endl;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 18;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
playerArray[1]->setMyCards(tempPlayerArray);
playerArray[1]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
playerArray[1]->setMyBestHandPosition(temp5Array);
tempPlayerArray[0] = 24;
tempPlayerArray[1] = 48;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
playerArray[2]->setMyCards(tempPlayerArray);
playerArray[2]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
playerArray[2]->setMyBestHandPosition(temp5Array);
tempPlayerArray[0] = 19;
tempPlayerArray[1] = 51;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
playerArray[3]->setMyCards(tempPlayerArray);
playerArray[3]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
playerArray[3]->setMyBestHandPosition(temp5Array);
// for(i=0; i<4; i++) {
// cout << i << ": " << playerArray[i]->getMyCardsValueInt() << endl;
// }
dealerPosition = 0;
}
// ----------------------------------------
// Dealer, SB, BB bestimmen
+41 -12
View File
@@ -31,18 +31,25 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
: PlayerInterface(), myConfig(c), actualHand(0), actualBoard(b), 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), myTurn(0), myRoundStartCash(0), sBluff(0), sBluffStatus(0)
{
// for statistic development
// if(myID==0) {
// myActiveStatus=0;
// myCash=20;
// }
//
// if(myID==1) {
// myCash=6130;
// }
// if(myID==2) {
// myCash=37;
// }
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
if(DEBUG_MODE) {
if(myID==0) {
// myActiveStatus=0;
myCash=570;
}
if(myID==1) {
myCash=2730;
}
if(myID==2) {
myCash=5970;
}
if(myID==3) {
myCash=2730;
}
}
////////////////////////////
// myBestHandPosition mit -1 initialisieren
@@ -332,6 +339,23 @@ void LocalPlayer::preflopEngine() {
// cout << myID << ": " << myOdds << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << "Bluff: " << sBluffStatus << endl;
if(DEBUG_MODE) {
switch(myID) {
case 0: {}
break;
case 1: { myAction = PLAYER_ACTION_FOLD; }
break;
case 2: { myAction = PLAYER_ACTION_CALL; }
break;
case 3: { myAction = PLAYER_ACTION_FOLD; }
break;
default: {}
}
}
evaluation(bet, raise);
}
@@ -1215,6 +1239,10 @@ void LocalPlayer::riverEngine() {
}
}
}
// lastPlayerAction für Karten umblättern reihenfolge setzrn
actualHand->getCurrentBeRo()->setLastActionPlayer(myID);
}
// auf sBluffStatus testen --> raise statt call und bet statt check
@@ -1292,6 +1320,7 @@ void LocalPlayer::evaluation(int bet, int raise) {
highestSet = actualHand->getCurrentBeRo()->getHighestSet();
// cout << "myAction(evaluation): " << myAction << endl;
switch(myAction) {
// none
+12
View File
@@ -41,6 +41,18 @@ ClientBeRo::setHighestCardsValue(int theValue)
highestCardsValue = theValue;
}
void
ClientBeRo::setLastActionPlayer ( int theValue )
{
lastActionPlayer = theValue;
}
int
ClientBeRo::getLastActionPlayer() const
{
return lastActionPlayer;
}
void
ClientBeRo::setPlayersTurn(int theValue)
{
+5
View File
@@ -30,6 +30,9 @@ public:
int getHighestCardsValue() const;
void setHighestCardsValue(int theValue);
void setLastActionPlayer ( int theValue );
int getLastActionPlayer() const;
void setPlayersTurn(int theValue);
int getPlayersTurn() const;
@@ -64,6 +67,8 @@ private:
bool firstRound;
int smallBlindPosition;
int smallBlind;
int lastActionPlayer;
};
#endif
-8
View File
@@ -106,20 +106,12 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
Game::~Game()
{
// cout << "Delete Game Object" << "\n";
int i;
delete actualBoard;
actualBoard = 0;
delete actualHand;
actualHand = 0;
// boost::shared_ptr<PlayerInterface> tempPlayer;
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
// tempPlayer = playerArray[i];
// playerArray[i] = 0;
// delete tempPlayer;
// }
}
HandInterface * Game::getCurrentHand()
+2
View File
@@ -26,6 +26,8 @@
#define MIN_GUI_SPEED 1
#define MAX_GUI_SPEED 11
#define DEBUG_MODE 0
enum GameState {
GAME_STATE_PREFLOP = 0,
GAME_STATE_FLOP,
+37 -17
View File
@@ -56,7 +56,7 @@
using namespace std;
mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
: QMainWindow(parent), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), debugMode(0), breakAfterActualHand(FALSE)
: QMainWindow(parent), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), breakAfterActualHand(FALSE)
{
int i;
@@ -265,6 +265,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
postRiverAnimation1Timer = new QTimer(this);
postRiverRunAnimation1Timer = new QTimer(this);
postRiverRunAnimation2Timer = new QTimer(this);
postRiverRunAnimation2_flipHoleCards1Timer = new QTimer(this);
postRiverRunAnimation2_flipHoleCards2Timer = new QTimer(this);
postRiverRunAnimation3Timer = new QTimer(this);
postRiverRunAnimation5Timer = new QTimer(this);
potDistributeTimer = new QTimer(this);
@@ -299,6 +301,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
postRiverAnimation1Timer->setSingleShot(TRUE);
postRiverRunAnimation1Timer->setSingleShot(TRUE);
postRiverRunAnimation2Timer->setSingleShot(TRUE);
postRiverRunAnimation2_flipHoleCards1Timer->setSingleShot(TRUE);
postRiverRunAnimation2_flipHoleCards2Timer->setSingleShot(TRUE);
postRiverRunAnimation3Timer->setSingleShot(TRUE);
postRiverRunAnimation5Timer->setSingleShot(TRUE);
postRiverRunAnimation6Timer->setSingleShot(TRUE);
@@ -555,6 +559,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
connect(postRiverAnimation1Timer, SIGNAL(timeout()), this, SLOT( postRiverAnimation1Action() ));
connect(postRiverRunAnimation1Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation2() ));
connect(postRiverRunAnimation2Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation3() ));
connect(postRiverRunAnimation2_flipHoleCards1Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation2_flipHoleCards1() ));
connect(postRiverRunAnimation2_flipHoleCards2Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation2_flipHoleCards2() ));
connect(postRiverRunAnimation3Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation4() ));
connect(potDistributeTimer, SIGNAL(timeout()), this, SLOT(postRiverRunAnimation5()));
connect(postRiverRunAnimation5Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation6() ));
@@ -1299,7 +1305,7 @@ void mainWindowImpl::dealHoleCards() {
currentGame->getPlayerArray()[i]->getMyCards(tempCardsIntArray);
for(j=0; j<2; j++) {
if(currentGame->getPlayerArray()[i]->getMyActiveStatus()) {
if ((i == 0) || debugMode) {
if ((i == 0) || DEBUG_MODE) {
tempCardsPixmapArray[j].load(":/cards/resources/graphics/cards/"+QString::number(tempCardsIntArray[j], 10)+".png");
holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j],FALSE);
@@ -1838,20 +1844,7 @@ void mainWindowImpl::riverAnimation2Action() { mySession->getCurrentGame()->getC
void mainWindowImpl::postRiverAnimation1() { postRiverAnimation1Timer->start(nextPlayerSpeed2); }
void mainWindowImpl::postRiverAnimation1Action() { mySession->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); }
void mainWindowImpl::postRiverRunAnimation1() {
//RoundsLabel mit "River" dunkel machen
// QPalette tempPalette = frame_handLabel->palette();
// tempPalette.setColor(QPalette::Window, active);
// frame_handLabel->setPalette(tempPalette);
//PotLabel aufhellen!
// // tempPalette = frame_Pot->palette();
// tempPalette.setColor(QPalette::Window, highlight);
// frame_Pot->setPalette(tempPalette);
postRiverRunAnimation1Timer->start(postRiverRunAnimationSpeed);
}
void mainWindowImpl::postRiverRunAnimation1() { postRiverRunAnimation1Timer->start(postRiverRunAnimationSpeed); }
void mainWindowImpl::postRiverRunAnimation2() {
@@ -1868,7 +1861,11 @@ void mainWindowImpl::postRiverRunAnimation2() {
if(!flipHolecardsAllInAlreadyDone) {
//Config? mit oder ohne Eye-Candy?
//TODO - Turn cards like in the rules
// postRiverRunAnimation2_flipHoleCards1Timer->start(nextPlayerSpeed2);
// //Config? mit oder ohne Eye-Candy?
if(myConfig->readConfigInt("ShowFlipCardsAnimation")) {
// mit Eye-Candy
@@ -1937,12 +1934,35 @@ void mainWindowImpl::postRiverRunAnimation2() {
else { postRiverRunAnimation3(); }
}
// TODO
void mainWindowImpl::postRiverRunAnimation2_flipHoleCards1() {
HandInterface *currentHand = mySession->getCurrentGame()->getCurrentHand();
currentHand->getCurrentBeRo()->setPlayersTurn(currentHand->getCurrentBeRo()->getLastActionPlayer());
postRiverRunAnimation2_flipHoleCards2Timer->start(nextPlayerSpeed2);
}
void mainWindowImpl::postRiverRunAnimation2_flipHoleCards2() {
// if() {
// postRiverRunAnimation2_flipHoleCards1Timer->start(nextPlayerSpeed2);
// }
// else {
// postRiverRunAnimation2Timer->start(postRiverRunAnimationSpeed);
// }
}
void mainWindowImpl::postRiverRunAnimation3() {
int i;
HandInterface *currentHand = mySession->getCurrentGame()->getCurrentHand();
//Alle Winner erhellen und "Winner" schreiben
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(currentHand->getPlayerArray()[i]->getMyActiveStatus() && currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) {
// QPalette tempPalette = groupBoxArray[i]->palette();
+5 -1
View File
@@ -230,6 +230,8 @@ public slots:
void postRiverRunAnimation1();
void postRiverRunAnimation2();
void postRiverRunAnimation2_flipHoleCards1();
void postRiverRunAnimation2_flipHoleCards2();
void postRiverRunAnimation3();
void postRiverRunAnimation4();
void postRiverRunAnimation5();
@@ -274,6 +276,7 @@ public slots:
void networkGameModification();
void quitPokerTH();
@@ -339,6 +342,8 @@ private:
QTimer *postRiverAnimation1Timer;
QTimer *postRiverRunAnimation1Timer;
QTimer *postRiverRunAnimation2Timer;
QTimer *postRiverRunAnimation2_flipHoleCards1Timer;
QTimer *postRiverRunAnimation2_flipHoleCards2Timer;
QTimer *postRiverRunAnimation3Timer;
QTimer *postRiverRunAnimation5Timer;
QTimer *postRiverRunAnimation6Timer;
@@ -396,7 +401,6 @@ private:
bool myActionIsBet;
bool myActionIsRaise;
bool debugMode;
bool breakAfterActualHand;
bool flipHolecardsAllInAlreadyDone;