BeRo refactoring

This commit is contained in:
doitux
2007-08-07 13:07:39 +00:00
parent 2f76bb82f9
commit c34f683c41
24 changed files with 425 additions and 1337 deletions
+1 -119
View File
@@ -24,130 +24,12 @@
using namespace std;
LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB), myHand(hi), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), firstHeadsUpFlopRound(1), playersTurn(dP), logBoardCardsDone(0)
LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_FLOP)
{
myBeRoID = GAME_STATE_FLOP;
int i;
//SmallBlind-Position ermitteln
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
cout << "LocalBeroFlop erstellt - " << myBeRoID << endl;
}
LocalBeRoFlop::~LocalBeRoFlop()
{
}
void LocalBeRoFlop::run() {
cout << "LocalBeroFlopRun!!!" << endl;
int i;
if (firstFlopRun) {
myHand->getGuiInterface()->dealFlopCards();
firstFlopRun = 0;
}
else {
//log the turned cards
if(!logBoardCardsDone) {
int tempBoardCardsArray[5];
myHand->getBoard()->getMyCards(tempBoardCardsArray);
myHand->getGuiInterface()->logDealBoardCardsMsg(1, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
logBoardCardsDone = 1;
}
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
}
}
// prfen, ob Flop wirklich dran ist
if(!firstFlopRound && allHighestSet) {
// Flop nicht dran, weil alle Sets gleich sind
//also gehe in Turn
myHand->setActualRound(2);
//Action loeschen und ActionButtons refresh
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
}
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
myHand->getBoard()->collectSets();
myHand->getBoard()->collectPot();
myHand->getGuiInterface()->refreshPot();
myHand->getGuiInterface()->refreshSet();
myHand->getGuiInterface()->refreshCash();
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { myHand->getGuiInterface()->refreshAction(i,0); }
myHand->switchRounds();
}
else {
// Flop ist wirklich dran
// Anzahl der effektiv gespielten Runden (des human player) erhöhen
if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) {
myHand->setBettingRoundsPlayed(1);
}
if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpFlopRound == 1) ) {
// 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);
}
else { firstHeadsUpFlopRound = 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);
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
//highlight active players groupbox and clear action
myHand->getGuiInterface()->refreshGroupbox(playersTurn,2);
myHand->getGuiInterface()->refreshAction(playersTurn,0);
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; }
if(playersTurn == 0) {
// Wir sind dran
myHand->getGuiInterface()->meInAction();
}
else {
//Gegner sind dran
myHand->getGuiInterface()->flopAnimation2();
}
}
}
}
void LocalBeRoFlop::nextPlayer2() {
// cout << "NextPlayerSpeed3 stop" << endl;
myHand->getPlayerArray()[playersTurn]->action();
}