Reformatting code using Kernighan & Ritchie style, tabs, tab width=4.

Command line: astyle --style=kr --indent=force-tab=4 --lineend=linux -n -r <file names>
This commit is contained in:
lotodore committed 2011-02-11 20:02:08 +00:00
1 parent 29dca1846e
commit 02518c67b2
232 files changed
+22743 -21044

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
//
// C++ Implementation: berointerface
//
// Description:
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
+3 -2
View File
@@ -23,11 +23,12 @@
#include <game_defs.h>
#include <engine_defs.h>
class BeRoInterface{
class BeRoInterface
{
public:
virtual ~BeRoInterface();
virtual GameState getMyBeRoID() const =0;
virtual void setCurrentPlayersTurnId(unsigned) =0;
+9 -8
View File
@@ -24,25 +24,26 @@
class HandInterface;
class BoardInterface {
class BoardInterface
{
public:
virtual ~BoardInterface();
//
//
virtual void setPlayerLists(PlayerList, PlayerList, PlayerList) =0;
//
//
virtual void setMyCards(int* theValue) =0;
virtual void getMyCards(int* theValue) =0;
//
//
virtual int getPot() const=0;
virtual void setPot(int theValue) =0;
virtual int getSets() const=0;
virtual void setSets(int theValue) =0;
virtual void setAllInCondition(bool theValue) =0;
virtual void setLastActionPlayer(unsigned theValue) =0;
//
virtual void setAllInCondition(bool theValue) =0;
virtual void setLastActionPlayer(unsigned theValue) =0;
//
virtual void collectSets() =0;
virtual void collectPot() =0;
+4 -3
View File
@@ -26,11 +26,12 @@
#include "berointerface.h"
#include "log.h"
class EngineFactory{
class EngineFactory
{
public:
virtual ~EngineFactory();
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp) =0;
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
+11 -10
View File
@@ -25,9 +25,10 @@
#include "playerinterface.h"
#include "berointerface.h"
class HandInterface{
class HandInterface
{
public:
virtual ~HandInterface();
virtual void start() = 0;
@@ -46,7 +47,7 @@ public:
virtual void setMyID(int theValue) =0;
virtual int getMyID() const =0;
virtual void setStartQuantityPlayers(int theValue) =0;
virtual int getStartQuantityPlayers() const =0;
@@ -84,13 +85,13 @@ protected:
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
friend class Game;
friend class LocalBeRo;
friend class LocalBeRoPreflop;
friend class LocalBeRoFlop;
friend class LocalBeRoTurn;
friend class LocalBeRoRiver;
friend class LocalBeRoPostRiver;
friend class Game;
friend class LocalBeRo;
friend class LocalBeRoPreflop;
friend class LocalBeRoFlop;
friend class LocalBeRoTurn;
friend class LocalBeRoRiver;
friend class LocalBeRoPostRiver;
};
#endif
+14 -17
View File
@@ -22,14 +22,12 @@
using namespace std;
struct RoundData
{
struct RoundData {
int hand;
double data[4];
};
static const RoundData PreflopValues[] =
{
static const RoundData PreflopValues[] = {
{ 0, { 0.392398, 0.276545, 0.212940, 0.178564 } },
{ 10, { 0.341141, 0.213735, 0.153802, 0.121123 } },
{ 11, { 0.374930, 0.252093, 0.194671, 0.161691 } },
@@ -201,8 +199,7 @@ static const RoundData PreflopValues[] =
{ 12120, { 0.855608, 0.736617, 0.642366, 0.562044 } }
};
static const RoundData FlopValues[] =
{
static const RoundData FlopValues[] = {
{ 106, { 0.160312, 0.078750, 0.048325, 0.033350 } },
{ 206, { 0.185012, 0.099666, 0.071425, 0.053450 } },
{ 306, { 0.199662, 0.115567, 0.081625, 0.067500 } },
@@ -839,14 +836,12 @@ static const RoundData FlopValues[] =
{ 71212, { 0.751687, 0.628100, 0.560100, 0.516900 } }
};
struct calcHandsData
{
struct calcHandsData {
int hand;
int data[10][2];
};
static const calcHandsData handChancePreflop[] =
{
static const calcHandsData handChancePreflop[] = {
{ 0, { { 0,0}, { 36,1}, { 40,1}, { 12,1}, { 1,1}, { 2,1}, { 9,1}, { 1,1}, { 0,1}, { 0,1} } },
{ 10, { { 19,1}, { 45,1}, { 23,1}, { 4,1}, { 5,1}, { 2,1}, { 2,1}, { 0,1}, { 0,1}, { 0,1} } },
{ 11, { { 18,1}, { 42,1}, { 22,1}, { 4,1}, { 5,1}, { 6,1}, { 2,1}, { 0,1}, { 0,1}, { 0,1} } },
@@ -1030,15 +1025,16 @@ ArrayData::~ArrayData()
{
}
void ArrayData::getHandChancePreflop(int handCode, int** values) {
void ArrayData::getHandChancePreflop(int handCode, int** values)
{
int check = -1;
for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) {
if(handCode == handChancePreflop[val].hand) {
check = 1;
for(int i=0;i<10;i++) {
for(int j=0;j<2;j++) {
for(int i=0; i<10; i++) {
for(int j=0; j<2; j++) {
values[i][j] = handChancePreflop[val].data[i][j];
}
}
@@ -1049,7 +1045,8 @@ void ArrayData::getHandChancePreflop(int handCode, int** values) {
}
vector< vector<int> > ArrayData::getHandChancePreflop(int handCode) {
vector< vector<int> > ArrayData::getHandChancePreflop(int handCode)
{
int check = -1;
@@ -1060,7 +1057,7 @@ vector< vector<int> > ArrayData::getHandChancePreflop(int handCode) {
chance[0].resize(10);
chance[1].resize(10);
for(i=0;i<10;i++) {
for(i=0; i<10; i++) {
chance[0][i] = 0;
chance[1][i] = 0;
}
@@ -1068,8 +1065,8 @@ vector< vector<int> > ArrayData::getHandChancePreflop(int handCode) {
for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) {
if(handCode == handChancePreflop[val].hand) {
check = 1;
for(int i=0;i<10;i++) {
for(int j=0;j<2;j++) {
for(int i=0; i<10; i++) {
for(int j=0; j<2; j++) {
chance[j][i] = handChancePreflop[val].data[i][j];
}
}
+4 -3
View File
@@ -24,11 +24,12 @@
#include<vector>
class ArrayData{
class ArrayData
{
public:
ArrayData();
ArrayData();
~ArrayData();
~ArrayData();
void getHandChancePreflop(int, int**);
std::vector< std::vector<int> > getHandChancePreflop(int);
+253 -198
View File
@@ -30,143 +30,192 @@ CardsValue::~CardsValue()
{
}
int CardsValue::holeCardsClass(int one, int two) const {
int CardsValue::holeCardsClass(int one, int two) const
{
if((one-1)%13<(two-1)%13) {
int temp = one;
one = two;
two = temp;
}
if((one-1)%13<(two-1)%13) {
int temp = one;
one = two;
two = temp;
}
if((one-1)%13 == (two-1)%13) {
if((one-1)%13+2 > 10) return 10;
else {
switch((one-1)%13+2) {
case 10: return 9;
case 9: return 8;
case 8: return 7;
case 7: return 6;
default: return 5;
}
}
}
switch((one-1)%13+2) {
//Ass
case 14: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1: return 10;
case 2: return 9;
case 3: return 9;
case 4: return 8;
default: return 7;
}
}
else {
switch((one-1)%13-(two-1)%13) {
case 1: return 9;
case 2: return 8;
case 3: return 7;
case 4: return 7;
default: return 4;
}
}
} break;
//K�ig
case 13: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1: return 9;
case 2: return 8;
case 3: return 8;
case 4: return 6;
default: return 5;
}
}
else {
switch((one-1)%13-(two-1)%13) {
case 1: return 7;
case 2: return 6;
case 3: return 6;
default: return 4;
}
}
} break;
//Dame
case 12: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1: return 8;
case 2: return 7;
case 3: return 6;
case 4: return 5;
default: return 4;
}
}
else {
switch((one-1)%13-(two-1)%13) {
case 1: return 6;
case 2: return 6;
case 3: return 4;
default: return 3;
}
}
} break;
//Bube
case 11: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1: return 7;
case 2: return 6;
case 3: return 5;
case 4: return 4;
default: return 3;
}
}
else {
switch((one-1)%13-(two-1)%13) {
case 1: return 6;
case 2: return 5;
case 3: return 4;
default: return 2;
}
}
} break;
//10
case 10: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1: return 6;
case 2: return 5;
default: return 2;
}
}
else {
switch((one-1)%13-(two-1)%13) {
case 1: return 5;
case 2: return 4;
default: return 1;
}
}
} break;
//Rest
default: {
if((one-1)%13 - (two-1)%13 <= 2) {
if((one-1)/13 == (two-1)/13) return 5;
else return 3;
}
else {
if((one-1)%13 - (two-1)%13 == 3) return 2;
else return 1;
}
}
}
if((one-1)%13 == (two-1)%13) {
if((one-1)%13+2 > 10) return 10;
else {
switch((one-1)%13+2) {
case 10:
return 9;
case 9:
return 8;
case 8:
return 7;
case 7:
return 6;
default:
return 5;
}
}
}
switch((one-1)%13+2) {
//Ass
case 14: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1:
return 10;
case 2:
return 9;
case 3:
return 9;
case 4:
return 8;
default:
return 7;
}
} else {
switch((one-1)%13-(two-1)%13) {
case 1:
return 9;
case 2:
return 8;
case 3:
return 7;
case 4:
return 7;
default:
return 4;
}
}
}
break;
//K�ig
case 13: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1:
return 9;
case 2:
return 8;
case 3:
return 8;
case 4:
return 6;
default:
return 5;
}
} else {
switch((one-1)%13-(two-1)%13) {
case 1:
return 7;
case 2:
return 6;
case 3:
return 6;
default:
return 4;
}
}
}
break;
//Dame
case 12: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1:
return 8;
case 2:
return 7;
case 3:
return 6;
case 4:
return 5;
default:
return 4;
}
} else {
switch((one-1)%13-(two-1)%13) {
case 1:
return 6;
case 2:
return 6;
case 3:
return 4;
default:
return 3;
}
}
}
break;
//Bube
case 11: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1:
return 7;
case 2:
return 6;
case 3:
return 5;
case 4:
return 4;
default:
return 3;
}
} else {
switch((one-1)%13-(two-1)%13) {
case 1:
return 6;
case 2:
return 5;
case 3:
return 4;
default:
return 2;
}
}
}
break;
//10
case 10: {
if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) {
case 1:
return 6;
case 2:
return 5;
default:
return 2;
}
} else {
switch((one-1)%13-(two-1)%13) {
case 1:
return 5;
case 2:
return 4;
default:
return 1;
}
}
}
break;
//Rest
default: {
if((one-1)%13 - (two-1)%13 <= 2) {
if((one-1)/13 == (two-1)/13) return 5;
else return 3;
} else {
if((one-1)%13 - (two-1)%13 == 3) return 2;
else return 1;
}
}
}
}
int CardsValue::holeCardsToIntCode(int* cards) const {
int CardsValue::holeCardsToIntCode(int* cards) const
{
// Code der HoleCards ermitteln
if(cards[0]%13 == cards[1]%13) {
@@ -189,7 +238,8 @@ int CardsValue::holeCardsToIntCode(int* cards) const {
}
int* CardsValue::intCodeToHoleCards(int code) const {
int* CardsValue::intCodeToHoleCards(int code) const
{
// one possibility !!!
@@ -198,8 +248,9 @@ int* CardsValue::intCodeToHoleCards(int code) const {
cards[0] = code/1000;
cards[1] = (code-cards[0]*1000)/10;
if(cards[0]==cards[1]) { cards[1] +=13; }
else {
if(cards[0]==cards[1]) {
cards[1] +=13;
} else {
if(code%10 == 0) cards[1] +=13;
}
@@ -207,9 +258,10 @@ int* CardsValue::intCodeToHoleCards(int code) const {
}
int CardsValue::cardsValue(int* cards, int* position) const {
int CardsValue::cardsValue(int* cards, int* position) const
{
int array[7][3];
int array[7][3];
int j1, j2, j3, j4, j5, k1, k2, ktemp[3];
// Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] )
@@ -360,7 +412,7 @@ int array[7][3];
for(j1=0; j1<4; j1++) {
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1] && array[j1][1] == array[j1+3][1]) {
// Position des Kickers ermitteln und der Blattwertung als dritte Gewichtung hinzuaddieren
if(j1==0) {
if(j1==0) {
if(position) {
// Position-Array fuellen
for(j2=0; j2<5; j2++) {
@@ -368,8 +420,7 @@ int array[7][3];
}
}
return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000;
}
else {
} else {
if(position) {
// Position-Array fuellen
for(j2=0; j2<4; j2++) {
@@ -414,8 +465,13 @@ int array[7][3];
position[4] = array[j5][2];
}
// Paar und Drilling des Full House ermitteln ermitteln
if(array[j3][1]==array[j1][1]) { drei = array[j1][1]; zwei = array[j4][1]; }
else { drei = array[j4][1]; zwei = array[j1][1]; }
if(array[j3][1]==array[j1][1]) {
drei = array[j1][1];
zwei = array[j4][1];
} else {
drei = array[j4][1];
zwei = array[j1][1];
}
return 600000000+drei*1000000+zwei*10000;
}
}
@@ -454,26 +510,24 @@ int array[7][3];
if(j1==0) {
if(position) {
// Position-Array fuellen
for(j2=0; j2<5;j2++) {
for(j2=0; j2<5; j2++) {
position[j2] = array[j2][2];
}
}
return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100;
}
else {
} else {
if(j1==1) {
if(position) {
// Position-Array fuellen
for(j2=0; j2<5;j2++) {
for(j2=0; j2<5; j2++) {
position[j2] = array[j2][2];
}
}
return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100;
}
else {
} else {
if(position) {
// Position-Array fuellen
for(j2=0; j2<3;j2++) {
for(j2=0; j2<3; j2++) {
position[j2] = array[j1+j2][2];
}
position[3] = array[0][2];
@@ -498,30 +552,28 @@ int array[7][3];
position[1] = array[j1+1][2];
position[2] = array[j2][2];
position[3] = array[j2+1][2];
position[4] = array[j2+2][2];
position[4] = array[j2+2][2];
}
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j2+2][1]*100;
}
else {
} else {
if(position) {
// Position-Array fuellen
position[0] = array[j1][2];
position[1] = array[j1+1][2];
position[2] = array[j2][2];
position[3] = array[j2+1][2];
position[4] = array[j1+2][2];
position[4] = array[j1+2][2];
}
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100;
}
}
else {
} else {
if(position) {
// Position-Array fuellen
position[0] = array[j1][2];
position[1] = array[j1+1][2];
position[2] = array[j2][2];
position[3] = array[j2+1][2];
position[4] = array[0][2];
position[4] = array[0][2];
}
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[0][1]*100;
}
@@ -559,8 +611,7 @@ int array[7][3];
}
}
return 100000000+array[j1][1]*1000000+array[j1-2][1]*10000+array[j1-1][1]*100+array[j1+2][1];
}
else {
} else {
if(position) {
// Position-Array fuellen
for(j2=0; j2<2; j2++) {
@@ -595,7 +646,7 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
chance[0].resize(10);
chance[1].resize(10);
for(i=0;i<10;i++) {
for(i=0; i<10; i++) {
chance[0][i] = 0;
chance[1][i] = 0;
}
@@ -605,22 +656,23 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
cards[0] = playerCards[0];
cards[1] = playerCards[1];
for(i=0;i<5;i++) cards[i+2] = boardCards[i];
for(i=0; i<5; i++) cards[i+2] = boardCards[i];
switch(beRoID) {
case GAME_STATE_PREFLOP: {
ArrayData* myArrayData = new ArrayData;
case GAME_STATE_PREFLOP: {
ArrayData* myArrayData = new ArrayData;
chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards));
chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards));
delete myArrayData;
delete myArrayData;
} break;
case GAME_STATE_FLOP: {
}
break;
case GAME_STATE_FLOP: {
for(i=0;i<51;i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) {
for(j=i+1;j<52;j++) {
for(i=0; i<51; i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) {
for(j=i+1; j<52; j++) {
if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) {
cards[5] = i;
cards[6] = j;
@@ -628,35 +680,38 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
sum++;
}
}
}
}
for(i=0;i<10;i++) {
if(chance[0][i] > 0) chance[1][i] = 1;
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
}
} break;
case GAME_STATE_TURN: {
for(i=0;i<52;i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) {
cards[6] = i;
(chance[0][cardsValue(cards,0)/100000000])++;
sum++;
}
}
for(i=0;i<10;i++) {
if(chance[0][i] > 0) chance[1][i] = 1;
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
}
} break;
case GAME_STATE_RIVER: {
chance[0][cardsValue(cards,0)/100000000] = 100;
chance[1][cardsValue(cards,0)/100000000] = 1;
} break;
default: {
}
for(i=0; i<10; i++) {
if(chance[0][i] > 0) chance[1][i] = 1;
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
}
}
break;
case GAME_STATE_TURN: {
for(i=0; i<52; i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) {
cards[6] = i;
(chance[0][cardsValue(cards,0)/100000000])++;
sum++;
}
}
for(i=0; i<10; i++) {
if(chance[0][i] > 0) chance[1][i] = 1;
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
}
}
break;
case GAME_STATE_RIVER: {
chance[0][cardsValue(cards,0)/100000000] = 100;
chance[1][cardsValue(cards,0)/100000000] = 1;
}
break;
default: {
}
}
return chance;
@@ -665,18 +720,18 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
//int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
//
// int i,j;
//
//
// int** chance = new int*[2];
//
//
// for(i=0;i<10;i++) {
// chance[i] = new int[2];
// for(j=0;j<2;j++) {
// chance[i][j] = 0;
// }
// }
//
//
// int rand[5];
//
//
// return chance;
//
//}
+10 -9
View File
@@ -28,20 +28,21 @@
class CardsValue{
class CardsValue
{
public:
CardsValue();
CardsValue();
~CardsValue();
~CardsValue();
int holeCardsClass(int, int) const;
int cardsValue(int*, int*) const;
int holeCardsClass(int, int) const;
int cardsValue(int*, int*) const;
int holeCardsToIntCode(int*) const;
int* intCodeToHoleCards(int) const;
int holeCardsToIntCode(int*) const;
int* intCodeToHoleCards(int) const;
std::vector< std::vector<int> > calcCardsChance(GameState, int*, int*) const;
//int** showdown(GameState, int**, int);
std::vector< std::vector<int> > calcCardsChance(GameState, int*, int*) const;
//int** showdown(GameState, int**, int);
};
+33 -27
View File
@@ -26,7 +26,7 @@
using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
{
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
@@ -68,7 +68,8 @@ int LocalBeRo::getHighestCardsValue() const
return 0;
}
void LocalBeRo::nextPlayer() {
void LocalBeRo::nextPlayer()
{
PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId);
if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) {
@@ -79,37 +80,37 @@ void LocalBeRo::nextPlayer() {
}
void LocalBeRo::run() {
void LocalBeRo::run()
{
if(firstRunGui) {
firstRunGui = false;
myHand->setLastPlayersTurn(-1);
myHand->getGuiInterface()->dealBeRoCards(myBeRoID);
}
else {
} else {
if(firstRun) {
firstRun = false;
if(!(myHand->getAllInCondition())) {
PlayerListIterator it_1, it_2;
// running player before smallBlind
bool formerRunningPlayerFound = false;
if(myHand->getActivePlayerList()->size() > 2) {
it_1 = myHand->getActivePlayerIt(smallBlindPositionId);
if(it_1 == myHand->getActivePlayerList()->end()) {
throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND);
}
for(size_t i=0; i<myHand->getActivePlayerList()->size(); i++) {
if(it_1 == myHand->getActivePlayerList()->begin()) it_1 = myHand->getActivePlayerList()->end();
--it_1;
it_2 = myHand->getRunningPlayerIt((*it_1)->getMyUniqueID());
// running player found
if(it_2 != myHand->getRunningPlayerList()->end()) {
@@ -125,7 +126,7 @@ void LocalBeRo::run() {
// heads up: bigBlind begins -> dealer/smallBlind is running player before bigBlind
else {
firstRoundLastPlayersTurnId = smallBlindPositionId;
}
}
currentPlayersTurnId = firstRoundLastPlayersTurnId;
}
}
@@ -138,13 +139,18 @@ void LocalBeRo::run() {
myHand->getBoard()->getMyCards(tempBoardCardsArray);
switch(myBeRoID) {
case GAME_STATE_FLOP: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
case GAME_STATE_FLOP:
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
break;
case GAME_STATE_TURN: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
case GAME_STATE_TURN:
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
break;
case GAME_STATE_RIVER: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
case GAME_STATE_RIVER:
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
break;
default: { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID"); }
default: {
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID");
}
}
logBoardCardsDone = true;
@@ -165,8 +171,8 @@ void LocalBeRo::run() {
}
// prfen, ob aktuelle bero wirklich dran ist
if(!firstRound && allHighestSet) {
if(!firstRound && allHighestSet) {
// aktuelle bero nicht dran, weil alle Sets gleich sind
//also gehe in naechste bero
myHand->setCurrentRound(myBeRoID+1);
@@ -180,14 +186,15 @@ void LocalBeRo::run() {
myHand->getBoard()->collectSets();
myHand->getBoard()->collectPot();
myHand->getGuiInterface()->refreshPot();
myHand->getGuiInterface()->refreshSet();
myHand->getGuiInterface()->refreshCash();
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { myHand->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
myHand->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE);
}
myHand->switchRounds();
}
else {
} else {
// aktuelle bero ist wirklich dran
// Anzahl der effektiv gespielten Runden (des human player) erhöhen
@@ -204,10 +211,10 @@ void LocalBeRo::run() {
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) {
throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND);
}
++currentPlayersTurnIt;
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
currentPlayersTurnId = (*currentPlayersTurnIt)->getMyUniqueID();
//highlight active players groupbox and clear action
@@ -229,8 +236,7 @@ void LocalBeRo::run() {
if( currentPlayersTurnId == 0) {
// Wir sind dran
myHand->getGuiInterface()->meInAction();
}
else {
} else {
//Gegner sind dran
myHand->getGuiInterface()->beRoAnimation2(myBeRoID);
+105 -38
View File
@@ -26,75 +26,142 @@
#include "berointerface.h"
#include "handinterface.h"
class LocalBeRo : public BeRoInterface{
class LocalBeRo : public BeRoInterface
{
public:
LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
~LocalBeRo();
GameState getMyBeRoID() const { return myBeRoID; }
GameState getMyBeRoID() const {
return myBeRoID;
}
int getHighestCardsValue() const;
void setHighestCardsValue(int /*theValue*/) { }
void setMinimumRaise ( int theValue ) { minimumRaise = theValue; }
int getMinimumRaise() const { return minimumRaise; }
void setMinimumRaise ( int theValue ) {
minimumRaise = theValue;
}
int getMinimumRaise() const {
return minimumRaise;
}
void setFullBetRule ( bool theValue ) { fullBetRule = theValue; }
bool getFullBetRule() const { return fullBetRule; }
void setFullBetRule ( bool theValue ) {
fullBetRule = theValue;
}
bool getFullBetRule() const {
return fullBetRule;
}
void skipFirstRunGui() { firstRunGui = false; }
void skipFirstRunGui() {
firstRunGui = false;
}
void nextPlayer();
void run();
void postRiverRun() {};
protected:
HandInterface* getMyHand() const { return myHand; }
HandInterface* getMyHand() const {
return myHand;
}
int getDealerPosition() const {return dealerPosition; }
void setDealerPosition(int theValue) { dealerPosition = theValue; }
int getDealerPosition() const {
return dealerPosition;
}
void setDealerPosition(int theValue) {
dealerPosition = theValue;
}
void setCurrentPlayersTurnId(unsigned theValue) { currentPlayersTurnId = theValue; }
unsigned getCurrentPlayersTurnId() const { return currentPlayersTurnId;}
void setCurrentPlayersTurnId(unsigned theValue) {
currentPlayersTurnId = theValue;
}
unsigned getCurrentPlayersTurnId() const {
return currentPlayersTurnId;
}
void setFirstRoundLastPlayersTurnId(unsigned theValue) { firstRoundLastPlayersTurnId = theValue; }
unsigned getFirstRoundLastPlayersTurnId() const { return firstRoundLastPlayersTurnId;}
void setFirstRoundLastPlayersTurnId(unsigned theValue) {
firstRoundLastPlayersTurnId = theValue;
}
unsigned getFirstRoundLastPlayersTurnId() const {
return firstRoundLastPlayersTurnId;
}
void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; }
PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; }
void setCurrentPlayersTurnIt(PlayerListIterator theValue) {
currentPlayersTurnIt = theValue;
}
PlayerListIterator getCurrentPlayersTurnIt() const {
return currentPlayersTurnIt;
}
void setLastPlayersTurnIt(PlayerListIterator theValue) { lastPlayersTurnIt = theValue; }
PlayerListIterator getLastPlayersTurnIt() const { return lastPlayersTurnIt; }
void setHighestSet(int theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setLastPlayersTurnIt(PlayerListIterator theValue) {
lastPlayersTurnIt = theValue;
}
PlayerListIterator getLastPlayersTurnIt() const {
return lastPlayersTurnIt;
}
void setFirstRun(bool theValue) { firstRun = theValue;}
bool getFirstRun() const { return firstRun;}
void setHighestSet(int theValue) {
highestSet = theValue;
}
int getHighestSet() const {
return highestSet;
}
void setFirstRound(bool theValue) { firstRound = theValue;}
bool getFirstRound() const { return firstRound;}
void setFirstRun(bool theValue) {
firstRun = theValue;
}
bool getFirstRun() const {
return firstRun;
}
void setFirstRound(bool theValue) {
firstRound = theValue;
}
bool getFirstRound() const {
return firstRound;
}
void setDealerPositionId(unsigned theValue) { dealerPositionId = theValue;}
unsigned getDealerPositionId() const { return dealerPositionId; }
void setDealerPositionId(unsigned theValue) {
dealerPositionId = theValue;
}
unsigned getDealerPositionId() const {
return dealerPositionId;
}
void setSmallBlindPositionId(unsigned theValue) { smallBlindPositionId = theValue;}
unsigned getSmallBlindPositionId() const { return smallBlindPositionId; }
void setSmallBlindPositionId(unsigned theValue) {
smallBlindPositionId = theValue;
}
unsigned getSmallBlindPositionId() const {
return smallBlindPositionId;
}
void setBigBlindPositionId(unsigned theValue) { bigBlindPositionId = theValue;}
unsigned getBigBlindPositionId() const { return bigBlindPositionId; }
void setBigBlindPositionId(unsigned theValue) {
bigBlindPositionId = theValue;
}
unsigned getBigBlindPositionId() const {
return bigBlindPositionId;
}
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setSmallBlindPosition(int theValue) {
smallBlindPosition = theValue;
}
int getSmallBlindPosition() const {
return smallBlindPosition;
}
void setSmallBlind(int theValue) {
smallBlind = theValue;
}
int getSmallBlind() const {
return smallBlind;
}
void setSmallBlind(int theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
@@ -115,7 +182,7 @@ private:
int smallBlind;
int highestSet;
int minimumRaise;
bool fullBetRule;
bool fullBetRule;
bool firstRun;
bool firstRunGui; // HACK
+2 -1
View File
@@ -25,7 +25,8 @@
class HandInterface;
class LocalBeRoFlop : public LocalBeRo{
class LocalBeRoFlop : public LocalBeRo
{
public:
LocalBeRoFlop(HandInterface*, int, unsigned, int);
@@ -33,10 +33,12 @@ LocalBeRoPostRiver::~LocalBeRoPostRiver()
{
}
void LocalBeRoPostRiver::run() {
void LocalBeRoPostRiver::run()
{
}
void LocalBeRoPostRiver::postRiverRun() {
void LocalBeRoPostRiver::postRiverRun()
{
PlayerListConstIterator it_c;
PlayerListIterator it;
@@ -44,8 +46,8 @@ void LocalBeRoPostRiver::postRiverRun() {
// who is the winner
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() > highestCardsValue ) {
highestCardsValue = (*it_c)->getMyCardsValueInt();
if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() > highestCardsValue ) {
highestCardsValue = (*it_c)->getMyCardsValueInt();
}
}
@@ -83,5 +85,5 @@ void LocalBeRoPostRiver::postRiverRun() {
getMyHand()->getBoard()->setPot(0);
//starte die Animaionsreihe
getMyHand()->getGuiInterface()->postRiverRunAnimation1();
getMyHand()->getGuiInterface()->postRiverRunAnimation1();
}
+8 -3
View File
@@ -26,13 +26,18 @@
class HandInterface;
class LocalBeRoPostRiver : public LocalBeRo{
class LocalBeRoPostRiver : public LocalBeRo
{
public:
LocalBeRoPostRiver(HandInterface*, int, int, int);
~LocalBeRoPostRiver();
void setHighestCardsValue(int theValue) { highestCardsValue = theValue;}
int getHighestCardsValue() const { return highestCardsValue;}
void setHighestCardsValue(int theValue) {
highestCardsValue = theValue;
}
int getHighestCardsValue() const {
return highestCardsValue;
}
void run();
+29 -28
View File
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *Irische Segenswnsche,
* f.thauer@web.de *Irische Segenswnsche,
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -38,37 +38,38 @@ LocalBeRoPreflop::~LocalBeRoPreflop()
{
}
void LocalBeRoPreflop::run() {
void LocalBeRoPreflop::run()
{
if(getFirstRun()) {
PlayerListIterator it;
// search bigBlindPosition in runningPlayerList
PlayerListIterator bigBlindPositionIt = getMyHand()->getRunningPlayerIt(getBigBlindPositionId());
// more than 2 players are still active -> runningPlayerList is not empty
if(getMyHand()->getActivePlayerList()->size() > 2) {
// bigBlindPlayer not found in runningPlayerList (he is all in) -> bigBlindPlayer is not the running player before first action player
if(bigBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
// search smallBlindPosition in runningPlayerList
PlayerListIterator smallBlindPositionIt = getMyHand()->getRunningPlayerIt(getSmallBlindPositionId());
// smallBlindPlayer not found in runningPlayerList (he is all in) -> next active player before smallBlindPlayer is running player before first action player
if(smallBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
it = getMyHand()->getActivePlayerIt(getSmallBlindPositionId());
if(it == getMyHand()->getActivePlayerList()->end()) {
throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND);
}
if(it == getMyHand()->getActivePlayerList()->begin()) it = getMyHand()->getActivePlayerList()->end();
--it;
setFirstRoundLastPlayersTurnId( (*it)->getMyUniqueID() );
}
// smallBlindPlayer found in runningPlayerList -> running player before first action player
else {
@@ -82,30 +83,30 @@ void LocalBeRoPreflop::run() {
}
// heads up -> dealer/smallBlindPlayer is first action player and bigBlindPlayer is player before
else {
// bigBlindPlayer not found in runningPlayerList (he is all in) -> only smallBlind has to choose fold or call the bigBlindAmount
if(bigBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
// search smallBlindPosition in runningPlayerList
PlayerListIterator smallBlindPositionIt = getMyHand()->getRunningPlayerIt(getSmallBlindPositionId());
// smallBlindPlayer not found in runningPlayerList (he is all in) -> no running player -> showdown and no firstRoundLastPlayersTurnId is used
if(smallBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
}
// smallBlindPlayer found in runningPlayerList -> running player before first action player (himself)
else {
setFirstRoundLastPlayersTurnId( getSmallBlindPositionId() );
}
} else {
setFirstRoundLastPlayersTurnId( getBigBlindPositionId() );
}
}
setCurrentPlayersTurnId( getFirstRoundLastPlayersTurnId() );
setFirstRun(false);
}
@@ -131,9 +132,9 @@ void LocalBeRoPreflop::run() {
if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) currentPlayersTurnIt = getMyHand()->getRunningPlayerList()->begin();
setCurrentPlayersTurnId( (*currentPlayersTurnIt)->getMyUniqueID() );
// prfen, ob Preflop wirklich dran ist
if(!getFirstRound() && allHighestSet) {
if(!getFirstRound() && allHighestSet) {
// Preflop nicht dran, weil wir nicht mehr in erster PreflopRunde und alle Sets gleich sind
//also gehe in Flop
@@ -148,14 +149,15 @@ void LocalBeRoPreflop::run() {
getMyHand()->getBoard()->collectSets();
getMyHand()->getBoard()->collectPot();
getMyHand()->getGuiInterface()->refreshPot();
getMyHand()->getGuiInterface()->refreshSet();
getMyHand()->getGuiInterface()->refreshCash();
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { getMyHand()->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
getMyHand()->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE);
}
getMyHand()->switchRounds();
}
else {
} else {
// lastPlayersTurn -> PreflopFirstRound is over
if( getCurrentPlayersTurnId() == getFirstRoundLastPlayersTurnId() ) {
setFirstRound(false);
@@ -175,8 +177,7 @@ void LocalBeRoPreflop::run() {
if( getCurrentPlayersTurnId() == 0) {
// Wir sind dran
getMyHand()->getGuiInterface()->meInAction();
}
else {
} else {
//Gegner sind dran
getMyHand()->getGuiInterface()->beRoAnimation2(getMyBeRoID());
}
+3 -2
View File
@@ -25,8 +25,9 @@
class HandInterface;
class LocalBeRoPreflop : public LocalBeRo{
class LocalBeRoPreflop : public LocalBeRo
{
public:
LocalBeRoPreflop(HandInterface*, int, unsigned, int);
~LocalBeRoPreflop();
+2 -1
View File
@@ -26,7 +26,8 @@
class HandInterface;
class LocalBeRoRiver : public LocalBeRo{
class LocalBeRoRiver : public LocalBeRo
{
public:
LocalBeRoRiver(HandInterface*, int, unsigned, int);
~LocalBeRoRiver();
+2 -1
View File
@@ -25,7 +25,8 @@
class HandInterface;
class LocalBeRoTurn : public LocalBeRo{
class LocalBeRoTurn : public LocalBeRo
{
public:
LocalBeRoTurn(HandInterface*, int, unsigned, int);
~LocalBeRoTurn();
+155 -150
View File
@@ -36,13 +36,15 @@ LocalBoard::~LocalBoard()
{
}
void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl) {
void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl)
{
seatsList = sl;
activePlayerList = apl;
runningPlayerList = rpl;
}
void LocalBoard::collectSets() {
void LocalBoard::collectSets()
{
sets = 0;
@@ -53,9 +55,10 @@ void LocalBoard::collectSets() {
}
void LocalBoard::collectPot() {
void LocalBoard::collectPot()
{
pot += sets;
pot += sets;
sets = 0;
PlayerListIterator it;
@@ -65,7 +68,8 @@ void LocalBoard::collectPot() {
}
void LocalBoard::distributePot() {
void LocalBoard::distributePot()
{
winners.clear();
@@ -115,8 +119,8 @@ void LocalBoard::distributePot() {
// determine level highestCardsValue
for(it_c=seatsList->begin(), j=0; it_c!=seatsList->end(); ++it_c,j++) {
if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
highestCardsValue = (*it_c)->getMyCardsValueInt();
if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
highestCardsValue = (*it_c)->getMyCardsValueInt();
}
}
@@ -139,12 +143,12 @@ void LocalBoard::distributePot() {
if(mod == 0) {
for(j=2; j<potLevel.size(); j++) {
// find seat with potLevel[j]-ID
// find seat with potLevel[j]-ID
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
if((*it)->getMyUniqueID() == potLevel[j]) {
break;
}
}
if((*it)->getMyUniqueID() == potLevel[j]) {
break;
}
}
if(it == seatsList->end()) {
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
}
@@ -162,13 +166,13 @@ void LocalBoard::distributePot() {
// winnerPointer = currentHand->getDealerPosition();
// find Seat with dealerPosition
// find Seat with dealerPosition
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
if((*it)->getMyUniqueID() == dealerPosition) {
break;
}
}
if(it == seatsList->end()) {
if((*it)->getMyUniqueID() == dealerPosition) {
break;
}
}
if(it == seatsList->end()) {
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
}
@@ -176,7 +180,7 @@ void LocalBoard::distributePot() {
winnerHit = false;
for(k=0; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++){
for(k=0; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++) {
// winnerPointer = (winnerPointer+1)%(MAX_NUMBER_OF_PLAYERS);
@@ -231,7 +235,7 @@ void LocalBoard::distributePot() {
}
}
// winners sort and unique
// winners sort and unique
winners.sort();
winners.unique();
@@ -247,195 +251,196 @@ void LocalBoard::distributePot() {
}*/
}
void LocalBoard::determinePlayerNeedToShowCards() {
void LocalBoard::determinePlayerNeedToShowCards()
{
playerNeedToShowCards.clear();
playerNeedToShowCards.clear();
// in All In Condition everybody have to show the cards
if(allInCondition) {
// in All In Condition everybody have to show the cards
if(allInCondition) {
PlayerListConstIterator it_c;
PlayerListConstIterator it_c;
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
}
}
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
}
}
}
}
else {
else {
// all winners have to show their cards
// playerNeedToShowCards = winners;
// all winners have to show their cards
// playerNeedToShowCards = winners;
// std::_List_const_iterator<unsigned> it_c;
// std::_List_const_iterator<unsigned> it_c;
std::list<int*> level;
std::list<int*> level;
// for(it_c=winners.begin(); it_c != winners.end(); it_c++) {
// cout << (*it_c) << endl;
// }
//
// cout << "lastActionPlayer" << currentHand->getCurrentBeRo()->getLastActionPlayer() << endl;
//
// int lastActionPlayer = ;
//
// if(lastActionPlayer == -1) {
// lastActionPlayer = 0;
// }
//
//
//
// for(it_c=winners.begin(); it_c != winners.end(); it_c++) {
// cout << (*it_c) << endl;
// }
//
// cout << "lastActionPlayer" << currentHand->getCurrentBeRo()->getLastActionPlayer() << endl;
//
// int lastActionPlayer = ;
//
// if(lastActionPlayer == -1) {
// lastActionPlayer = 0;
// }
//
//
//
PlayerListConstIterator lastActionPlayerIt;
PlayerListConstIterator it_c;
PlayerListConstIterator lastActionPlayerIt;
PlayerListConstIterator it_c;
// cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl;
// search lastActionPlayer
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
if((*it_c)->getMyUniqueID() == lastActionPlayer && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
// cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl;
// search lastActionPlayer
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
if((*it_c)->getMyUniqueID() == lastActionPlayer && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
// cout << (*it_c)->getMyUniqueID() << endl;
break;
}
}
break;
}
}
if(it_c == activePlayerList->end()) {
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
break;
}
}
}
if(it_c == activePlayerList->end()) {
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
break;
}
}
}
// the player who has done the last action has to show his cards first
playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID());
// the player who has done the last action has to show his cards first
playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID());
// cout << (*lastActionPlayerIt)->getMyUniqueID() << " - " << (*lastActionPlayerIt)->getMyName() << endl;
int *level_tmp = new int[2];
// get position und cardsValue of the player who show his cards first
level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt();
level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash();
int *level_tmp = new int[2];
// get position und cardsValue of the player who show his cards first
level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt();
level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash();
// level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()};
// level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()};
// cout << level_tmp[0] << "," << level_tmp[1] << endl;
level.push_back(level_tmp);
level.push_back(level_tmp);
std::_List_iterator<int*> level_it;
std::_List_iterator<int*> level_it_tmp;
std::_List_iterator<int*> next_level_it;
std::_List_iterator<int*> level_it;
std::_List_iterator<int*> level_it_tmp;
std::_List_iterator<int*> next_level_it;
// PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt;
// firstAfterLastActionPlayerIt++;
// PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt;
// firstAfterLastActionPlayerIt++;
it_c = lastActionPlayerIt;
++it_c;
it_c = lastActionPlayerIt;
++it_c;
for(unsigned i = 0; i < activePlayerList->size(); i++) {
for(unsigned i = 0; i < activePlayerList->size(); i++) {
if(it_c == activePlayerList->end()) it_c = activePlayerList->begin();
if(it_c == activePlayerList->end()) it_c = activePlayerList->begin();
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
// for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) {
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
// for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) {
// if(it_c == lastActionPlayerIt) {
// break;
// }
// }
for(level_it = level.begin(); level_it != level.end(); level_it++) {
if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
if(next_level_it == level.end()) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
level_tmp = new int[2];
level_tmp[0] = (*it_c)->getMyCardsValueInt();
level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
level.push_back(level_tmp);
break;
}
} else {
if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
// if(it_c == lastActionPlayerIt) {
// break;
// }
// }
for(level_it = level.begin(); level_it != level.end(); level_it++) {
if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
if(next_level_it == level.end()) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
level_tmp = new int[2];
level_tmp[0] = (*it_c)->getMyCardsValueInt();
level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
level.push_back(level_tmp);
break;
}
} else {
if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
//
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
// }
if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
(*level_it)[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
}
}
break;
} else {
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
level_tmp = new int(2);
level_tmp[0] = (*it_c)->getMyCardsValueInt();
level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
(*level_it)[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
}
}
break;
} else {
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
level_tmp = new int(2);
level_tmp[0] = (*it_c)->getMyCardsValueInt();
level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash();
//
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
// }
level.insert(level_it,level_tmp);
level.insert(level_it,level_tmp);
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
// }
break;
}
}
}
}
break;
}
}
}
}
}
}
++it_c;
++it_c;
}
}
// bool showCards;
// bool showCards;
// search for more player who have to show their cards (perhaps not all situation are considered yet)
// for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) {
//
// showCards = false;
//
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
//// }
// }
//
// for(it_c = activePlayerList->begin(); it_c!=lastActionPlayerIt; it_c++) {
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
//// }
// }
// search for more player who have to show their cards (perhaps not all situation are considered yet)
// for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) {
//
// showCards = false;
//
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
//// }
// }
//
// for(it_c = activePlayerList->begin(); it_c!=lastActionPlayerIt; it_c++) {
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
//// }
// }
}
}
// sort and unique the list
playerNeedToShowCards.sort();
playerNeedToShowCards.unique();
// sort and unique the list
playerNeedToShowCards.sort();
playerNeedToShowCards.unique();
// std::_List_iterator<unsigned> playerNeedToShowCardsIt;
//
+46 -19
View File
@@ -30,35 +30,62 @@ class PlayerInterface;
class HandInterface;
class LocalBoard : public BoardInterface{
class LocalBoard : public BoardInterface
{
public:
LocalBoard(unsigned dealerPosition);
LocalBoard(unsigned dealerPosition);
~LocalBoard();
void setPlayerLists(PlayerList, PlayerList, PlayerList);
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; }
void getMyCards(int* theValue) { int i; for(i=0; i<5; i++) theValue[i] = myCards[i]; }
void setMyCards(int* theValue) {
int i;
for(i=0; i<5; i++) myCards[i] = theValue[i];
}
void getMyCards(int* theValue) {
int i;
for(i=0; i<5; i++) theValue[i] = myCards[i];
}
void setAllInCondition(bool theValue) { allInCondition = theValue; }
void setLastActionPlayer(unsigned theValue) { lastActionPlayer = theValue; }
void setAllInCondition(bool theValue) {
allInCondition = theValue;
}
void setLastActionPlayer(unsigned theValue) {
lastActionPlayer = theValue;
}
int getPot() const { return pot;}
void setPot(int theValue) { pot = theValue;}
int getSets() const { return sets; }
void setSets(int theValue) { sets = theValue; }
int getPot() const {
return pot;
}
void setPot(int theValue) {
pot = theValue;
}
int getSets() const {
return sets;
}
void setSets(int theValue) {
sets = theValue;
}
void collectSets() ;
void collectPot() ;
void distributePot();
void determinePlayerNeedToShowCards();
void determinePlayerNeedToShowCards();
std::list<unsigned> getWinners() const { return winners; }
void setWinners(const std::list<unsigned> &w) { winners = w; }
std::list<unsigned> getWinners() const {
return winners;
}
void setWinners(const std::list<unsigned> &w) {
winners = w;
}
std::list<unsigned> getPlayerNeedToShowCards() const { return playerNeedToShowCards; }
void setPlayerNeedToShowCards(const std::list<unsigned> &p) { playerNeedToShowCards = p; }
std::list<unsigned> getPlayerNeedToShowCards() const {
return playerNeedToShowCards;
}
void setPlayerNeedToShowCards(const std::list<unsigned> &p) {
playerNeedToShowCards = p;
}
private:
@@ -67,14 +94,14 @@ private:
PlayerList runningPlayerList;
std::list<unsigned> winners;
std::list<unsigned> playerNeedToShowCards;
std::list<unsigned> playerNeedToShowCards;
int myCards[5];
int pot;
int sets;
unsigned dealerPosition;
bool allInCondition;
unsigned lastActionPlayer;
unsigned dealerPosition;
bool allInCondition;
unsigned lastActionPlayer;
};
@@ -32,7 +32,7 @@
LocalEngineFactory::LocalEngineFactory(ConfigFile *c)
: myConfig(c)
: myConfig(c)
{
}
+290 -275
View File
@@ -31,8 +31,8 @@
using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false),
cardsShown(false), bettingRoundsPlayed(0)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false),
cardsShown(false), bettingRoundsPlayed(0)
{
int i, j, k;
@@ -94,19 +94,19 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! DEBUGGER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
if(DEBUG_MODE) {
if(DEBUG_MODE) {
//QSqlDatabase *mySqliteLogDb;
//QSqlDatabase *mySqliteLogDb;
// myGui->getMyW()->getSession();
// myGui->getMyW()->getSession();
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
// if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
@@ -114,237 +114,240 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
switch(myID) {
case 1: {
case 1: {
tempBoardArray[0] = 4;
tempBoardArray[1] = 19;
tempBoardArray[2] = 20;
tempBoardArray[3] = 43;
tempBoardArray[4] = 49;
myBoard->setMyCards(tempBoardArray);
tempPlayerAndBoardArray[2] = tempBoardArray[0];
tempPlayerAndBoardArray[3] = tempBoardArray[1];
tempPlayerAndBoardArray[4] = tempBoardArray[2];
tempPlayerAndBoardArray[5] = tempBoardArray[3];
tempPlayerAndBoardArray[6] = tempBoardArray[4];
// player0
it = seatsList->begin();
tempPlayerArray[0] = 18;
tempPlayerArray[1] = 17;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
tempBoardArray[0] = 4;
tempBoardArray[1] = 19;
tempBoardArray[2] = 20;
tempBoardArray[3] = 43;
tempBoardArray[4] = 49;
// player1
++it;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 8;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player2
++it;
tempPlayerArray[0] = 26;
tempPlayerArray[1] = 27;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player3
++it;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 30;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
myBoard->setMyCards(tempBoardArray);
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
tempPlayerAndBoardArray[2] = tempBoardArray[0];
tempPlayerAndBoardArray[3] = tempBoardArray[1];
tempPlayerAndBoardArray[4] = tempBoardArray[2];
tempPlayerAndBoardArray[5] = tempBoardArray[3];
tempPlayerAndBoardArray[6] = tempBoardArray[4];
(*it)->setMyBestHandPosition(temp5Array);
// player0
it = seatsList->begin();
// player4
++it;
tempPlayerArray[0] = 50;
tempPlayerArray[1] = 51;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
tempPlayerArray[0] = 18;
tempPlayerArray[1] = 17;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// player5
++it;
tempPlayerArray[0] = 25;
tempPlayerArray[1] = 24;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
(*it)->setMyBestHandPosition(temp5Array);
// player1
++it;
// player6
++it;
tempPlayerArray[0] = 38;
tempPlayerArray[1] = 37;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 8;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// player7
++it;
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
tempPlayerArray[0] = 32;
tempPlayerArray[1] = 33;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyBestHandPosition(temp5Array);
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
// player2
++it;
(*it)->setMyBestHandPosition(temp5Array);
tempPlayerArray[0] = 26;
tempPlayerArray[1] = 27;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
// player8
++it;
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
tempPlayerArray[0] = 19;
tempPlayerArray[1] = 20;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyBestHandPosition(temp5Array);
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
// player3
++it;
(*it)->setMyBestHandPosition(temp5Array);
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 30;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player4
++it;
tempPlayerArray[0] = 50;
tempPlayerArray[1] = 51;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player5
++it;
tempPlayerArray[0] = 25;
tempPlayerArray[1] = 24;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player6
++it;
tempPlayerArray[0] = 38;
tempPlayerArray[1] = 37;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player7
++it;
tempPlayerArray[0] = 32;
tempPlayerArray[1] = 33;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
// player8
++it;
tempPlayerArray[0] = 19;
tempPlayerArray[1] = 20;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
(*it)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
(*it)->setMyBestHandPosition(temp5Array);
} break;
case 2: {
/* tempBoardArray[0] = 48;
tempBoardArray[1] = 21;
tempBoardArray[2] = 4;
tempBoardArray[3] = 9;
tempBoardArray[4] = 0;
myBoard->setMyCards(tempBoardArray);
tempPlayerAndBoardArray[2] = tempBoardArray[0];
tempPlayerAndBoardArray[3] = tempBoardArray[1];
tempPlayerAndBoardArray[4] = tempBoardArray[2];
tempPlayerAndBoardArray[5] = tempBoardArray[3];
tempPlayerAndBoardArray[6] = tempBoardArray[4];*/
// player0
it = seatsList->begin();
}
break;
case 2: {
/* tempBoardArray[0] = 48;
tempBoardArray[1] = 21;
tempBoardArray[2] = 4;
tempBoardArray[3] = 9;
tempBoardArray[4] = 0;
myBoard->setMyCards(tempBoardArray);
tempPlayerAndBoardArray[2] = tempBoardArray[0];
tempPlayerAndBoardArray[3] = tempBoardArray[1];
tempPlayerAndBoardArray[4] = tempBoardArray[2];
tempPlayerAndBoardArray[5] = tempBoardArray[3];
tempPlayerAndBoardArray[6] = tempBoardArray[4];*/
// player0
it = seatsList->begin();
// tempPlayerArray[0] = 9;
// tempPlayerArray[1] = 5;
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
//
//
// (*it)->setMyCards(tempPlayerArray);
// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
//
//
// (*it)->setMyBestHandPosition(temp5Array);
// player1
++it;
// player1
++it;
// tempPlayerArray[0] = 47;
// tempPlayerArray[1] = 22;
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
//
//
// (*it)->setMyCards(tempPlayerArray);
// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
//
//
// (*it)->setMyBestHandPosition(temp5Array);
// player2
++it;
// player2
++it;
// tempPlayerArray[0] = 33;
// tempPlayerArray[1] = 27;
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
//
//
// (*it)->setMyCards(tempPlayerArray);
// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
//
//
// (*it)->setMyBestHandPosition(temp5Array);
// player3
++it;
// player3
++it;
// tempPlayerArray[0] = 38;
// tempPlayerArray[1] = 22;
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
//
//
// (*it)->setMyCards(tempPlayerArray);
// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
//
//
// (*it)->setMyBestHandPosition(temp5Array);
// player4
++it;
// player4
++it;
// tempPlayerArray[0] = 25;
// tempPlayerArray[1] = 16;
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
//
//
// (*it)->setMyCards(tempPlayerArray);
// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
//
//
// (*it)->setMyBestHandPosition(temp5Array);
// player5
++it;
// player5
++it;
// tempPlayerArray[0] = 27;
// tempPlayerArray[1] = 10;
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
//
//
// (*it)->setMyCards(tempPlayerArray);
// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array));
//
//
// (*it)->setMyBestHandPosition(temp5Array);
} break;
default: {}
}
break;
default:
{}
}
@@ -356,7 +359,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
// determine dealer, SB, BB
assignButtons();
myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList);
myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList);
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind);
}
@@ -367,29 +370,32 @@ LocalHand::~LocalHand()
{
}
void LocalHand::start() {
void LocalHand::start()
{
//Log blinds sets for new Hand
PlayerListConstIterator it_sB, it_bB;
it_sB = getActivePlayerIt(getCurrentBeRo()->getSmallBlindPositionId());
it_bB = getActivePlayerIt(getCurrentBeRo()->getBigBlindPositionId());
if(it_sB != getActivePlayerList()->end() && it_bB != getActivePlayerList()->end()) {
myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str());
}
else { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID"); }
myGui->flushLogAtHand();
myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str());
} else {
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID");
}
myGui->flushLogAtHand();
// deal cards
myGui->dealHoleCards();
getBoard()->collectSets();
getGuiInterface()->refreshPot();
// change rounds | first start preflop
myGui->nextPlayerAnimation();
}
void LocalHand::assignButtons() {
void LocalHand::assignButtons()
{
size_t i;
PlayerListIterator it;
@@ -424,33 +430,33 @@ void LocalHand::assignButtons() {
it = getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() );
if(it != activePlayerList->end() ) {
nextActivePlayerFound = true;
if(activePlayerList->size() > 2) {
//small blind normal
(*it)->setMyButton(2);
smallBlindPosition = (*it)->getMyUniqueID();
} else {
//big blind in heads up
(*it)->setMyButton(3);
bigBlindPosition = (*it)->getMyUniqueID();
// lastPlayerAction for showing cards
}
if(activePlayerList->size() > 2) {
//small blind normal
(*it)->setMyButton(2);
smallBlindPosition = (*it)->getMyUniqueID();
} else {
//big blind in heads up
(*it)->setMyButton(3);
bigBlindPosition = (*it)->getMyUniqueID();
// lastPlayerAction for showing cards
}
// first player after dealer have to show his cards first (in showdown)
lastActionPlayer = (*it)->getMyUniqueID();
myBoard->setLastActionPlayer(lastActionPlayer);
// first player after dealer have to show his cards first (in showdown)
lastActionPlayer = (*it)->getMyUniqueID();
myBoard->setLastActionPlayer(lastActionPlayer);
++it;
if(it == activePlayerList->end()) it = activePlayerList->begin();
if(activePlayerList->size() > 2) {
//big blind normal
(*it)->setMyButton(3);
bigBlindPosition = (*it)->getMyUniqueID();
} else {
//small blind in heads up
(*it)->setMyButton(2);
smallBlindPosition = (*it)->getMyUniqueID();
}
if(activePlayerList->size() > 2) {
//big blind normal
(*it)->setMyButton(3);
bigBlindPosition = (*it)->getMyUniqueID();
} else {
//small blind in heads up
(*it)->setMyButton(2);
smallBlindPosition = (*it)->getMyUniqueID();
}
break;
}
@@ -466,7 +472,7 @@ void LocalHand::assignButtons() {
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
//small blind
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
// All in ?
if((*it_c)->getMyCash() <= smallBlind) {
@@ -475,24 +481,22 @@ void LocalHand::assignButtons() {
// 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
}
else {
} else {
(*it_c)->setMySet(smallBlind);
}
}
//big blind
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
// all in ?
if((*it_c)->getMyCash() <= 2*smallBlind) {
(*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
}
else {
} else {
(*it_c)->setMySet(2*smallBlind);
}
}
@@ -500,7 +504,8 @@ void LocalHand::assignButtons() {
}
void LocalHand::switchRounds() {
void LocalHand::switchRounds()
{
PlayerListIterator it, it_1;
PlayerListConstIterator it_c;
@@ -537,10 +542,10 @@ void LocalHand::switchRounds() {
// if only one player non-fold -> distribute pot
if(nonFoldPlayerCounter==1) {
myBoard->collectPot();
myBoard->collectPot();
myGui->refreshPot();
myGui->refreshSet();
currentRound = 4;
currentRound = 4;
}
// check for all in condition
@@ -550,7 +555,7 @@ void LocalHand::switchRounds() {
// 1) all players all in
if(allInPlayersCounter == nonFoldPlayerCounter) {
allInCondition = true;
myBoard->setAllInCondition(true);
myBoard->setAllInCondition(true);
}
// 2) all players but one all in and he has highest set
@@ -559,64 +564,64 @@ void LocalHand::switchRounds() {
for(it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
if((*it_c)->getMySet() >= myBeRo[currentRound]->getHighestSet()) {
allInCondition = true;
myBoard->setAllInCondition(true);
allInCondition = true;
myBoard->setAllInCondition(true);
}
}
// exception
// no.1: if in first Preflop Round next player is small blind and only all-in-big-blind with less than smallblind amount and other all-in players with less than small blind are nonfold too -> preflop is over
PlayerListConstIterator smallBlindIt_c = getRunningPlayerIt(myBeRo[currentRound]->getSmallBlindPositionId());
PlayerListConstIterator bigBlindIt_c = getActivePlayerIt(myBeRo[currentRound]->getBigBlindPositionId());
if(smallBlindIt_c!=runningPlayerList->end() && bigBlindIt_c!=activePlayerList->end() && currentRound == GAME_STATE_PREFLOP && myBeRo[currentRound]->getFirstRound()) {
// determine player who are all in with less than small blind amount
int tempCounter = 0;
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
if((*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMySet() <= smallBlind) {
tempCounter++;
}
}
if( (*bigBlindIt_c)->getMySet() <= smallBlind && tempCounter == allInPlayersCounter) {
allInCondition = true;
myBoard->setAllInCondition(true);
}
}
// no.2: heads up -> detect player who is all in and bb but could set less than sb
// no.1: if in first Preflop Round next player is small blind and only all-in-big-blind with less than smallblind amount and other all-in players with less than small blind are nonfold too -> preflop is over
PlayerListConstIterator smallBlindIt_c = getRunningPlayerIt(myBeRo[currentRound]->getSmallBlindPositionId());
PlayerListConstIterator bigBlindIt_c = getActivePlayerIt(myBeRo[currentRound]->getBigBlindPositionId());
if(smallBlindIt_c!=runningPlayerList->end() && bigBlindIt_c!=activePlayerList->end() && currentRound == GAME_STATE_PREFLOP && myBeRo[currentRound]->getFirstRound()) {
// determine player who are all in with less than small blind amount
int tempCounter = 0;
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
if(activePlayerList->size()==2 && (*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMyButton()==BUTTON_BIG_BLIND && (*it_c)->getMySet()<=smallBlind && currentRound == GAME_STATE_PREFLOP) {
allInCondition = true;
myBoard->setAllInCondition(true);
if((*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMySet() <= smallBlind) {
tempCounter++;
}
}
if( (*bigBlindIt_c)->getMySet() <= smallBlind && tempCounter == allInPlayersCounter) {
allInCondition = true;
myBoard->setAllInCondition(true);
}
}
// no.2: heads up -> detect player who is all in and bb but could set less than sb
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
if(activePlayerList->size()==2 && (*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMyButton()==BUTTON_BIG_BLIND && (*it_c)->getMySet()<=smallBlind && currentRound == GAME_STATE_PREFLOP) {
allInCondition = true;
myBoard->setAllInCondition(true);
}
}
}
}
// special routine
if(allInCondition) {
myBoard->collectPot();
myBoard->collectPot();
myGui->refreshPot();
myGui->refreshSet();
myGui->flipHolecardsAllIn();
if (currentRound < 4) // do not increment past 4
currentRound++;
//log board cards for allin
if(currentRound >= 1) {
int tempBoardCardsArray[5];
myBoard->getMyCards(tempBoardCardsArray);
myGui->logDealBoardCardsMsg(currentRound, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
}
}
//unhighlight current players groupbox
it_c = getActivePlayerIt(lastPlayersTurn);
if( it_c != activePlayerList->end() ) {
if( it_c != activePlayerList->end() ) {
// lastPlayersTurn is active
myGui->refreshGroupbox(lastPlayersTurn,1);
}
@@ -624,38 +629,45 @@ void LocalHand::switchRounds() {
myGui->refreshGameLabels((GameState)getCurrentRound());
switch(currentRound) {
case 0: {
// start preflop
myGui->preflopAnimation1();
} break;
case 1: {
// start flop
myGui->flopAnimation1();
} break;
case 2: {
// start turn
myGui->turnAnimation1();
case 0: {
// start preflop
myGui->preflopAnimation1();
}
break;
case 1: {
// start flop
myGui->flopAnimation1();
}
break;
case 2: {
// start turn
myGui->turnAnimation1();
} break;
case 3: {
// start river
myGui->riverAnimation1();
}
break;
case 3: {
// start river
myGui->riverAnimation1();
} break;
case 4: {
// start post river
myGui->postRiverAnimation1();
}
break;
case 4: {
// start post river
myGui->postRiverAnimation1();
}
break;
default:
{}
} break;
default: {}
}
}
PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const {
PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const
{
PlayerListIterator it;
@@ -669,7 +681,8 @@ PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const {
}
PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const {
PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const
{
PlayerListIterator it;
@@ -683,7 +696,8 @@ PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const {
}
PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const
{
PlayerListIterator it;
@@ -698,7 +712,8 @@ PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
}
void LocalHand::setLastActionPlayer(unsigned theValue) {
lastActionPlayer = theValue;
myBoard->setLastActionPlayer(theValue);
void LocalHand::setLastActionPlayer(unsigned theValue)
{
lastActionPlayer = theValue;
myBoard->setLastActionPlayer(theValue);
}
+103 -40
View File
@@ -31,57 +31,120 @@
class Log;
class LocalHand : public HandInterface{
class LocalHand : public HandInterface
{
public:
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int);
~LocalHand();
void start();
PlayerList getSeatsList() const {return seatsList;}
PlayerList getActivePlayerList() const {return activePlayerList;}
PlayerList getRunningPlayerList() const {return runningPlayerList;}
PlayerList getSeatsList() const {
return seatsList;
}
PlayerList getActivePlayerList() const {
return activePlayerList;
}
PlayerList getRunningPlayerList() const {
return runningPlayerList;
}
boost::shared_ptr<BoardInterface> getBoard() const { return myBoard; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[GAME_STATE_TURN]; }
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[GAME_STATE_RIVER]; }
GuiInterface* getGuiInterface() const { return myGui; }
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const { return myBeRo[currentRound]; }
boost::shared_ptr<BoardInterface> getBoard() const {
return myBoard;
}
boost::shared_ptr<BeRoInterface> getPreflop() const {
return myBeRo[GAME_STATE_PREFLOP];
}
boost::shared_ptr<BeRoInterface> getFlop() const {
return myBeRo[GAME_STATE_FLOP];
}
boost::shared_ptr<BeRoInterface> getTurn() const {
return myBeRo[GAME_STATE_TURN];
}
boost::shared_ptr<BeRoInterface> getRiver() const {
return myBeRo[GAME_STATE_RIVER];
}
GuiInterface* getGuiInterface() const {
return myGui;
}
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const {
return myBeRo[currentRound];
}
void setMyID(int theValue) { myID = theValue; }
int getMyID() const { return myID; }
void setMyID(int theValue) {
myID = theValue;
}
int getMyID() const {
return myID;
}
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
int getStartQuantityPlayers() const { return startQuantityPlayers; }
void setStartQuantityPlayers(int theValue) {
startQuantityPlayers = theValue;
}
int getStartQuantityPlayers() const {
return startQuantityPlayers;
}
void setCurrentRound(int theValue) { currentRound = theValue; }
int getCurrentRound() const { return currentRound; }
void setCurrentRound(int theValue) {
currentRound = theValue;
}
int getCurrentRound() const {
return currentRound;
}
void setDealerPosition(int theValue) { dealerPosition = theValue; }
int getDealerPosition() const { return dealerPosition; }
void setDealerPosition(int theValue) {
dealerPosition = theValue;
}
int getDealerPosition() const {
return dealerPosition;
}
void setSmallBlind(int theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setSmallBlind(int theValue) {
smallBlind = theValue;
}
int getSmallBlind() const {
return smallBlind;
}
void setAllInCondition(bool theValue) { allInCondition = theValue; }
bool getAllInCondition() const { return allInCondition; }
void setAllInCondition(bool theValue) {
allInCondition = theValue;
}
bool getAllInCondition() const {
return allInCondition;
}
void setStartCash(int theValue) { startCash = theValue; }
int getStartCash() const { return startCash; }
void setBettingRoundsPlayed(int theValue) { bettingRoundsPlayed = theValue; }
int getBettingRoundsPlayed() const { return bettingRoundsPlayed; }
void setStartCash(int theValue) {
startCash = theValue;
}
int getStartCash() const {
return startCash;
}
void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; }
int getLastPlayersTurn() const { return lastPlayersTurn; }
void setBettingRoundsPlayed(int theValue) {
bettingRoundsPlayed = theValue;
}
int getBettingRoundsPlayed() const {
return bettingRoundsPlayed;
}
void setLastPlayersTurn(int theValue) {
lastPlayersTurn = theValue;
}
int getLastPlayersTurn() const {
return lastPlayersTurn;
}
void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const { return lastActionPlayer; }
unsigned getLastActionPlayer() const {
return lastActionPlayer;
}
void setCardsShown(bool theValue) { cardsShown = theValue; }
bool getCardsShown() const { return cardsShown; }
void setCardsShown(bool theValue) {
cardsShown = theValue;
}
bool getCardsShown() const {
return cardsShown;
}
void assignButtons();
@@ -97,25 +160,25 @@ private:
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
boost::shared_ptr<BoardInterface> myBoard;
Log *myLog;
Log *myLog;
PlayerList seatsList; // all player
PlayerList activePlayerList; // all player who are not out
PlayerList runningPlayerList; // all player who are not folded, not all in and not out
PlayerList seatsList; // all player
PlayerList activePlayerList; // all player who are not out
PlayerList runningPlayerList; // all player who are not folded, not all in and not out
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
int startQuantityPlayers;
unsigned dealerPosition;
unsigned smallBlindPosition;
unsigned bigBlindPosition;
unsigned smallBlindPosition;
unsigned bigBlindPosition;
int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
int smallBlind;
int startCash;
int lastPlayersTurn;
unsigned lastActionPlayer;
unsigned lastActionPlayer;
bool allInCondition;
bool cardsShown;
File diff suppressed because it is too large. Load diff
+167 -70
View File
@@ -30,7 +30,8 @@ class CardsValue;
class ConfigFile;
class HandInterface;
class LocalPlayer : public PlayerInterface{
class LocalPlayer : public PlayerInterface
{
public:
LocalPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
@@ -38,93 +39,179 @@ public:
void setHand(HandInterface *);
int getMyID() const { return myID; }
unsigned getMyUniqueID() const { return myUniqueID; }
PlayerType getMyType() const { return myType; }
void setMyDude(int theValue) { myDude = theValue; }
int getMyDude() const { return myDude; }
void setMyDude4(int theValue) { myDude4 = theValue; }
int getMyDude4() const { return myDude4; }
void setMyName(const std::string& theValue) { myName = theValue; }
std::string getMyName() const { return myName; }
void setMyAvatar(const std::string& theValue) { myAvatar = theValue; }
std::string getMyAvatar() const { return myAvatar; }
void setMyCash(int theValue) { myCash = theValue; }
int getMyCash() const { return myCash; }
void setMySet(int theValue) { myLastRelativeSet = theValue; mySet += theValue; myCash -= theValue; }
void setMySetAbsolute(int theValue) { mySet = theValue; }
void setMySetNull() { mySet = 0; myLastRelativeSet = 0; }
int getMySet() const { return mySet;}
int getMyLastRelativeSet() const { return myLastRelativeSet; }
void setMyAction(int theValue, bool blind = 0) {
myAction = theValue;
// logging for human player
if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet);
int getMyID() const {
return myID;
}
unsigned getMyUniqueID() const {
return myUniqueID;
}
PlayerType getMyType() const {
return myType;
}
int getMyAction() const { return myAction; }
void setMyButton(int theValue) { myButton = theValue; }
int getMyButton() const { return myButton; }
void setMyDude(int theValue) {
myDude = theValue;
}
int getMyDude() const {
return myDude;
}
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; }
bool getMyActiveStatus() const { return myActiveStatus; }
void setMyDude4(int theValue) {
myDude4 = theValue;
}
int getMyDude4() const {
return myDude4;
}
void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; }
bool getMyStayOnTableStatus() const { return myStayOnTableStatus; }
void setMyName(const std::string& theValue) {
myName = theValue;
}
std::string getMyName() const {
return myName;
}
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; }
void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; }
void setMyAvatar(const std::string& theValue) {
myAvatar = theValue;
}
std::string getMyAvatar() const {
return myAvatar;
}
void setMyTurn(bool theValue){ myTurn = theValue;}
bool getMyTurn() const{ return myTurn;}
void setMyCash(int theValue) {
myCash = theValue;
}
int getMyCash() const {
return myCash;
}
void setMyCardsFlip(bool theValue, int state){
void setMySet(int theValue) {
myLastRelativeSet = theValue;
mySet += theValue;
myCash -= theValue;
}
void setMySetAbsolute(int theValue) {
mySet = theValue;
}
void setMySetNull() {
mySet = 0;
myLastRelativeSet = 0;
}
int getMySet() const {
return mySet;
}
int getMyLastRelativeSet() const {
return myLastRelativeSet;
}
void setMyAction(int theValue, bool blind = 0) {
myAction = theValue;
// logging for human player
if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet);
}
int getMyAction() const {
return myAction;
}
void setMyButton(int theValue) {
myButton = theValue;
}
int getMyButton() const {
return myButton;
}
void setMyActiveStatus(bool theValue) {
myActiveStatus = theValue;
}
bool getMyActiveStatus() const {
return myActiveStatus;
}
void setMyStayOnTableStatus(bool theValue) {
myStayOnTableStatus = theValue;
}
bool getMyStayOnTableStatus() const {
return myStayOnTableStatus;
}
void setMyCards(int* theValue) {
int i;
for(i=0; i<2; i++) myCards[i] = theValue[i];
}
void getMyCards(int* theValue) const {
int i;
for(i=0; i<2; i++) theValue[i] = myCards[i];
}
void setMyTurn(bool theValue) {
myTurn = theValue;
}
bool getMyTurn() const {
return myTurn;
}
void setMyCardsFlip(bool theValue, int state) {
myCardsFlip = theValue;
// log flipping cards
if(myCardsFlip) {
switch(state) {
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
case 1:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
break;
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
case 2:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
break;
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
case 3:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
break;
default: ;
default:
;
}
}
}
bool getMyCardsFlip() const{ return myCardsFlip;}
bool getMyCardsFlip() const {
return myCardsFlip;
}
void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;}
int getMyCardsValueInt() const { return myCardsValueInt; }
void setMyCardsValueInt(int theValue) {
myCardsValueInt = theValue;
}
int getMyCardsValueInt() const {
return myCardsValueInt;
}
void setMyBestHandPosition(int* theValue)
{
void setMyBestHandPosition(int* theValue) {
for (int i = 0; i < 5; i++)
myBestHandPosition[i] = theValue[i];
}
void getMyBestHandPosition(int* theValue) const
{
void getMyBestHandPosition(int* theValue) const {
for (int i = 0; i < 5; i++)
theValue[i] = myBestHandPosition[i];
}
void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;}
int getMyRoundStartCash() const { return myRoundStartCash; }
void setMyRoundStartCash(int theValue) {
myRoundStartCash = theValue;
}
int getMyRoundStartCash() const {
return myRoundStartCash;
}
void setLastMoneyWon ( int theValue ) { lastMoneyWon = theValue; }
int getLastMoneyWon() const { return lastMoneyWon; }
void setLastMoneyWon ( int theValue ) {
lastMoneyWon = theValue;
}
int getLastMoneyWon() const {
return lastMoneyWon;
}
void setMyAverageSets(int theValue) {
myAverageSets[0] = myAverageSets[1];
myAverageSets[1] = myAverageSets[2];
myAverageSets[2] = myAverageSets[3];
myAverageSets[3] = theValue;
}
int getMyAverageSets() const {
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
}
void setMyAverageSets(int theValue) { myAverageSets[0] = myAverageSets[1]; myAverageSets[1] = myAverageSets[2]; myAverageSets[2] = myAverageSets[3]; myAverageSets[3] = theValue; }
int getMyAverageSets() const { return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; }
void setMyAggressive(bool theValue) {
int i;
for(i=0; i<6; i++) {
@@ -140,24 +227,34 @@ public:
return sum;
}
void setSBluff ( int theValue ) { sBluff = theValue; }
int getSBluff() const { return sBluff; }
void setSBluff ( int theValue ) {
sBluff = theValue;
}
int getSBluff() const {
return sBluff;
}
void setSBluffStatus ( bool theValue ) { sBluffStatus = theValue; }
bool getSBluffStatus() const { return sBluffStatus; }
void setSBluffStatus ( bool theValue ) {
sBluffStatus = theValue;
}
bool getSBluffStatus() const {
return sBluffStatus;
}
void setMyWinnerState ( bool theValue, int pot ) {
if(theValue) myWinnerState = theValue;
currentHand->getGuiInterface()->logPlayerWinsMsg(myName, pot, theValue);
currentHand->getGuiInterface()->logPlayerWinsMsg(myName, pot, theValue);
}
bool getMyWinnerState() const { return myWinnerState;}
bool getMyWinnerState() const {
return myWinnerState;
}
void action();
int checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind);
void preflopEngine();
void flopEngine();
void turnEngine();
@@ -214,7 +311,7 @@ private:
int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin
int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big
bool myActiveStatus; // 0 = inactive, 1 = active
bool myStayOnTableStatus; // 0 = left, 1 = stay
bool myStayOnTableStatus; // 0 = left, 1 = stay
bool myTurn; // 0 = no, 1 = yes
bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
int myRoundStartCash;
@@ -225,7 +322,7 @@ private:
int sBluff;
bool sBluffStatus;
bool myWinnerState;
unsigned m_actionTimeoutCounter;
+4 -4
View File
@@ -25,10 +25,10 @@ Replay::Replay() : replaySqliteLogDb(0)
// replaySqliteLogDb = new QSqlDatabase();
//
// *replaySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE");
//replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb");
//if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
//}
//replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb");
//if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
//}
}
+4 -4
View File
@@ -24,12 +24,12 @@
class Replay
{
public:
Replay();
~Replay();
public:
Replay();
~Replay();
private:
QSqlDatabase *replaySqliteLogDb;
QSqlDatabase *replaySqliteLogDb;
};
+11 -13
View File
@@ -27,7 +27,8 @@
using namespace std;
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad, int countBad) {
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad, int countBad)
{
int r = end-start+1;
unsigned char rand_buf[4];
@@ -39,8 +40,7 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
for (i=0; i<howMany; i++) {
if(!RAND_bytes(rand_buf, 4))
{
if(!RAND_bytes(rand_buf, 4)) {
LOG_MSG("RAND_bytes failed!");
}
@@ -54,23 +54,21 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
}
}
}
else {
} else {
int *tempArray = new int[end-start+1];
for (i=0; i<(end-start+1); i++) tempArray[i]=1;
if(bad) {
for(i=0;i<countBad;i++) {
for(i=0; i<countBad; i++) {
tempArray[bad[i]]=0;
}
}
int counter(0);
while (counter < howMany) {
if(!RAND_bytes(rand_buf, 4))
{
if(!RAND_bytes(rand_buf, 4)) {
LOG_MSG("RAND_bytes failed!");
}
@@ -82,14 +80,14 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
if(randNumber < ( (unsigned int) ( ((double)numeric_limits<unsigned int>::max()) / r ) ) * r) {
randNumber = randNumber % r;
if (tempArray[randNumber] == 1) {
randArray[counter] = start + randNumber;
if (tempArray[randNumber] == 1) {
randArray[counter] = start + randNumber;
tempArray[randNumber] = 0;
counter++;
}
}
}
delete[] tempArray;
+2 -1
View File
@@ -20,7 +20,8 @@
#ifndef TOOLS_H
#define TOOLS_H
class Tools{
class Tools
{
public:
static void getRandNumber(int, int, int, int*, bool, int* = 0, int = 0);
+175 -173
View File
@@ -32,238 +32,240 @@ using namespace std;
Log::Log(string logDirString, int logOnOffInt) : curGameID(0), logOnOff(false)
{
if(SQLITE_LOG) {
if(SQLITE_LOG) {
// logging activated
if(logOnOffInt) {
// logging activated
if(logOnOffInt) {
logOnOff = true;
logOnOff = true;
DIR *logDir;
logDir = opendir(logDirString.c_str());
DIR *logDir;
logDir = opendir(logDirString.c_str());
bool dirExists = logDir != NULL;
closedir(logDir);
// check if logging path exist
// check if logging path exist
if(logDirString != "" && dirExists) {
string sql;
char *errmsg;
string sql;
char *errmsg;
// detect current time
char curDateTime[20];
char curDate[11];
char curTime[9];
time_t now = time(NULL);
tm *z = localtime(&now);
strftime(curDateTime,20,"%Y-%m-%d_%H.%M.%S",z);
strftime(curDate,11,"%Y-%m-%d",z);
strftime(curTime,9,"%H:%M:%S",z);
// detect current time
char curDateTime[20];
char curDate[11];
char curTime[9];
time_t now = time(NULL);
tm *z = localtime(&now);
strftime(curDateTime,20,"%Y-%m-%d_%H.%M.%S",z);
strftime(curDate,11,"%Y-%m-%d",z);
strftime(curTime,9,"%H:%M:%S",z);
string mySqliteLogFileName = boost::lexical_cast<string>(logDirString.c_str());
mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast<string>(curDateTime) + ".pdb";
string mySqliteLogFileName = boost::lexical_cast<string>(logDirString.c_str());
mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast<string>(curDateTime) + ".pdb";
// open sqlite-db
sqlite3_open(mySqliteLogFileName.data(), &mySqliteLogDb);
if( mySqliteLogDb != 0 ) {
// open sqlite-db
sqlite3_open(mySqliteLogFileName.data(), &mySqliteLogDb);
if( mySqliteLogDb != 0 ) {
int i;
// create session table
sql = "CREATE TABLE Session (";
sql += "PokerTH_Version TEXT NOT NULL";
sql += ",Date TEXT NOT NULL";
sql += ",Time TEXT NOT NULL";
sql += ", PRIMARY KEY(Date,Time))";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sql = "CREATE TABLE Session (";
sql += "PokerTH_Version TEXT NOT NULL";
sql += ",Date TEXT NOT NULL";
sql += ",Time TEXT NOT NULL";
sql += ", PRIMARY KEY(Date,Time))";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
}
sql = "INSERT INTO Session (";
sql += "PokerTH_Version";
sql += ",Date";
sql += ",Time";
sql += ") VALUES (";
sql += "\"" + boost::lexical_cast<string>(POKERTH_BETA_RELEASE_STRING) + "\",";
sql += "\"" + boost::lexical_cast<string>(curDate) + "\",";
sql += "\"" + boost::lexical_cast<string>(curTime) + "\")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sql = "INSERT INTO Session (";
sql += "PokerTH_Version";
sql += ",Date";
sql += ",Time";
sql += ") VALUES (";
sql += "\"" + boost::lexical_cast<string>(POKERTH_BETA_RELEASE_STRING) + "\",";
sql += "\"" + boost::lexical_cast<string>(curDate) + "\",";
sql += "\"" + boost::lexical_cast<string>(curTime) + "\")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
}
// create game table
sql = "CREATE TABLE Game (";
sql += "GameID INTEGER NOT NULL PRIMARY KEY";
sql += ",Startmoney INTEGER NOT NULL";
sql += ",StartSb INTEGER NOT NULL";
sql += ",DealerPos INTEGER NOT NULL";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + " TEXT";
}
sql += ",Winner_Seat INTEGER";
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
// create game table
sql = "CREATE TABLE Game (";
sql += "GameID INTEGER NOT NULL PRIMARY KEY";
sql += ",Startmoney INTEGER NOT NULL";
sql += ",StartSb INTEGER NOT NULL";
sql += ",DealerPos INTEGER NOT NULL";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + " TEXT";
}
sql += ",Winner_Seat INTEGER";
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
}
// create hand table
sql = "CREATE TABLE Hand (";
sql += "HandID INTEGER NOT NULL";
sql += ",GameID INTEGER NOT NULL";
sql += ",Dealer_Seat INTEGER";
sql += ",Sb_Amount INTEGER NOT NULL";
sql += ",Sb_Seat INTEGER NOT NULL";
sql += ",Bb_Amount INTEGER NOT NULL";
sql += ",Bb_Seat INTEGER NOT NULL";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash INTEGER";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_1 INTEGER";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_2 INTEGER";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_text TEXT";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_int INTEGER";
}
for(i=1; i<=5; i++) {
sql += ",BoardCard_" + boost::lexical_cast<std::string>(i) + " INTEGER";
}
sql += ",PRIMARY KEY(HandID,GameID))";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
// create hand table
sql = "CREATE TABLE Hand (";
sql += "HandID INTEGER NOT NULL";
sql += ",GameID INTEGER NOT NULL";
sql += ",Dealer_Seat INTEGER";
sql += ",Sb_Amount INTEGER NOT NULL";
sql += ",Sb_Seat INTEGER NOT NULL";
sql += ",Bb_Amount INTEGER NOT NULL";
sql += ",Bb_Seat INTEGER NOT NULL";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash INTEGER";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_1 INTEGER";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_2 INTEGER";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_text TEXT";
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_int INTEGER";
}
for(i=1; i<=5; i++) {
sql += ",BoardCard_" + boost::lexical_cast<std::string>(i) + " INTEGER";
}
sql += ",PRIMARY KEY(HandID,GameID))";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
}
// create action table
sql = "CREATE TABLE Action (";
sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT";
sql += ",HandID INTEGER NOT NULL";
sql += ",GameID INTEGER NOT NULL";
sql += ",BeRo INTEGER NOT NULL";
sql += ",Player INTEGER NOT NULL";
sql += ",Action TEXT NOT NULL";
sql += ",Amount INTEGER";
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
// create action table
sql = "CREATE TABLE Action (";
sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT";
sql += ",HandID INTEGER NOT NULL";
sql += ",GameID INTEGER NOT NULL";
sql += ",BeRo INTEGER NOT NULL";
sql += ",Player INTEGER NOT NULL";
sql += ",Action TEXT NOT NULL";
sql += ",Amount INTEGER";
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
}
}
}
}
}
}
}
}
}
}
Log::~Log()
{
if(SQLITE_LOG) {
sqlite3_close(mySqliteLogDb);
}
if(SQLITE_LOG) {
sqlite3_close(mySqliteLogDb);
}
}
void
Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList) {
Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList)
{
curGameID = gameID;
curGameID = gameID;
if(SQLITE_LOG) {
if(SQLITE_LOG) {
if(logOnOff) {
//if write logfiles is enabled
if(logOnOff) {
//if write logfiles is enabled
PlayerListConstIterator it_c;
string sql;
char *errmsg;
PlayerListConstIterator it_c;
string sql;
char *errmsg;
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
int i;
sql = "INSERT INTO Game (";
sql += "GameID";
sql += ",Startmoney";
sql += ",StartSb";
sql += ",DealerPos";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i);
}
sql += ") VALUES (";
sql += boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(startCash);
sql += "," + boost::lexical_cast<string>(startSmallBlind);
sql += "," + boost::lexical_cast<string>(dealerPosition);
for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) {
if((*it_c)->getMyActiveStatus()) {
sql += ",\"" + (*it_c)->getMyName() +"\"";
} else {
sql += ",NULL";
}
}
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
}
}
}
}
sql = "INSERT INTO Game (";
sql += "GameID";
sql += ",Startmoney";
sql += ",StartSb";
sql += ",DealerPos";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i);
}
sql += ") VALUES (";
sql += boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(startCash);
sql += "," + boost::lexical_cast<string>(startSmallBlind);
sql += "," + boost::lexical_cast<string>(dealerPosition);
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
sql += ",\"" + (*it_c)->getMyName() +"\"";
} else {
sql += ",NULL";
}
}
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
}
}
}
}
}
void
Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList) {
Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList)
{
if(SQLITE_LOG) {
if(SQLITE_LOG) {
if(logOnOff) {
//if write logfiles is enabled
if(logOnOff) {
//if write logfiles is enabled
PlayerListConstIterator it_c;
string sql;
char *errmsg;
PlayerListConstIterator it_c;
string sql;
char *errmsg;
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
int i;
sql = "INSERT INTO Hand (";
sql += "HandID";
sql += ",GameID";
sql += ",Dealer_Seat";
sql += ",Sb_Amount";
sql += ",Sb_Seat";
sql += ",Bb_Amount";
sql += ",Bb_Seat";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash";
}
sql += ") VALUES (";
sql += boost::lexical_cast<string>(handID);
sql += "," + boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
sql += "," + boost::lexical_cast<string>(smallBlind);
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
sql += "," + boost::lexical_cast<string>(bigBlind);
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) {
if((*it_c)->getMyActiveStatus()) {
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
} else {
sql += ",NULL";
}
}
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
}
sql = "INSERT INTO Hand (";
sql += "HandID";
sql += ",GameID";
sql += ",Dealer_Seat";
sql += ",Sb_Amount";
sql += ",Sb_Seat";
sql += ",Bb_Amount";
sql += ",Bb_Seat";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash";
}
sql += ") VALUES (";
sql += boost::lexical_cast<string>(handID);
sql += "," + boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
sql += "," + boost::lexical_cast<string>(smallBlind);
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
sql += "," + boost::lexical_cast<string>(bigBlind);
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
} else {
sql += ",NULL";
}
}
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
}
}
}
}
}
}
}
}
//void
+7 -7
View File
@@ -28,19 +28,19 @@ class Log
{
public:
Log(std::string logDirString, int logOnOffInt);
Log(std::string logDirString, int logOnOffInt);
~Log();
~Log();
void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList);
void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList);
void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList);
void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList);
// void closeLogDbAtExit();
private:
sqlite3 *mySqliteLogDb;
int curGameID;
bool logOnOff;
sqlite3 *mySqliteLogDb;
int curGameID;
bool logOnOff;
};
+3 -3
View File
@@ -20,9 +20,9 @@
#include "clientbero.h"
ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, unsigned /*dP*/, int sB, GameState gS)
: BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), smallBlindPositionId(0), bigBlindPositionId(0), currentPlayersTurnId(0),
firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false),
lastActionPlayer(0)
: BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), smallBlindPositionId(0), bigBlindPositionId(0), currentPlayersTurnId(0),
firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false),
lastActionPlayer(0)
{
}
+5 -4
View File
@@ -28,7 +28,8 @@ class HandInterface;
/**
@author FThauer FHammer <webmaster@pokerth.net>
*/
class ClientBeRo : public BeRoInterface{
class ClientBeRo : public BeRoInterface
{
public:
ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
~ClientBeRo();
@@ -38,8 +39,8 @@ public:
int getHighestCardsValue() const;
void setHighestCardsValue(int theValue);
void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const;
void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const;
void setSmallBlindPositionId(unsigned theValue);
unsigned getSmallBlindPositionId() const;
@@ -58,7 +59,7 @@ public:
void setLastPlayersTurnIt(PlayerListIterator theValue);
PlayerListIterator getLastPlayersTurnIt() const;
void setHighestSet(int theValue);
int getHighestSet() const;
+6 -6
View File
@@ -24,7 +24,7 @@
using namespace std;
ClientBoard::ClientBoard(unsigned dp)
: pot(0), sets(0), dealerPosition(dp), allInCondition(false), lastActionPlayer(0)
: pot(0), sets(0), dealerPosition(dp), allInCondition(false), lastActionPlayer(0)
{
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
}
@@ -90,15 +90,15 @@ ClientBoard::setSets(int theValue)
void
ClientBoard::setAllInCondition(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
allInCondition = theValue;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
allInCondition = theValue;
}
void
ClientBoard::setLastActionPlayer(unsigned theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
lastActionPlayer = theValue;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
lastActionPlayer = theValue;
}
void
@@ -116,7 +116,7 @@ void
ClientBoard::collectPot()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
pot += sets;
pot += sets;
sets = 0;
}
+6 -6
View File
@@ -31,7 +31,7 @@ class HandInterface;
class ClientBoard : public BoardInterface
{
public:
ClientBoard(unsigned dealerPosition);
ClientBoard(unsigned dealerPosition);
~ClientBoard();
void setPlayerLists(PlayerList, PlayerList, PlayerList);
@@ -44,8 +44,8 @@ public:
int getSets() const;
void setSets(int theValue);
void setAllInCondition(bool theValue);
void setLastActionPlayer(unsigned theValue);
void setAllInCondition(bool theValue);
void setLastActionPlayer(unsigned theValue);
void collectSets();
void collectPot();
@@ -72,9 +72,9 @@ private:
int myCards[5];
int pot;
int sets;
unsigned dealerPosition;
bool allInCondition;
unsigned lastActionPlayer;
unsigned dealerPosition;
bool allInCondition;
unsigned lastActionPlayer;
};
#endif
+4 -4
View File
@@ -22,15 +22,15 @@
using namespace std;
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0),
smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0),
smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0)
{
PlayerListIterator it;
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
(*it)->setHand(this);
// myFlipCards auf 0 setzen
// myFlipCards auf 0 setzen
(*it)->setMyCardsFlip(0, 0);
}
+63 -63
View File
@@ -32,97 +32,97 @@
class ClientHand : public HandInterface
{
public:
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int );
~ClientHand();
public:
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int );
~ClientHand();
void start();
void start();
PlayerList getSeatsList() const;
PlayerList getActivePlayerList() const;
PlayerList getRunningPlayerList() const;
PlayerList getSeatsList() const;
PlayerList getActivePlayerList() const;
PlayerList getRunningPlayerList() const;
boost::shared_ptr<BoardInterface> getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const;
boost::shared_ptr<BeRoInterface> getTurn() const;
boost::shared_ptr<BeRoInterface> getRiver() const;
GuiInterface* getGuiInterface() const;
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
boost::shared_ptr<BoardInterface> getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const;
boost::shared_ptr<BeRoInterface> getTurn() const;
boost::shared_ptr<BeRoInterface> getRiver() const;
GuiInterface* getGuiInterface() const;
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
void setMyID ( int theValue );
int getMyID() const;
void setMyID ( int theValue );
int getMyID() const;
void setCurrentQuantityPlayers ( int theValue );
int getCurrentQuantityPlayers() const;
void setCurrentQuantityPlayers ( int theValue );
int getCurrentQuantityPlayers() const;
void setStartQuantityPlayers ( int theValue );
int getStartQuantityPlayers() const;
void setStartQuantityPlayers ( int theValue );
int getStartQuantityPlayers() const;
void setCurrentRound ( int theValue );
int getCurrentRound() const;
void setCurrentRound ( int theValue );
int getCurrentRound() const;
void setDealerPosition ( int theValue );
int getDealerPosition() const;
void setDealerPosition ( int theValue );
int getDealerPosition() const;
void setSmallBlind ( int theValue );
int getSmallBlind() const;
void setSmallBlind ( int theValue );
int getSmallBlind() const;
void setAllInCondition ( bool theValue );
bool getAllInCondition() const;
void setAllInCondition ( bool theValue );
bool getAllInCondition() const;
void setStartCash ( int theValue );
int getStartCash() const;
void setStartCash ( int theValue );
int getStartCash() const;
void setBettingRoundsPlayed ( int theValue );
int getBettingRoundsPlayed() const;
void setBettingRoundsPlayed ( int theValue );
int getBettingRoundsPlayed() const;
void setLastPlayersTurn ( int theValue );
int getLastPlayersTurn() const;
void setLastPlayersTurn ( int theValue );
int getLastPlayersTurn() const;
void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const;
void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const;
void setCardsShown ( bool theValue );
bool getCardsShown() const;
void setCardsShown ( bool theValue );
bool getCardsShown() const;
void switchRounds();
void switchRounds();
protected:
PlayerListIterator getSeatIt(unsigned) const;
PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const;
PlayerListIterator getSeatIt(unsigned) const;
PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const;
private:
mutable boost::recursive_mutex m_syncMutex;
mutable boost::recursive_mutex m_syncMutex;
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
boost::shared_ptr<BoardInterface> myBoard;
Log *myLog;
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
boost::shared_ptr<BoardInterface> myBoard;
Log *myLog;
PlayerList seatsList;
PlayerList activePlayerList;
PlayerList runningPlayerList;
PlayerList seatsList;
PlayerList activePlayerList;
PlayerList runningPlayerList;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
int startQuantityPlayers;
unsigned dealerPosition;
int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
int smallBlind;
int startCash;
int myID;
int startQuantityPlayers;
unsigned dealerPosition;
int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
int smallBlind;
int startCash;
int lastPlayersTurn;
unsigned lastActionPlayer;
int lastPlayersTurn;
unsigned lastActionPlayer;
bool allInCondition;
bool cardsShown;
bool allInCondition;
bool cardsShown;
// hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ...
int bettingRoundsPlayed;
// hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ...
int bettingRoundsPlayed;
};
#endif
+19 -18
View File
@@ -23,10 +23,10 @@ using namespace std;
ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
: PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type),
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0),
myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false)
: PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type),
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0),
myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false)
{
myBestHandPosition[0] = myBestHandPosition[1] = myBestHandPosition[2] = myBestHandPosition[3] = myBestHandPosition[4] = 0;
myNiveau[0] = myNiveau[1] = myNiveau[2] = 0;
@@ -266,13 +266,17 @@ ClientPlayer::setMyCardsFlip(bool theValue, int state)
// log flipping cards
if (myCardsFlip) {
switch(state) {
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
case 1:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
break;
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
case 2:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
break;
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
case 3:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
break;
default: ;
default:
;
}
}
}
@@ -363,8 +367,7 @@ void
ClientPlayer::setMyAggressive(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i=0; i<6; i++)
{
for (int i=0; i<6; i++) {
myAggressive[i] = myAggressive[i+1];
}
myAggressive[6] = theValue;
@@ -375,14 +378,13 @@ ClientPlayer::getMyAggressive() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
int sum = 0;
for (int i=0; i<7; i++)
{
for (int i=0; i<7; i++) {
sum += myAggressive[i];
}
return sum;
}
void
void
ClientPlayer::setSBluff(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
@@ -527,10 +529,9 @@ bool ClientPlayer::checkIfINeedToShowCards()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it)
{
if(*it == myUniqueID) return true;
}
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) {
if(*it == myUniqueID) return true;
}
return false;
return false;
}
+6 -3
View File
@@ -29,7 +29,8 @@ class CardsValue;
class ConfigFile;
class HandInterface;
class ClientPlayer : public PlayerInterface{
class ClientPlayer : public PlayerInterface
{
public:
ClientPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
~ClientPlayer();
@@ -134,7 +135,9 @@ public:
boost::shared_ptr<SessionData> getNetSessionData();
// unused as client
unsigned getActionTimeoutCounter() const {return 0;}
unsigned getActionTimeoutCounter() const {
return 0;
}
void incrementActionTimeoutCounter() {}
void resetActionTimeoutCounter() {}
@@ -171,7 +174,7 @@ private:
int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin
int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big
bool myActiveStatus; // 0 = inactive, 1 = active
bool myStayOnTableStatus; // 0 = left, 1 = stay
bool myStayOnTableStatus; // 0 = left, 1 = stay
bool myTurn; // 0 = no, 1 = yes
bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
int myRoundStartCash;
+4 -3
View File
@@ -25,7 +25,8 @@
class SessionData;
class PlayerInterface{
class PlayerInterface
{
public:
virtual ~PlayerInterface() =0;
@@ -66,8 +67,8 @@ public:
virtual void setMyActiveStatus(bool theValue) =0;
virtual bool getMyActiveStatus() const =0;
virtual void setMyStayOnTableStatus(bool theValue) =0;
virtual bool getMyStayOnTableStatus() const =0;
virtual void setMyStayOnTableStatus(bool theValue) =0;
virtual bool getMyStayOnTableStatus() const =0;
virtual void setMyCards(int* theValue) =0;
virtual void getMyCards(int* theValue) const =0;