Maximum number of players is now a constant in game_defs.h.

This commit is contained in:
lotodore
2007-04-17 07:28:32 +00:00
parent 496261de7b
commit 27cd08ccb0
15 changed files with 134 additions and 115 deletions
+3 -2
View File
@@ -20,6 +20,7 @@
#include "localboard.h"
#include "localhand.h"
#include <game_defs.h>
using namespace std;
@@ -40,7 +41,7 @@ void LocalBoard::collectSets() {
sets = 0;
int i;
for(i=0; i<actualHand->getGuiInterface()->getMaxQuantityPlayers(); i++) sets += playerArray[i]->getMySet();
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) sets += playerArray[i]->getMySet();
}
@@ -48,7 +49,7 @@ void LocalBoard::collectPot() {
int i;
pot += sets;
sets = 0;
for(i=0; i<actualHand->getGuiInterface()->getMaxQuantityPlayers(); i++){ playerArray[i]->setMySetNull(); }
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++){ playerArray[i]->setMySetNull(); }
}
+6 -5
View File
@@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localflop.h"
#include <game_defs.h>
using namespace std;
@@ -27,7 +28,7 @@ LocalFlop::LocalFlop(HandInterface* bR, int id, int qP, int dP, int sB) : FlopIn
int i;
//SmallBlind-Position ermitteln
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
@@ -53,7 +54,7 @@ void LocalFlop::flopRun() {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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; }
}
@@ -69,7 +70,7 @@ void LocalFlop::flopRun() {
myHand->setActualRound(2);
//Action lchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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
@@ -94,12 +95,12 @@ void LocalFlop::flopRun() {
// nhsten Spieler ermitteln
do { playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
//Spieler-Position vor SmallBlind-Position ermitteln
int activePlayerBeforeSmallBlind = smallBlindPosition;
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + myHand->getGuiInterface()->getMaxQuantityPlayers() - 1 ) % (myHand->getGuiInterface()->getMaxQuantityPlayers());
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);
+8 -7
View File
@@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localhand.h"
#include <game_defs.h>
using namespace std;
@@ -41,7 +42,7 @@ LocalHand::LocalHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, Playe
// roundStartCashArray fllen
for(i=0; i<myGui->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
}
@@ -135,7 +136,7 @@ void LocalHand::assignButtons() {
int i;
// alle Buttons loeschen
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) { playerArray[i]->setMyButton(0); }
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { playerArray[i]->setMyButton(0); }
// DealerButton zuweisen
playerArray[dealerPosition]->setMyButton(1);
@@ -143,7 +144,7 @@ void LocalHand::assignButtons() {
// Small Blind zuweisen und setzen
i = dealerPosition;
do {
i = (i+1)%(myGui->getMaxQuantityPlayers());
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
if(playerArray[i]->getMyActiveStatus()) {
playerArray[i]->setMyButton(2);
// mit SmallBlind All In ?
@@ -163,7 +164,7 @@ void LocalHand::assignButtons() {
// Big Blind zuweisen
do {
i = (i+1)%(myGui->getMaxQuantityPlayers());
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
if(playerArray[i]->getMyActiveStatus()) {
playerArray[i]->setMyButton(3);
// mit BigBlind All In ?
@@ -191,13 +192,13 @@ void LocalHand::switchRounds() {
//Aktive Spieler zlen --> wenn nur noch einer nicht-folded dann gleich den Pot verteilen
activePlayersCounter = 0;
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) {
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if (playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyActiveStatus() == 1) activePlayersCounter++;
}
// Anzahl der Spieler ermitteln, welche All In sind
int allInPlayersCounter = 0;
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) {
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if (playerArray[i]->getMyAction() == 6) allInPlayersCounter++;
}
@@ -222,7 +223,7 @@ void LocalHand::switchRounds() {
int tempHighestSet;
if(allInPlayersCounter+1 == activePlayersCounter) {
// Spieler ermitteln, der noch nicht All In ist
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) {
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) {
tempHighestSet = 0;
switch (actualRound) {
+6 -5
View File
@@ -20,6 +20,7 @@
#include "localpreflop.h"
#include "handinterface.h"
#include <game_defs.h>
using namespace std;
@@ -33,7 +34,7 @@ LocalPreflop::LocalPreflop(HandInterface* bR, int id, int qP, int dP, int sB) :
// // BigBlind ermitteln
bigBlindPosition = dealerPosition;
while (myHand->getPlayerArray()[bigBlindPosition]->getMyButton() != 3) {
bigBlindPosition = (bigBlindPosition+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS);
}
// // erste Spielernummer fr preflopRun() setzen
@@ -56,7 +57,7 @@ void LocalPreflop::preflopRun() {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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; }
}
@@ -65,7 +66,7 @@ void LocalPreflop::preflopRun() {
// BigBlind ermitteln
bigBlindPosition = dealerPosition;
while (myHand->getPlayerArray()[bigBlindPosition]->getMyButton() != 3) {
bigBlindPosition = (bigBlindPosition+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS);
}
// prfen, ob Preflop wirklich dran ist
@@ -76,7 +77,7 @@ void LocalPreflop::preflopRun() {
myHand->setActualRound(1);
//Action lchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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
@@ -97,7 +98,7 @@ void LocalPreflop::preflopRun() {
// nhsten Spieler ermitteln
do {
playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
// falls BigBlind, dann PreflopFirstRound zuende
if(myHand->getPlayerArray()[playersTurn]->getMyButton() == 3) preflopFirstRound = 0;
+17 -16
View File
@@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localriver.h"
#include <game_defs.h>
using namespace std;
@@ -27,7 +28,7 @@ LocalRiver::LocalRiver(HandInterface* bR, int id, int qP, int dP, int sB) : Rive
{ int i;
//SmallBlind-Position ermitteln
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
@@ -52,7 +53,7 @@ void LocalRiver::riverRun() {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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; }
@@ -70,7 +71,7 @@ void LocalRiver::riverRun() {
myHand->setActualRound(4);
//Action lᅵchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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
@@ -94,12 +95,12 @@ void LocalRiver::riverRun() {
}
// nᅵhsten Spieler ermitteln
do { playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
//Spieler-Position vor SmallBlind-Position ermitteln
int activePlayerBeforeSmallBlind = smallBlindPosition;
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + myHand->getGuiInterface()->getMaxQuantityPlayers() - 1 ) % (myHand->getGuiInterface()->getMaxQuantityPlayers());
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);
@@ -138,7 +139,7 @@ void LocalRiver::postRiverRun() {
// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl;
//berechnen welcher Spieler gewonnen hat
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
// cout << "Spieler: " << i << " hat: " << myHand->getPlayerArray()[i]->getMyCardsValueInt() << endl;
@@ -154,7 +155,7 @@ void LocalRiver::postRiverRun() {
// Aggressivität des human player ermitteln
// anzahl der player die möglichkeit haben am pot teilzuhaben
int potPlayers = 0;
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) {
potPlayers++;
}
@@ -202,14 +203,14 @@ void LocalRiver::distributePot() {
/////////////////////
// winnersArray erstellen -> hier werden die winner der jeweiligen Potverteilungsrunden eingetragen
int *winnersArray = new int[myHand->getGuiInterface()->getMaxQuantityPlayers()];
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[myHand->getGuiInterface()->getMaxQuantityPlayers()];
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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)
@@ -219,10 +220,10 @@ void LocalRiver::distributePot() {
}
// 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[myHand->getGuiInterface()->getMaxQuantityPlayers()];
int *cardsValueArray = new int[MAX_NUMBER_OF_PLAYERS];
int playerWantsPotCounter = 0;
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
// Standardwert
cardsValueArray[i] = 0;
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) {
@@ -255,7 +256,7 @@ void LocalRiver::distributePot() {
highestCardsValueTemp = 0;
// aktuellen highestCardsValueTemp berechnen, von denen die noch an der Potverteilung teilnehmen
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(cardsValueArray[i] > highestCardsValueTemp ) {
highestCardsValueTemp = myHand->getPlayerArray()[i]->getMyCardsValueInt();
}
@@ -264,7 +265,7 @@ void LocalRiver::distributePot() {
// 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<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(cardsValueArray[i] == highestCardsValueTemp ) {
winnersArray[winnersCounter] = i;
winnersCounter++;
@@ -291,7 +292,7 @@ void LocalRiver::distributePot() {
// else {
// alle Spieler nacheinander durchgehen und prfen von wem man wieviel Geld aus dem Pot bekommt
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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) {
@@ -371,7 +372,7 @@ void LocalRiver::distributePot() {
}
// alle Spieler nacheinander durchgehen und prfen von wem die Winner wieviel Geld aus dem Pot bekommen
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
// prfen ob Spieler i zu den Winnern gehᅵt
playerIsWinner = 0;
+6 -5
View File
@@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localturn.h"
#include <game_defs.h>
using namespace std;
@@ -27,7 +28,7 @@ LocalTurn::LocalTurn(HandInterface* bR, int id, int qP, int dP, int sB) : TurnIn
{ int i;
//SmallBlind-Position ermitteln
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
@@ -53,7 +54,7 @@ void LocalTurn::turnRun() {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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; }
@@ -71,7 +72,7 @@ void LocalTurn::turnRun() {
myHand->setActualRound(3);
//Action lchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
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
@@ -95,12 +96,12 @@ void LocalTurn::turnRun() {
}
// nhsten Spieler ermitteln
do { playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
//Spieler-Position vor SmallBlind-Position ermitteln
int activePlayerBeforeSmallBlind = smallBlindPosition;
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + myHand->getGuiInterface()->getMaxQuantityPlayers() - 1 ) % (myHand->getGuiInterface()->getMaxQuantityPlayers());
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);