Resetting cards value on client side each hand. Added GUI synchronization function. Fixed update of pot when all but one fold. Reset sets on end of hand.
This commit is contained in:
@@ -42,14 +42,15 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
|
||||
}
|
||||
|
||||
|
||||
// roundStartCashArray fllen
|
||||
// roundStartCashArray fuellen
|
||||
// cardsvalue zuruecksetzen
|
||||
// remove all buttons
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
|
||||
playerArray[i]->setMyCardsValueInt(0);
|
||||
playerArray[i]->setMyButton(0);
|
||||
}
|
||||
|
||||
// remove all buttons
|
||||
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { playerArray[i]->setMyButton(0); }
|
||||
|
||||
// assign dealer button
|
||||
playerArray[dealerPosition]->setMyButton(1);
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ void ServerGuiWrapper::refreshPlayerName() const {}
|
||||
void ServerGuiWrapper::refreshButton() const {}
|
||||
void ServerGuiWrapper::refreshGameLabels(GameState state) const {}
|
||||
|
||||
void ServerGuiWrapper::waitForGuiUpdateDone() const {}
|
||||
|
||||
void ServerGuiWrapper::dealHoleCards() {}
|
||||
void ServerGuiWrapper::dealFlopCards() {}
|
||||
void ServerGuiWrapper::dealTurnCard() {}
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
void refreshButton() const;
|
||||
void refreshGameLabels(GameState state) const;
|
||||
|
||||
void waitForGuiUpdateDone() const;
|
||||
|
||||
void dealHoleCards();
|
||||
void dealFlopCards();
|
||||
void dealTurnCard();
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
virtual void refreshButton() const =0;
|
||||
virtual void refreshGameLabels(GameState state) const=0;
|
||||
|
||||
virtual void waitForGuiUpdateDone() const=0;
|
||||
|
||||
// // Karten-Funktionen
|
||||
virtual void dealHoleCards()=0;
|
||||
virtual void dealFlopCards()=0;
|
||||
|
||||
@@ -60,6 +60,12 @@ void GuiWrapper::refreshPlayerName() const { myW->signalRefreshPlayerName(); }
|
||||
void GuiWrapper::refreshButton() const { myW->signalRefreshButton(); }
|
||||
void GuiWrapper::refreshGameLabels(GameState state) const { myW->signalRefreshGameLabels(state); }
|
||||
|
||||
void GuiWrapper::waitForGuiUpdateDone() const
|
||||
{
|
||||
myW->signalGuiUpdateDone();
|
||||
myW->waitForGuiUpdateDone();
|
||||
}
|
||||
|
||||
void GuiWrapper::dealHoleCards() { myW->signalDealHoleCards(); }
|
||||
void GuiWrapper::dealFlopCards() { myW->signalDealFlopCards0(); }
|
||||
void GuiWrapper::dealTurnCard() { myW->signalDealTurnCards0(); }
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
void refreshButton() const;
|
||||
void refreshGameLabels(GameState state) const;
|
||||
|
||||
void waitForGuiUpdateDone() const;
|
||||
|
||||
void dealHoleCards();
|
||||
void dealFlopCards();
|
||||
void dealTurnCard();
|
||||
|
||||
@@ -584,6 +584,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
connect(this, SIGNAL(signalRefreshButton()), this, SLOT(refreshButton()));
|
||||
connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int)));
|
||||
|
||||
connect(this, SIGNAL(signalGuiUpdateDone()), this, SLOT(guiUpdateDone()));
|
||||
|
||||
connect(this, SIGNAL(signalMeInAction()), this, SLOT(meInAction()));
|
||||
connect(this, SIGNAL(signalDisableMyButtons()), this, SLOT(disableMyButtons()));
|
||||
connect(this, SIGNAL(signalStartTimeoutAnimation(int, int)), this, SLOT(startTimeoutAnimation(int, int)));
|
||||
@@ -1251,6 +1253,14 @@ void mainWindowImpl::refreshPot() {
|
||||
textLabel_Pot->setText("<span style='font-weight:bold'>"+QString::number(currentHand->getBoard()->getPot(),10)+" $</span>");
|
||||
}
|
||||
|
||||
void mainWindowImpl::guiUpdateDone() {
|
||||
guiUpdateSemaphore.release();
|
||||
}
|
||||
|
||||
void mainWindowImpl::waitForGuiUpdateDone() {
|
||||
guiUpdateSemaphore.acquire();
|
||||
}
|
||||
|
||||
void mainWindowImpl::dealHoleCards() {
|
||||
|
||||
QPixmap onePix(":/graphics/resources/graphics/1px.png");
|
||||
|
||||
@@ -85,6 +85,8 @@ signals:
|
||||
void signalRefreshButton();
|
||||
void signalRefreshGameLabels(int);
|
||||
|
||||
void signalGuiUpdateDone();
|
||||
|
||||
void signalMeInAction();
|
||||
void signalDisableMyButtons();
|
||||
void signalStartTimeoutAnimation(int playerId, int timeoutSec);
|
||||
@@ -140,6 +142,9 @@ public slots:
|
||||
void refreshButton();
|
||||
void refreshPlayerAvatar();
|
||||
|
||||
void guiUpdateDone();
|
||||
void waitForGuiUpdateDone();
|
||||
|
||||
// Karten-Funktionen
|
||||
void dealHoleCards();
|
||||
|
||||
@@ -390,7 +395,7 @@ private:
|
||||
// statistic testing
|
||||
int statisticArray[15];
|
||||
|
||||
|
||||
QSemaphore guiUpdateSemaphore;
|
||||
|
||||
friend class GuiWrapper;
|
||||
};
|
||||
|
||||
@@ -757,6 +757,15 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
}
|
||||
else if (packet->ToNetPacketEndOfHandHideCards())
|
||||
{
|
||||
curGame->getCurrentHand()->getBoard()->collectPot();
|
||||
// Reset player sets
|
||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
||||
curGame->getPlayerArray()[i]->setMySetNull();
|
||||
client.GetGui().refreshPot();
|
||||
client.GetGui().refreshSet();
|
||||
// Synchronize with GUI.
|
||||
client.GetGui().waitForGuiUpdateDone();
|
||||
|
||||
// End of Hand, but keep cards hidden.
|
||||
NetPacketEndOfHandHideCards::Data endHandData;
|
||||
packet->ToNetPacketEndOfHandHideCards()->GetData(endHandData);
|
||||
@@ -768,17 +777,24 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
tmpPlayer->setMyCash(endHandData.playerMoney);
|
||||
// TODO use moneyWon
|
||||
curGame->getCurrentHand()->getBoard()->setPot(0);
|
||||
|
||||
client.GetGui().postRiverRunAnimation1();
|
||||
|
||||
// Reset player actions
|
||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
||||
curGame->getPlayerArray()[i]->setMySetNull();
|
||||
// Wait for next Hand.
|
||||
client.SetState(ClientStateWaitHand::Instance());
|
||||
retVal = MSG_NET_GAME_SERVER_HAND_END;
|
||||
}
|
||||
else if (packet->ToNetPacketEndOfHandShowCards())
|
||||
{
|
||||
curGame->getCurrentHand()->getBoard()->collectPot();
|
||||
// Reset player sets
|
||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
||||
curGame->getPlayerArray()[i]->setMySetNull();
|
||||
client.GetGui().refreshPot();
|
||||
client.GetGui().refreshSet();
|
||||
// Synchronize with GUI.
|
||||
client.GetGui().waitForGuiUpdateDone();
|
||||
|
||||
// End of Hand, show cards.
|
||||
NetPacketEndOfHandShowCards::Data endHandData;
|
||||
packet->ToNetPacketEndOfHandShowCards()->GetData(endHandData);
|
||||
@@ -810,17 +826,18 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
}
|
||||
curGame->getCurrentHand()->getRiver()->setHighestCardsValue(highestValueOfCards);
|
||||
curGame->getCurrentHand()->getBoard()->setPot(0);
|
||||
|
||||
client.GetGui().postRiverRunAnimation1();
|
||||
|
||||
// Reset player sets
|
||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
||||
curGame->getPlayerArray()[i]->setMySetNull();
|
||||
// Wait for next Hand.
|
||||
client.SetState(ClientStateWaitHand::Instance());
|
||||
retVal = MSG_NET_GAME_SERVER_HAND_END;
|
||||
}
|
||||
}
|
||||
|
||||
// Synchronize with GUI.
|
||||
client.GetGui().waitForGuiUpdateDone();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user