Player action timeout - display is working, function still missing.

This commit is contained in:
lotodore
2007-06-07 23:24:22 +00:00
parent fb274284f5
commit 9a29830532
12 changed files with 65 additions and 36 deletions
+6 -2
View File
@@ -55,7 +55,7 @@ Server Reply: Join Game ACK
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message Type = 2 | Message Length = 12 |
| Message Type = 2 | Message Length = 28 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Your Session ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -63,7 +63,9 @@ Server Reply: Join Game ACK
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Number of Players | Small Blind |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hands before raise | Proposed GUI Speed |
| Hands before raise | Proposed GUI Speed |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Player Action Timeout | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Start Money |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -74,6 +76,8 @@ Player ID:
Unique Player ID
Proposed GUI Speed:
1-11
Player Action Timeout:
# seconds
Server Notification: Player Joined
+2 -1
View File
@@ -26,12 +26,13 @@
struct GameData
{
GameData() : numberOfPlayers(0), startMoney(0), smallBlind(0),
handsBeforeRaise(1), guiSpeed(4) {}
handsBeforeRaise(1), guiSpeed(4), playerActionTimeoutSec(20) {}
int numberOfPlayers;
int startMoney;
int smallBlind;
int handsBeforeRaise;
int guiSpeed;
int playerActionTimeoutSec;
};
struct StartData
+2
View File
@@ -89,6 +89,8 @@ void ServerGuiWrapper::flipHolecardsAllIn() {}
void ServerGuiWrapper::nextRoundCleanGui() {}
void ServerGuiWrapper::meInAction() {}
void ServerGuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) {}
void ServerGuiWrapper::stopTimeoutAnimation(int playerId) {}
void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {}
void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {}
+2
View File
@@ -73,6 +73,8 @@ public:
void nextRoundCleanGui();
void meInAction();
void startTimeoutAnimation(int playerId, int timeoutSec);
void stopTimeoutAnimation(int playerId);
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
+2 -1
View File
@@ -82,7 +82,8 @@ public:
// virtual void userWidgetsBackgroudColor() const=0;
// virtual void timerBlockerFalse() const=0;
virtual void meInAction()=0;
virtual void startTimeoutAnimation(int playerId, int timeoutSec) =0;
virtual void stopTimeoutAnimation(int playerId) =0;
//log.cpp
virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0;
+2
View File
@@ -87,6 +87,8 @@ void GuiWrapper::flipHolecardsAllIn() { myW->signalFlipHolecardsAllIn(); }
void GuiWrapper::nextRoundCleanGui() { myW->signalNextRoundCleanGui(); }
void GuiWrapper::meInAction() { myW->signalMeInAction(); }
void GuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) { myW->signalStartTimeoutAnimation(playerId, timeoutSec); }
void GuiWrapper::stopTimeoutAnimation(int playerId) { myW->signalStopTimeoutAnimation(playerId); }
void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), action, setValue); }
void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->signalLogNewGameHandMsg(gameID, handID); }
+2
View File
@@ -80,6 +80,8 @@ public:
void nextRoundCleanGui();
void meInAction();
void startTimeoutAnimation(int playerId, int timeoutSec);
void stopTimeoutAnimation(int playerId);
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
+13 -11
View File
@@ -585,6 +585,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int)));
connect(this, SIGNAL(signalMeInAction()), this, SLOT(meInAction()));
connect(this, SIGNAL(signalStartTimeoutAnimation(int, int)), this, SLOT(startTimeoutAnimation(int, int)));
connect(this, SIGNAL(signalStopTimeoutAnimation(int)), this, SLOT(stopTimeoutAnimation(int)));
connect(this, SIGNAL(signalDealHoleCards()), this, SLOT(dealHoleCards()));
connect(this, SIGNAL(signalDealFlopCards0()), this, SLOT(dealFlopCards0()));
@@ -719,6 +721,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
//temporarely static until ai is enabled in network
// gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value();
gameData.guiSpeed = 4;
gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value();
myStartNetworkGameDialog->setSession(&myServerGuiInterface->getSession());
myStartNetworkGameDialog->treeWidget->clear();
@@ -1500,6 +1503,16 @@ void mainWindowImpl::meInAction() {
}
}
void mainWindowImpl::startTimeoutAnimation(int playerId, int timeoutSec) {
assert(playerId >= 0 && playerId < mySession->getCurrentGame()->getStartQuantityPlayers());
setLabelArray[playerId]->startTimeOutAnimation(timeoutSec);
}
void mainWindowImpl::stopTimeoutAnimation(int playerId) {
assert(playerId >= 0 && playerId < mySession->getCurrentGame()->getStartQuantityPlayers());
setLabelArray[playerId]->stopTimeOutAnimation();
}
void mainWindowImpl::disableMyButtons() {
//clear userWidgets
@@ -1758,15 +1771,6 @@ void mainWindowImpl::myAllIn(){
myActionDone();
}
void mainWindowImpl::userActionTimeOutReached() {
//TODO
// automatic check, fold
cout << "timeoutaction" << endl;
}
void mainWindowImpl::myActionDone() {
// If a network client is running, we need
@@ -2514,8 +2518,6 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
if (event->key() == Qt::Key_F3) { pushButton_BetRaise->click(); }
if (event->key() == Qt::Key_F10) { switchLeftToolBox(); }
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
if (event->key() == Qt::Key_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //f
if (event->key() == Qt::Key_E) { setLabelArray[0]->stopTimeOutAnimation(); } //f
// if (event->key() == Qt::Key_W) { qApp->quit(); } //s
if (event->key() == 16777249) {
pushButton_break->click();
+5 -2
View File
@@ -86,6 +86,8 @@ signals:
void signalRefreshGameLabels(int);
void signalMeInAction();
void signalStartTimeoutAnimation(int playerId, int timeoutSec);
void signalStopTimeoutAnimation(int playerId);
void signalDealHoleCards();
void signalDealFlopCards0();
@@ -152,6 +154,9 @@ public slots:
void callCreateNetworkGameDialog();
void callJoinNetworkGameDialog();
void startTimeoutAnimation(int playerId, int timoutSec);
void stopTimeoutAnimation(int playerId);
void myBetRaise();
void myFoldAllin();
void myCallCheckSet();
@@ -251,8 +256,6 @@ public slots:
void localGameModification();
void networkGameModification();
void userActionTimeOutReached();
void quitPokerTH();
private:
+3 -3
View File
@@ -57,9 +57,9 @@ void MySetLabel::nextTimeOutAnimationFrame() {
update();
}
else {
stopTimeOutAnimation();
//callback
myW->userActionTimeOutReached();
stopTimeOutAnimation();
// no callback is called here.
// the server initiates any action required.
}
}
+6
View File
@@ -630,6 +630,9 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
if (tmpPlayer->getMySet() > GetHighestSet(*curGame))
SetHighestSet(*curGame, tmpPlayer->getMySet());
// Stop the timeout for the player.
client.GetGui().stopTimeoutAnimation(tmpPlayer->getMyID());
// Unmark last player in GUI.
client.GetGui().refreshGroupbox(tmpPlayer->getMyID(), 3);
@@ -668,6 +671,9 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
guiStatus = 1;
client.GetGui().refreshGroupbox(tmpPlayer->getMyID(), guiStatus);
// Start displaying the timeout for the player.
client.GetGui().startTimeoutAnimation(tmpPlayer->getMyID(), client.GetGameData().playerActionTimeoutSec);
if (tmpPlayer->getMyID() == 0) // Is this the GUI player?
client.GetGui().meInAction();
}
+20 -16
View File
@@ -97,6 +97,8 @@ struct GCC_PACKED NetPacketJoinGameAckData
u_int16_t smallBlind;
u_int16_t handsBeforeRaise;
u_int16_t proposedGuiSpeed;
u_int16_t playerActionTimeout;
u_int16_t reserved;
u_int32_t startMoney;
};
@@ -716,14 +718,15 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData)
NetPacketJoinGameAckData *tmpData = (NetPacketJoinGameAckData *)GetRawData();
assert(tmpData);
tmpData->sessionId = htonl(inData.sessionId);
tmpData->playerId = htons(inData.yourPlayerUniqueId);
tmpData->playerNumber = htons(inData.yourPlayerNum);
tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers);
tmpData->smallBlind = htons(inData.gameData.smallBlind);
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
tmpData->startMoney = htonl(inData.gameData.startMoney);
tmpData->sessionId = htonl(inData.sessionId);
tmpData->playerId = htons(inData.yourPlayerUniqueId);
tmpData->playerNumber = htons(inData.yourPlayerNum);
tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers);
tmpData->smallBlind = htons(inData.gameData.smallBlind);
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
tmpData->playerActionTimeout = htons(inData.gameData.playerActionTimeoutSec);
tmpData->startMoney = htonl(inData.gameData.startMoney);
}
void
@@ -732,14 +735,15 @@ NetPacketJoinGameAck::GetData(NetPacketJoinGameAck::Data &outData) const
NetPacketJoinGameAckData *tmpData = (NetPacketJoinGameAckData *)GetRawData();
assert(tmpData);
outData.sessionId = ntohl(tmpData->sessionId);
outData.yourPlayerUniqueId = ntohs(tmpData->playerId);
outData.yourPlayerNum = ntohs(tmpData->playerNumber);
outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
outData.gameData.startMoney = ntohl(tmpData->startMoney);
outData.sessionId = ntohl(tmpData->sessionId);
outData.yourPlayerUniqueId = ntohs(tmpData->playerId);
outData.yourPlayerNum = ntohs(tmpData->playerNumber);
outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
outData.gameData.playerActionTimeoutSec = ntohs(tmpData->playerActionTimeout);
outData.gameData.startMoney = ntohl(tmpData->startMoney);
}
const NetPacketJoinGameAck *