BeRo refactoring
This commit is contained in:
@@ -11,17 +11,35 @@
|
||||
//
|
||||
#include "localbero.h"
|
||||
|
||||
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB) : BeRoInterface(), myHand(hi), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRun(1), firstRound(1), firstHeadsUpRound(1), playersTurn(dP), logBoardCardsDone(0)
|
||||
using namespace std;
|
||||
|
||||
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB, GameState gS) : BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRun(1), firstRound(1), firstHeadsUpRound(1), playersTurn(dP), logBoardCardsDone(0)
|
||||
{
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
//SmallBlind-Position ermitteln
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
LocalBeRo::~LocalBeRo()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalBeRo::nextPlayer() {
|
||||
|
||||
myHand->getPlayerArray()[playersTurn]->action();
|
||||
|
||||
}
|
||||
|
||||
void LocalBeRo::run() {
|
||||
|
||||
cout << "LocalBeRoRun-" << myBeRoID << endl;
|
||||
|
||||
int i;
|
||||
|
||||
if (firstRun) {
|
||||
@@ -110,7 +128,7 @@ void LocalBeRo::run() {
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->flopAnimation2();
|
||||
myHand->getGuiInterface()->beRoAnimation2(myBeRoID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#ifndef LOCALBERO_H
|
||||
#define LOCALBERO_H
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "game_defs.h"
|
||||
#include "berointerface.h"
|
||||
#include "handinterface.h"
|
||||
|
||||
@@ -20,7 +24,7 @@
|
||||
*/
|
||||
class LocalBeRo : public BeRoInterface{
|
||||
public:
|
||||
LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB);
|
||||
LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB, GameState gS);
|
||||
|
||||
~LocalBeRo();
|
||||
|
||||
@@ -29,6 +33,25 @@ public:
|
||||
int getHighestCardsValue() const {return 0;}
|
||||
void setHighestCardsValue(int theValue) {}
|
||||
|
||||
|
||||
void setPlayersTurn(int theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
|
||||
void setFirstRound(bool theValue) { firstRound = theValue;}
|
||||
bool getFirstRound() const { return firstRound;}
|
||||
|
||||
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
|
||||
int getSmallBlindPosition() const { return smallBlindPosition; }
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
|
||||
void resetFirstRun() { firstRun = false; }
|
||||
|
||||
void nextPlayer();
|
||||
void run();
|
||||
|
||||
//only until bero refactoring is over
|
||||
@@ -37,8 +60,6 @@ public:
|
||||
void riverRun() {}
|
||||
void turnRun() {}
|
||||
void postRiverRun() {}
|
||||
|
||||
void resetFirstRun() {}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,47 +31,6 @@ public:
|
||||
LocalBeRoFlop(HandInterface*, int, int, int, int);
|
||||
~LocalBeRoFlop();
|
||||
|
||||
|
||||
void setPlayersTurn(int theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
|
||||
void setFirstFlopRound(bool theValue) { firstFlopRound = theValue;}
|
||||
bool getFirstFlopRound() const { return firstFlopRound;}
|
||||
|
||||
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
|
||||
int getSmallBlindPosition() const { return smallBlindPosition; }
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
|
||||
void resetFirstRun() { firstFlopRun = false; }
|
||||
|
||||
void run();
|
||||
|
||||
void nextPlayer2();
|
||||
|
||||
private:
|
||||
|
||||
HandInterface *myHand;
|
||||
|
||||
int myID;
|
||||
int actualQuantityPlayers;
|
||||
int dealerPosition;
|
||||
int smallBlindPosition;
|
||||
|
||||
int smallBlind;
|
||||
int highestSet;
|
||||
|
||||
bool firstFlopRun;
|
||||
bool firstFlopRound;
|
||||
bool firstHeadsUpFlopRound;
|
||||
int playersTurn;
|
||||
|
||||
bool logBoardCardsDone;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,19 +25,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LocalBeRoPostRiver::LocalBeRoPostRiver(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), firstRiverRun(1), firstRiverRound(1), firstHeadsUpRiverRound(1), playersTurn(dP), highestCardsValue(0), logBoardCardsDone(0)
|
||||
|
||||
LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_POST_RIVER)
|
||||
{
|
||||
|
||||
myBeRoID = GAME_STATE_POST_RIVER;
|
||||
|
||||
int i;
|
||||
|
||||
//SmallBlind-Position ermitteln
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
|
||||
}
|
||||
cout << "LocalBeroPostRiver erstellt - " << myBeRoID << endl;
|
||||
}
|
||||
|
||||
LocalBeRoPostRiver::~LocalBeRoPostRiver()
|
||||
@@ -45,109 +34,6 @@ LocalBeRoPostRiver::~LocalBeRoPostRiver()
|
||||
}
|
||||
|
||||
|
||||
void LocalBeRoPostRiver::riverRun() {
|
||||
|
||||
cout << "LocalBeroPostRiverRun!!!" << endl;
|
||||
int i;
|
||||
|
||||
if (firstRiverRun) {
|
||||
myHand->getGuiInterface()->dealRiverCard();
|
||||
firstRiverRun = 0;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
//log the turned cards
|
||||
if(!logBoardCardsDone) {
|
||||
int tempBoardCardsArray[5];
|
||||
|
||||
myHand->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(3, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
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) {
|
||||
// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl;
|
||||
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
|
||||
}
|
||||
}
|
||||
// cout << "allHighestSet " << allHighestSet << endl;
|
||||
|
||||
// cout << "firstflopround " << firstRiverRound << endl;
|
||||
|
||||
// prfen, ob River wirklich dran ist
|
||||
if(!firstRiverRound && allHighestSet) {
|
||||
|
||||
// River nicht dran, weil alle Sets gleich sind
|
||||
//also gehe in Turn
|
||||
myHand->setActualRound(4);
|
||||
|
||||
//Action lᅵchen 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 {
|
||||
// River 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(3);
|
||||
}
|
||||
|
||||
if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpRiverRound == 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 { firstHeadsUpRiverRound = 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);
|
||||
|
||||
// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl;
|
||||
// cout << "playersTurn " << playersTurn << endl;
|
||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; }
|
||||
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->riverAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBeRoPostRiver::postRiverRun() {
|
||||
|
||||
int i;
|
||||
@@ -199,12 +85,6 @@ void LocalBeRoPostRiver::postRiverRun() {
|
||||
myHand->getGuiInterface()->postRiverRunAnimation1();
|
||||
}
|
||||
|
||||
void LocalBeRoPostRiver::nextPlayer2() {
|
||||
|
||||
myHand->getPlayerArray()[playersTurn]->action();
|
||||
|
||||
}
|
||||
|
||||
void LocalBeRoPostRiver::distributePot() {
|
||||
|
||||
// int potCalcAllinArray[5][2]; // 0 -> ID , 1 -> AllInCash
|
||||
|
||||
@@ -31,57 +31,16 @@ public:
|
||||
LocalBeRoPostRiver(HandInterface*, int, int, int, int);
|
||||
~LocalBeRoPostRiver();
|
||||
|
||||
void setPlayersTurn(int theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
|
||||
void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;}
|
||||
bool getFirstRiverRound() const { return firstRiverRound;}
|
||||
|
||||
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
|
||||
int getSmallBlindPosition() const { return smallBlindPosition; }
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
|
||||
void setHighestCardsValue(int theValue) { highestCardsValue = theValue;}
|
||||
int getHighestCardsValue() const { return highestCardsValue;}
|
||||
|
||||
void resetFirstRun() { firstRiverRun = false; }
|
||||
|
||||
void riverRun();
|
||||
void postRiverRun();
|
||||
void nextPlayer2();
|
||||
void distributePot();
|
||||
|
||||
//only until bero refactory is over
|
||||
void preflopRun() {}
|
||||
void turnRun() {}
|
||||
void flopRun() {}
|
||||
|
||||
private:
|
||||
|
||||
HandInterface *myHand;
|
||||
|
||||
int myID;
|
||||
int actualQuantityPlayers;
|
||||
int dealerPosition;
|
||||
int smallBlindPosition;
|
||||
|
||||
int smallBlind;
|
||||
int highestSet;
|
||||
|
||||
bool firstRiverRun;
|
||||
bool firstRiverRound;
|
||||
bool firstHeadsUpRiverRound;
|
||||
int playersTurn;
|
||||
|
||||
int highestCardsValue;
|
||||
|
||||
bool logBoardCardsDone;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB), myHand(hi), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0)
|
||||
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0)
|
||||
|
||||
{
|
||||
myBeRoID = GAME_STATE_PREFLOP;
|
||||
highestSet = 2*smallBlind;
|
||||
|
||||
// // BigBlind ermitteln
|
||||
bigBlindPosition = dealerPosition;
|
||||
@@ -72,11 +72,11 @@ void LocalBeRoPreflop::run() {
|
||||
}
|
||||
|
||||
// prfen, ob Preflop wirklich dran ist
|
||||
if(!preflopFirstRound && allHighestSet) {
|
||||
if(!firstRound && allHighestSet) {
|
||||
|
||||
// Preflop nicht dran, weil wir nicht mehr in erster PreflopRunde und alle Sets gleich sind
|
||||
//also gehe in Flop
|
||||
myHand->setActualRound(1);
|
||||
myHand->setActualRound(GAME_STATE_FLOP);
|
||||
|
||||
//Action loeschen und ActionButtons refresh
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
@@ -101,7 +101,7 @@ void LocalBeRoPreflop::run() {
|
||||
|
||||
playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
// falls BigBlind, dann PreflopFirstRound zuende
|
||||
if(myHand->getPlayerArray()[playersTurn]->getMyButton() == 3) preflopFirstRound = 0;
|
||||
if(myHand->getPlayerArray()[playersTurn]->getMyButton() == 3) firstRound = 0;
|
||||
|
||||
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || myHand->getPlayerArray()[playersTurn]->getMyAction() == 1 || myHand->getPlayerArray()[playersTurn]->getMyAction() == 6);
|
||||
|
||||
@@ -117,13 +117,7 @@ void LocalBeRoPreflop::run() {
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->preflopAnimation2();
|
||||
myHand->getGuiInterface()->beRoAnimation2(myBeRoID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBeRoPreflop::nextPlayer2() {
|
||||
// cout << "NextPlayerSpeed3 stop" << endl;
|
||||
myHand->getPlayerArray()[playersTurn]->action();
|
||||
|
||||
}
|
||||
|
||||
@@ -31,32 +31,10 @@ public:
|
||||
LocalBeRoPreflop(HandInterface*, int, int, int, int);
|
||||
~LocalBeRoPreflop();
|
||||
|
||||
void setPlayersTurn(int theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
|
||||
void run();
|
||||
void nextPlayer2();
|
||||
|
||||
|
||||
private:
|
||||
HandInterface *myHand;
|
||||
|
||||
|
||||
int myID;
|
||||
int actualQuantityPlayers;
|
||||
int dealerPosition;
|
||||
int bigBlindPosition;
|
||||
|
||||
int smallBlind;
|
||||
int highestSet;
|
||||
|
||||
bool preflopFirstRound;
|
||||
int playersTurn;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,445 +25,10 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LocalBeRoRiver::LocalBeRoRiver(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), firstRiverRun(1), firstRiverRound(1), firstHeadsUpRiverRound(1), playersTurn(dP), highestCardsValue(0), logBoardCardsDone(0)
|
||||
|
||||
LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_RIVER)
|
||||
{
|
||||
|
||||
myBeRoID = GAME_STATE_RIVER;
|
||||
|
||||
int i;
|
||||
|
||||
//SmallBlind-Position ermitteln
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
|
||||
}
|
||||
cout << "LocalBeroRiver erstellt - " << myBeRoID << endl;
|
||||
}
|
||||
|
||||
LocalBeRoRiver::~LocalBeRoRiver()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LocalBeRoRiver::run() {
|
||||
|
||||
cout << "LocalBeroRiverRun!!!" << endl;
|
||||
int i;
|
||||
|
||||
if (firstRiverRun) {
|
||||
myHand->getGuiInterface()->dealRiverCard();
|
||||
firstRiverRun = 0;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
//log the turned cards
|
||||
if(!logBoardCardsDone) {
|
||||
int tempBoardCardsArray[5];
|
||||
|
||||
myHand->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(3, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
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 River wirklich dran ist
|
||||
if(!firstRiverRound && allHighestSet) {
|
||||
|
||||
// River nicht dran, weil alle Sets gleich sind
|
||||
//also gehe in Turn
|
||||
myHand->setActualRound(4);
|
||||
|
||||
//Action lᅵchen 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 {
|
||||
// River 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(3);
|
||||
}
|
||||
|
||||
if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpRiverRound == 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 { firstHeadsUpRiverRound = 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) { firstRiverRound = 0; }
|
||||
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->riverAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBeRoRiver::postRiverRun() {
|
||||
|
||||
int i;
|
||||
|
||||
// für die Engine die durchschnittlichen Sets von Player 0 setzen --> UNUSED !!!
|
||||
// if(myID < 5) {
|
||||
// myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*(myID-1))/myID + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/myID);
|
||||
// } else {
|
||||
// myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*4)/5 + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/5);
|
||||
// }
|
||||
|
||||
// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl;
|
||||
|
||||
//berechnen welcher Spieler gewonnen hat
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
|
||||
// cout << "Spieler: " << i << " hat: " << myHand->getPlayerArray()[i]->getMyCardsValueInt() << endl;
|
||||
|
||||
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyCardsValueInt() > highestCardsValue ) {
|
||||
highestCardsValue = myHand->getPlayerArray()[i]->getMyCardsValueInt();
|
||||
}
|
||||
}
|
||||
|
||||
// Durchschnittsets des human player ermitteln
|
||||
myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyRoundStartCash())-(myHand->getPlayerArray()[0]->getMyCash()))/(myHand->getBettingRoundsPlayed()+1));
|
||||
// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl;
|
||||
|
||||
// Aggressivität des human player ermitteln
|
||||
// anzahl der player die möglichkeit haben am pot teilzuhaben
|
||||
int potPlayers = 0;
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) {
|
||||
potPlayers++;
|
||||
}
|
||||
}
|
||||
|
||||
// prüfen ob nur noch der human player an der verteilung teilnimmt und myAggressive für human player setzen
|
||||
myHand->getPlayerArray()[0]->setMyAggressive(potPlayers == 1 && myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1);
|
||||
|
||||
// cout << "myAggressive: " << myHand->getPlayerArray()[0]->getMyAggressive() << endl;
|
||||
|
||||
// Pot-Verteilung
|
||||
distributePot();
|
||||
|
||||
//Pot auf 0 setzen
|
||||
myHand->getBoard()->setPot(0);
|
||||
|
||||
//starte die Animaionsreihe
|
||||
myHand->getGuiInterface()->postRiverRunAnimation1();
|
||||
}
|
||||
|
||||
void LocalBeRoRiver::nextPlayer2() {
|
||||
|
||||
myHand->getPlayerArray()[playersTurn]->action();
|
||||
|
||||
}
|
||||
|
||||
void LocalBeRoRiver::distributePot() {
|
||||
|
||||
// int potCalcAllinArray[5][2]; // 0 -> ID , 1 -> AllInCash
|
||||
|
||||
int i, j;
|
||||
|
||||
////////////////////
|
||||
// (1) EINLEITUNG //
|
||||
////////////////////
|
||||
|
||||
// die Potverteilung gliedert sich in mehrere Runden:
|
||||
// in der ersten Runden sucht sich der Winner der BettingRound seinen zustehenden Anteil am Pot raus. das kann alles oder nur ein Teil sein (z.b. wenn er mit wenig allin gegangen ist und der Rest weitergespielt hat)
|
||||
// in den darauffolgenden Verteilungsrunden suchen sich die jeweils nᅵhsten Winner aus dem noch brig gebliebenen Pot ihren zustehenden Anteil raus
|
||||
// die gesamte Potverteilung ist zuende, wenn der Pot leer ist und nichts mehr zu holen ist
|
||||
|
||||
|
||||
/////////////////////
|
||||
// (2) HILFSMITTEL //
|
||||
/////////////////////
|
||||
|
||||
// winnersArray erstellen -> hier werden die winner der jeweiligen Potverteilungsrunden eingetragen
|
||||
int *winnersArray = new int[MAX_NUMBER_OF_PLAYERS];
|
||||
|
||||
// Anzahl der winner in einer Potverteilungsrunde
|
||||
int winnersCounter = 0;
|
||||
|
||||
// dieses Array ermittelt wieviel jeder Spieler wᅵrend der gesamten BettingRound gesetzt hat
|
||||
int *roundSetArray = new int[MAX_NUMBER_OF_PLAYERS];
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
// Standardwert fr nicht mehr aktive
|
||||
roundSetArray[i] = 0;
|
||||
// nur fr die Spieler ermitteln, die noch aktiv sind (inkl. der gefoldeten)
|
||||
if(myHand->getPlayerArray()[i]->getMyActiveStatus()) {
|
||||
roundSetArray[i] = myHand->getPlayerArray()[i]->getMyRoundStartCash()-myHand->getPlayerArray()[i]->getMyCash();
|
||||
}
|
||||
}
|
||||
|
||||
// hier steht der CardsValue der Spieler drin die an der Potverteilung teilnehmen (d.h. aktiv und nicht gefoldet), bei allen anderen steht ne 0
|
||||
int *cardsValueArray = new int[MAX_NUMBER_OF_PLAYERS];
|
||||
int playerWantsPotCounter = 0;
|
||||
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
// Standardwert
|
||||
cardsValueArray[i] = 0;
|
||||
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) {
|
||||
// nur bei den Spielen den Kartenwert eintragen, die an der Potverteilung teilnehmen
|
||||
cardsValueArray[i] = myHand->getPlayerArray()[i]->getMyCardsValueInt();
|
||||
playerWantsPotCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
int winner;
|
||||
int highestCardsValueTemp;
|
||||
|
||||
// fr SplitPotBerechnung;
|
||||
int winnersSets;
|
||||
int winnersMaxSet;
|
||||
int winnersPot;
|
||||
bool playerIsWinner;
|
||||
|
||||
|
||||
|
||||
//////////////////////
|
||||
// (3) DIE SCHLEIFE //
|
||||
//////////////////////
|
||||
|
||||
|
||||
// Potverteilungsrunden -> solange noch was aus dem pot zu vergeben ist
|
||||
while(playerWantsPotCounter != 0 ) {
|
||||
|
||||
// highestCardsValueTemp zu Beginn der aktuellen Potverteilungsrunde auf Null setzen
|
||||
highestCardsValueTemp = 0;
|
||||
|
||||
// aktuellen highestCardsValueTemp berechnen, von denen die noch an der Potverteilung teilnehmen
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(cardsValueArray[i] > highestCardsValueTemp ) {
|
||||
highestCardsValueTemp = myHand->getPlayerArray()[i]->getMyCardsValueInt();
|
||||
}
|
||||
}
|
||||
|
||||
// zu Beginn der Potverteilungsrunde die Anzahl der winner auf 0 setzen
|
||||
winnersCounter = 0;
|
||||
// Siegerposition und -anzahl von denen ermitteln, die noch an der Potverteilung teilnehmen
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(cardsValueArray[i] == highestCardsValueTemp ) {
|
||||
winnersArray[winnersCounter] = i;
|
||||
winnersCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// A) nur einer hat aktulle Potverteilungsrunde gewonnen gewonnen
|
||||
// --------------------------------------------------------------
|
||||
if(winnersCounter == 1) {
|
||||
|
||||
// winnerID ist an der ersten Stelle im winnersArray
|
||||
winner = winnersArray[0];
|
||||
|
||||
// Winner ist nicht All In gegangen -> bekommt den gesamten Pot
|
||||
// if(myHand->getPlayerArray()[winner]->getMyAction() != 6) {
|
||||
//
|
||||
// myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+myHand->getBoard()->getPot());
|
||||
// myHand->getBoard()->setPot(0);
|
||||
// playerWantsPotCounter = 1;
|
||||
//
|
||||
// }
|
||||
// Winner ist All In gegangen -> von denen die weniger gesetzt oder gefoldet hatten alles nehmen und von denen die mehr gesetzt hatten nur die eigenen Sets nehmen
|
||||
// else {
|
||||
|
||||
// alle Spieler nacheinander durchgehen und prfen von wem man wieviel Geld aus dem Pot bekommt
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
|
||||
// zuerst prfen ob ein gefoldeter Spieler was gesetzt hatte
|
||||
if(i != winner && myHand->getPlayerArray()[i]->getMyAction() == 1) {
|
||||
|
||||
// diesen Teil aus dem Pot holen
|
||||
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]);
|
||||
// Pot dementsprechend verkleinern
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
|
||||
// deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nimmt der Winner dann von diesen Spielern 0 Dollar aus dem Pot
|
||||
roundSetArray[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
// nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht von einem selber
|
||||
if(i != winner && cardsValueArray[i] != 0) {
|
||||
|
||||
// zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten
|
||||
if(roundSetArray[winner] >= roundSetArray[i]) {
|
||||
|
||||
// von denen alles holen
|
||||
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]);
|
||||
// Pot dementsprechend verkleinern
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
|
||||
// diese Spieler dann von der weiteren Potverteilung ausschlieᅵn
|
||||
cardsValueArray[i] = 0;
|
||||
playerWantsPotCounter--;
|
||||
// deren Sets auf Null seztzen, da sie schon alles abgegeben haben
|
||||
roundSetArray[i] = 0;
|
||||
|
||||
}
|
||||
// nun alle Spieler die mehr gesetzt hatten
|
||||
else {
|
||||
|
||||
// den eigenen Setanteil aus dem Pot holen
|
||||
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]);
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]);
|
||||
// den Set des Gegners um den bereits abgenommenen Setanteil verkleinern
|
||||
roundSetArray[i] = roundSetArray[i] - roundSetArray[winner];
|
||||
// diese Spieler nehmen an der weiteren Potverteilung teil
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// // }
|
||||
|
||||
// zum Scluss noch eingenen Set wieder holen
|
||||
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]);
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]);
|
||||
// nicht mehr an der weiteren Potverteilung teilnehmen, da man sich alles geholt hat was einem zusteht
|
||||
cardsValueArray[winner] = 0;
|
||||
playerWantsPotCounter--;
|
||||
// eigene Sets auf Null seztzen, da sie eben eingesammelt wurden
|
||||
roundSetArray[winner] = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// B) mehrere haben die aktuelle Potverteilungsrunde gewonnen -> SplitPot
|
||||
// ----------------------------------------------------------------------
|
||||
else {
|
||||
|
||||
// hierfr wird ein temporᅵer WinnersPot erstellt; dort flieᅵn erstmal alle zustehenden Anteile aus dem Pot rauf; am Ende wird dies auf die Winners verteilt
|
||||
winnersPot = 0;
|
||||
// hᅵhster Set aller Winner
|
||||
winnersMaxSet = 0;
|
||||
|
||||
// den hᅵhsten Set aller Winner ermitteln
|
||||
for(i=0; i<winnersCounter; i++) {
|
||||
if(roundSetArray[winnersArray[i]] > winnersMaxSet) winnersMaxSet = roundSetArray[i];
|
||||
}
|
||||
|
||||
// gesamtSet aller Winner
|
||||
winnersSets = 0;
|
||||
for(i=0; i<winnersCounter; i++) {
|
||||
winnersSets += roundSetArray[winnersArray[i]];
|
||||
}
|
||||
|
||||
// alle Spieler nacheinander durchgehen und prfen von wem die Winner wieviel Geld aus dem Pot bekommen
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
|
||||
// prfen ob Spieler i zu den Winnern gehᅵt
|
||||
playerIsWinner = 0;
|
||||
for(j=0; j<winnersCounter; j++) {
|
||||
if(winnersArray[j] == i) playerIsWinner = 1; // -> Spieler i gehᅵt zu den Winnern
|
||||
}
|
||||
|
||||
// zuerst prfen ob ein gefoldeter Spieler was gesetzt hatte
|
||||
if(!playerIsWinner && myHand->getPlayerArray()[i]->getMyAction() == 1) {
|
||||
|
||||
// diesen Teil aus dem Pot holen und dem winnersPot geben
|
||||
winnersPot += roundSetArray[i];
|
||||
// Pot dementsprechend verkleinern
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
|
||||
// deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nehmen die Winner dann von diesen Spielern 0 Dollar aus dem Pot
|
||||
roundSetArray[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
// nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht zu den Winnern gehᅵen
|
||||
if(!playerIsWinner && cardsValueArray[i] != 0) {
|
||||
|
||||
// zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten
|
||||
if(winnersMaxSet >= roundSetArray[i]) {
|
||||
|
||||
// von denen alles holen
|
||||
winnersPot += roundSetArray[i];
|
||||
// Pot dementsprechend verkleinern
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
|
||||
// diese Spieler dann von der weiteren Potverteilung ausschlieᅵn
|
||||
cardsValueArray[i] = 0;
|
||||
playerWantsPotCounter--;
|
||||
// deren Sets auf Null seztzen, da sie schon alles abgegeben haben
|
||||
roundSetArray[i] = 0;
|
||||
|
||||
}
|
||||
// nun alle Spieler die mehr gesetzt hatten
|
||||
else {
|
||||
|
||||
// den eigenen Setanteil aus dem Pot holen
|
||||
winnersPot += winnersMaxSet;
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersMaxSet);
|
||||
// den Set des Gegners um den bereits abgenommenen Setanteil verkleinern
|
||||
roundSetArray[i] = roundSetArray[i] - winnersMaxSet;
|
||||
// diese Spieler nehmen an der weiteren Potverteilung teil
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// zum Schluss noch die eingenen Set aus dem Pot holen
|
||||
winnersPot += winnersSets;
|
||||
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersSets);
|
||||
|
||||
// winnersPot verteilen (anteilmᅵig)
|
||||
for(i=0; i<winnersCounter; i++) {
|
||||
myHand->getPlayerArray()[winnersArray[i]]->setMyCash(myHand->getPlayerArray()[winnersArray[i]]->getMyCash()+((roundSetArray[winnersArray[i]]*winnersPot)/winnersSets));
|
||||
}
|
||||
|
||||
|
||||
for(i=0; i<winnersCounter; i++) {
|
||||
// nicht mehr an der weiteren Potverteilung teilnehmen, da man sich alle Winner dieser Verteilungsrunde ihren Anteil geholt haben
|
||||
cardsValueArray[winnersArray[i]] = 0;
|
||||
playerWantsPotCounter--;
|
||||
// Sets auf Null seztzen, da sie eben eingesammelt wurden
|
||||
roundSetArray[winnersArray[i]] = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(myHand->getBoard()->getPot() != 0) cout << "!!! Pot: " << myHand->getBoard()->getPot() << endl;
|
||||
|
||||
delete[] winnersArray;
|
||||
delete[] roundSetArray;
|
||||
delete[] cardsValueArray;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,53 +30,6 @@ class LocalBeRoRiver : public LocalBeRo{
|
||||
public:
|
||||
LocalBeRoRiver(HandInterface*, int, int, int, int);
|
||||
~LocalBeRoRiver();
|
||||
|
||||
void setPlayersTurn(int theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
|
||||
void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;}
|
||||
bool getFirstRiverRound() const { return firstRiverRound;}
|
||||
|
||||
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
|
||||
int getSmallBlindPosition() const { return smallBlindPosition; }
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
|
||||
void setHighestCardsValue(int theValue) { highestCardsValue = theValue;}
|
||||
int getHighestCardsValue() const { return highestCardsValue;}
|
||||
|
||||
void resetFirstRun() { firstRiverRun = false; }
|
||||
|
||||
void run();
|
||||
void postRiverRun();
|
||||
void nextPlayer2();
|
||||
void distributePot();
|
||||
|
||||
private:
|
||||
|
||||
HandInterface *myHand;
|
||||
|
||||
int myID;
|
||||
int actualQuantityPlayers;
|
||||
int dealerPosition;
|
||||
int smallBlindPosition;
|
||||
|
||||
int smallBlind;
|
||||
int highestSet;
|
||||
|
||||
bool firstRiverRun;
|
||||
bool firstRiverRound;
|
||||
bool firstHeadsUpRiverRound;
|
||||
int playersTurn;
|
||||
|
||||
int highestCardsValue;
|
||||
|
||||
bool logBoardCardsDone;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,126 +24,10 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LocalBeRoTurn::LocalBeRoTurn(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), firstTurnRun(1), firstTurnRound(1), firstHeadsUpTurnRound(1), playersTurn(dP), logBoardCardsDone(0)
|
||||
|
||||
LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_TURN)
|
||||
{
|
||||
|
||||
myBeRoID = GAME_STATE_TURN;
|
||||
|
||||
int i;
|
||||
|
||||
//SmallBlind-Position ermitteln
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
|
||||
}
|
||||
|
||||
cout << "LocalBeroTurn erstellt - " << myBeRoID << endl;
|
||||
|
||||
}
|
||||
|
||||
LocalBeRoTurn::~LocalBeRoTurn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LocalBeRoTurn::run() {
|
||||
|
||||
cout << "LocalBeroTurnRun!!!" << endl;
|
||||
int i;
|
||||
|
||||
if (firstTurnRun) {
|
||||
myHand->getGuiInterface()->dealTurnCard();
|
||||
firstTurnRun = 0;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
//log the turned cards
|
||||
if(!logBoardCardsDone) {
|
||||
int tempBoardCardsArray[5];
|
||||
|
||||
myHand->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(2, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
||||
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 Turn wirklich dran ist
|
||||
if(!firstTurnRound && allHighestSet) {
|
||||
|
||||
// Turn nicht dran, weil alle Sets gleich sind
|
||||
//also gehe in Turn
|
||||
myHand->setActualRound(3);
|
||||
|
||||
//Action l�chen 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 {
|
||||
// Turn 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(2);
|
||||
}
|
||||
|
||||
if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpTurnRound == 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 { firstHeadsUpTurnRound = 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) { firstTurnRound = 0; }
|
||||
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->turnAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBeRoTurn::nextPlayer2() {
|
||||
// cout << "NextPlayerSpeed3 stop" << endl;
|
||||
myHand->getPlayerArray()[playersTurn]->action();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,45 +30,6 @@ public:
|
||||
LocalBeRoTurn(HandInterface*, int, int, int, int);
|
||||
~LocalBeRoTurn();
|
||||
|
||||
void setPlayersTurn(int theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
|
||||
void setFirstTurnRound(bool theValue) { firstTurnRound = theValue;}
|
||||
bool getFirstTurnRound() const { return firstTurnRound;}
|
||||
|
||||
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
|
||||
int getSmallBlindPosition() const { return smallBlindPosition; }
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
|
||||
void resetFirstRun() { firstTurnRun = false; }
|
||||
|
||||
void nextPlayer2();
|
||||
void run();
|
||||
|
||||
private:
|
||||
|
||||
HandInterface *myHand;
|
||||
|
||||
int myID;
|
||||
int actualQuantityPlayers;
|
||||
int dealerPosition;
|
||||
int smallBlindPosition;
|
||||
|
||||
int smallBlind;
|
||||
int highestSet;
|
||||
|
||||
bool firstTurnRun;
|
||||
bool firstTurnRound;
|
||||
bool firstHeadsUpTurnRound;
|
||||
int playersTurn;
|
||||
|
||||
bool logBoardCardsDone;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user