BeRo refactoring
This commit is contained in:
@@ -103,15 +103,20 @@ void LocalBeRo::run() {
|
||||
// not first round in heads up (for headsup dealer is smallblind so it is dealers turn)
|
||||
|
||||
// naechsten Spieler ermitteln
|
||||
do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
|
||||
int i;
|
||||
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6) || i==0; i++) {
|
||||
playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
}
|
||||
}
|
||||
else { firstHeadsUpRound = 0; }
|
||||
|
||||
//Spieler-Position vor SmallBlind-Position ermitteln
|
||||
int activePlayerBeforeSmallBlind = smallBlindPosition;
|
||||
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS);
|
||||
} while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6);
|
||||
|
||||
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6) || i==0; i++) {
|
||||
|
||||
activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS);
|
||||
}
|
||||
|
||||
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
||||
//highlight active players groupbox and clear action
|
||||
|
||||
@@ -31,7 +31,9 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int qP, int dP, in
|
||||
|
||||
// // BigBlind ermitteln
|
||||
bigBlindPosition = getDealerPosition();
|
||||
while (getMyHand()->getPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND) {
|
||||
|
||||
int i;
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS && getMyHand()->getPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) {
|
||||
bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
}
|
||||
|
||||
@@ -63,7 +65,8 @@ void LocalBeRoPreflop::run() {
|
||||
|
||||
// BigBlind ermitteln
|
||||
bigBlindPosition = getDealerPosition();
|
||||
while (getMyHand()->getPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND) {
|
||||
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS && getMyHand()->getPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) {
|
||||
bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
}
|
||||
|
||||
@@ -93,13 +96,13 @@ void LocalBeRoPreflop::run() {
|
||||
// Preflop ist wirklich dran
|
||||
|
||||
// naechsten Spieler ermitteln
|
||||
do {
|
||||
for(i=0; (MAX_NUMBER_OF_PLAYERS && (!(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyActiveStatus()) || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_FOLD || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_ALLIN)) || i==0; i++) {
|
||||
|
||||
setPlayersTurn((getPlayersTurn()+1)%(MAX_NUMBER_OF_PLAYERS));
|
||||
// falls BigBlind, dann PreflopFirstRound zuende
|
||||
if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND) setFirstRound(0);
|
||||
|
||||
} while(!(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyActiveStatus()) || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_FOLD || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_ALLIN);
|
||||
}
|
||||
|
||||
getMyHand()->getPlayerArray()[getPlayersTurn()]->setMyTurn(1);
|
||||
//highlight active players groupbox and clear action
|
||||
|
||||
@@ -190,7 +190,7 @@ void LocalHand::start() {
|
||||
|
||||
void LocalHand::assignButtons() {
|
||||
|
||||
int i;
|
||||
int i,j;
|
||||
|
||||
//Aktive Spieler zählen
|
||||
int activePlayersCounter = 0;
|
||||
@@ -206,26 +206,26 @@ void LocalHand::assignButtons() {
|
||||
|
||||
// assign Small Blind next to dealer. ATTENTION: in heads up it is big blind
|
||||
i = dealerPosition;
|
||||
do {
|
||||
|
||||
for(j=0; (j<MAX_NUMBER_OF_PLAYERS && !(playerArray[i]->getMyActiveStatus())) || j==0; j++) {
|
||||
|
||||
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
if(playerArray[i]->getMyActiveStatus()) {
|
||||
if(activePlayersCounter > 2) playerArray[i]->setMyButton(2); //small blind normal
|
||||
else playerArray[i]->setMyButton(3); //big blind in heads up
|
||||
|
||||
else playerArray[i]->setMyButton(3); //big blind in heads up
|
||||
}
|
||||
|
||||
} while(!(playerArray[i]->getMyActiveStatus()));
|
||||
}
|
||||
|
||||
// assign big blind next to small blind. ATTENTION: in heads up it is small blind
|
||||
do {
|
||||
for(j=0; (j<MAX_NUMBER_OF_PLAYERS && !(playerArray[i]->getMyActiveStatus())) || j==0; j++) {
|
||||
|
||||
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
if(playerArray[i]->getMyActiveStatus()) {
|
||||
if(activePlayersCounter > 2) playerArray[i]->setMyButton(3); //big blind normal
|
||||
else playerArray[i]->setMyButton(2); //small blind in heads up
|
||||
|
||||
}
|
||||
|
||||
} while(!(playerArray[i]->getMyActiveStatus()));
|
||||
}
|
||||
|
||||
//do sets
|
||||
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
|
||||
@@ -520,6 +520,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig);
|
||||
myAboutPokerthDialog = new aboutPokerthImpl(this);
|
||||
|
||||
myStartNetworkGameDialog->setMyW(this);
|
||||
|
||||
// //ShortCuts
|
||||
// QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this);
|
||||
// connect( quitPokerTHKeys, SIGNAL(activated() ), actionQuit, SLOT( trigger() ) );
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFile *config)
|
||||
: QDialog(parent), myConfig(config), isAdmin(false)
|
||||
: QDialog(parent), myConfig(config), isAdmin(false), myW(0)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -64,6 +64,8 @@ void startNetworkGameDialogImpl::addConnectedPlayer(QString playerName, int righ
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget,0);
|
||||
item->setData(0, 0, playerName);
|
||||
|
||||
// myW->getMySDLPlayer()->playSound("call", 0);
|
||||
|
||||
checkPlayerQuantity();
|
||||
}
|
||||
|
||||
@@ -104,11 +106,16 @@ void startNetworkGameDialogImpl::kickPlayer() {
|
||||
|
||||
void startNetworkGameDialogImpl::checkPlayerQuantity() {
|
||||
|
||||
if (treeWidget->topLevelItemCount() >= 2 && isAdmin)
|
||||
if (treeWidget->topLevelItemCount() >= 2 && isAdmin) {
|
||||
pushButton_startGame->setEnabled(TRUE);
|
||||
else
|
||||
}
|
||||
else {
|
||||
pushButton_startGame->setEnabled(FALSE);
|
||||
|
||||
}
|
||||
|
||||
if(treeWidget->topLevelItemCount() == maxPlayerNumber) {
|
||||
// myW->getMySDLPlayer()->playSound("raise", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void startNetworkGameDialogImpl::setSession(Session *session)
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtCore>
|
||||
#include "sdlplayer.h"
|
||||
#include "mainwindowimpl.h"
|
||||
|
||||
class Session;
|
||||
class ConfigFile;
|
||||
@@ -35,6 +37,9 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
void setMyW ( mainWindowImpl* theValue ) { myW = theValue; }
|
||||
|
||||
|
||||
void startGame();
|
||||
void cancel();
|
||||
void refresh(int actionID);
|
||||
@@ -55,6 +60,7 @@ public slots:
|
||||
|
||||
private:
|
||||
|
||||
mainWindowImpl* myW;
|
||||
int maxPlayerNumber;
|
||||
bool isAdmin;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
Reference in New Issue
Block a user