Tools - random number function is now static. Fixed player number issue with network games (GUI player number needs to be 0), this still requires some work.
This commit is contained in:
@@ -111,12 +111,12 @@ Server Notification: Game Start
|
|||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Message Type = 5 | Message Length = 8 |
|
| Message Type = 5 | Message Length = 8 |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Start Dealer Pos | Reserved |
|
| Start Dealer Player Id | Reserved |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
[ Dealer Pos can be different for each game, therefore it is not
|
[ Dealer Pos can be different for each game, therefore it is not
|
||||||
transmitted in Join Game ACK. ]
|
transmitted in Join Game ACK. ]
|
||||||
[ It is not necessary to transmit the Dealer Pos, because the server
|
[ It is not necessary to transmit the Dealer Id, because the server
|
||||||
decides which player's turn it is. This is only for fast and simple
|
decides which player's turn it is. This is only for fast and simple
|
||||||
GUI display. ]
|
GUI display. ]
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Karten generieren und Board sowie Player zuweisen
|
// Karten generieren und Board sowie Player zuweisen
|
||||||
Tools myTool;
|
|
||||||
int *cardsArray = new int[2*actualQuantityPlayers+5];
|
int *cardsArray = new int[2*actualQuantityPlayers+5];
|
||||||
myTool.getRandNumber(0, 51, 2*actualQuantityPlayers+5, cardsArray, 1);
|
Tools::getRandNumber(0, 51, 2*actualQuantityPlayers+5, cardsArray, 1);
|
||||||
int tempBoardArray[5];
|
int tempBoardArray[5];
|
||||||
int tempPlayerArray[2];
|
int tempPlayerArray[2];
|
||||||
int tempPlayerAndBoardArray[7];
|
int tempPlayerAndBoardArray[7];
|
||||||
@@ -81,7 +80,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
|||||||
|
|
||||||
// sBluff für alle aktiver Spieler außer human player setzen
|
// sBluff für alle aktiver Spieler außer human player setzen
|
||||||
if(i) {
|
if(i) {
|
||||||
myTool.getRandNumber(1,100,1,&sBluff,0);
|
Tools::getRandNumber(1,100,1,&sBluff,0);
|
||||||
playerArray[i]->setSBluff(sBluff);
|
playerArray[i]->setSBluff(sBluff);
|
||||||
playerArray[i]->setSBluffStatus(0);
|
playerArray[i]->setSBluffStatus(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,8 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
|
|||||||
myAggressive[i] = 0;
|
myAggressive[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tools myTool;
|
|
||||||
// Dude zuweisen
|
// Dude zuweisen
|
||||||
myTool.getRandNumber(3 , 5, 1, &myDude, 0);
|
Tools::getRandNumber(3 , 5, 1, &myDude, 0);
|
||||||
// cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl;
|
// cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl;
|
||||||
|
|
||||||
// Dude4 zuweisen
|
// Dude4 zuweisen
|
||||||
@@ -64,7 +63,7 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
|
|||||||
int count = 4;
|
int count = 4;
|
||||||
|
|
||||||
int *tempArray = new int[count];
|
int *tempArray = new int[count];
|
||||||
myTool.getRandNumber(0, 2*interval, count, tempArray, 0);
|
Tools::getRandNumber(0, 2*interval, count, tempArray, 0);
|
||||||
for(i=0; i<count; i++) {
|
for(i=0; i<count; i++) {
|
||||||
myDude4 += tempArray[i];
|
myDude4 += tempArray[i];
|
||||||
}
|
}
|
||||||
@@ -146,7 +145,6 @@ void LocalPlayer::preflopEngine() {
|
|||||||
int bet = 0;
|
int bet = 0;
|
||||||
int raise = 0;
|
int raise = 0;
|
||||||
int cBluff;
|
int cBluff;
|
||||||
Tools myTool;
|
|
||||||
|
|
||||||
// temporär solange preflopValue und flopValue noch nicht bereinigt für sechs und sieben spieler
|
// temporär solange preflopValue und flopValue noch nicht bereinigt für sechs und sieben spieler
|
||||||
int players = actualHand->getActualQuantityPlayers();
|
int players = actualHand->getActualQuantityPlayers();
|
||||||
@@ -194,7 +192,7 @@ void LocalPlayer::preflopEngine() {
|
|||||||
// cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl;
|
// cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl;
|
||||||
|
|
||||||
// Check-Bluff generieren
|
// Check-Bluff generieren
|
||||||
myTool.getRandNumber(1,100,1,&cBluff,0);
|
Tools::getRandNumber(1,100,1,&cBluff,0);
|
||||||
|
|
||||||
// aktive oder passivie Situation ? -> im preflop nur passiv
|
// aktive oder passivie Situation ? -> im preflop nur passiv
|
||||||
|
|
||||||
@@ -338,7 +336,6 @@ void LocalPlayer::flopEngine() {
|
|||||||
int i;
|
int i;
|
||||||
int cBluff;
|
int cBluff;
|
||||||
int pBluff;
|
int pBluff;
|
||||||
Tools myTool;
|
|
||||||
int rand;
|
int rand;
|
||||||
|
|
||||||
// übergang solange preflopValue und flopValue noch nicht bereinigt
|
// übergang solange preflopValue und flopValue noch nicht bereinigt
|
||||||
@@ -369,7 +366,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check-Bluff generieren
|
// Check-Bluff generieren
|
||||||
myTool.getRandNumber(1,100,1,&cBluff,0);
|
Tools::getRandNumber(1,100,1,&cBluff,0);
|
||||||
|
|
||||||
// aktiv oder passiv?
|
// aktiv oder passiv?
|
||||||
if(actualHand->getFlop()->getHighestSet() > 0) {
|
if(actualHand->getFlop()->getHighestSet() > 0) {
|
||||||
@@ -475,7 +472,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// Position
|
// Position
|
||||||
if(myButton == 1) {
|
if(myButton == 1) {
|
||||||
// Position-Bluff generieren
|
// Position-Bluff generieren
|
||||||
myTool.getRandNumber(1,100,1,&pBluff,0);
|
Tools::getRandNumber(1,100,1,&pBluff,0);
|
||||||
if(pBluff <= 16) {
|
if(pBluff <= 16) {
|
||||||
bet = (pBluff/4)*2*actualHand->getSmallBlind();
|
bet = (pBluff/4)*2*actualHand->getSmallBlind();
|
||||||
// bet zu klein
|
// bet zu klein
|
||||||
@@ -513,7 +510,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// Standard-Raise-Routine
|
// Standard-Raise-Routine
|
||||||
else {
|
else {
|
||||||
// raise-Betrag ermitteln
|
// raise-Betrag ermitteln
|
||||||
myTool.getRandNumber(1,8,1,&rand,0);
|
Tools::getRandNumber(1,8,1,&rand,0);
|
||||||
raise = rand*actualHand->getSmallBlind();
|
raise = rand*actualHand->getSmallBlind();
|
||||||
// raise-Betrag zu klein -> mindestens Standard-raise
|
// raise-Betrag zu klein -> mindestens Standard-raise
|
||||||
if(raise < actualHand->getFlop()->getHighestSet()) {
|
if(raise < actualHand->getFlop()->getHighestSet()) {
|
||||||
@@ -537,7 +534,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
|
|
||||||
// cout << "sBLUFF!" << endl;
|
// cout << "sBLUFF!" << endl;
|
||||||
|
|
||||||
myTool.getRandNumber(1,8,1,&rand,0);
|
Tools::getRandNumber(1,8,1,&rand,0);
|
||||||
bet = rand*actualHand->getSmallBlind();
|
bet = rand*actualHand->getSmallBlind();
|
||||||
// bet zu klein
|
// bet zu klein
|
||||||
if(bet == 0) {
|
if(bet == 0) {
|
||||||
@@ -576,7 +573,6 @@ void LocalPlayer::flopEngine() {
|
|||||||
//
|
//
|
||||||
// int i;
|
// int i;
|
||||||
//
|
//
|
||||||
// Tools myTools;
|
|
||||||
//
|
//
|
||||||
// for(i=0; i<2; i++) tempArray[i] = myCards[i];
|
// for(i=0; i<2; i++) tempArray[i] = myCards[i];
|
||||||
// actualBoard->getMyCards(boardCards);
|
// actualBoard->getMyCards(boardCards);
|
||||||
@@ -601,7 +597,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// case 6: {}
|
// case 6: {}
|
||||||
// case 5: {}
|
// case 5: {}
|
||||||
// case 4: {
|
// case 4: {
|
||||||
// myTools.getRandNumber(0,100,1,&cBluff,0);
|
// Tools::getRandNumber(0,100,1,&cBluff,0);
|
||||||
// if(cBluff < 35) {
|
// if(cBluff < 35) {
|
||||||
// myAction = 2;
|
// myAction = 2;
|
||||||
// }
|
// }
|
||||||
@@ -623,7 +619,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// case 3: {
|
// case 3: {
|
||||||
// switch(info[3]) {
|
// switch(info[3]) {
|
||||||
// case 2: {
|
// case 2: {
|
||||||
// myTools.getRandNumber(0,100,1,&cBluff,0);
|
// Tools::getRandNumber(0,100,1,&cBluff,0);
|
||||||
// if(cBluff < 35) {
|
// if(cBluff < 35) {
|
||||||
// myAction = 2;
|
// myAction = 2;
|
||||||
// }
|
// }
|
||||||
@@ -643,7 +639,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
// case 1: {
|
// case 1: {
|
||||||
// myTools.getRandNumber(0,100,1,&cBluff,0);
|
// Tools::getRandNumber(0,100,1,&cBluff,0);
|
||||||
// if(cBluff < 40) {
|
// if(cBluff < 40) {
|
||||||
// myAction = 2;
|
// myAction = 2;
|
||||||
// }
|
// }
|
||||||
@@ -663,7 +659,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
// default: {
|
// default: {
|
||||||
// myTools.getRandNumber(0,100,1,&sBluff,0);
|
// Tools::getRandNumber(0,100,1,&sBluff,0);
|
||||||
// if(info[1] >= 10 && sBluff <= 40) {
|
// if(info[1] >= 10 && sBluff <= 40) {
|
||||||
// bet = (sBluff/10)*2*actualHand->getSmallBlind();
|
// bet = (sBluff/10)*2*actualHand->getSmallBlind();
|
||||||
// if(bet < 2*actualHand->getSmallBlind()) bet = 2*actualHand->getSmallBlind();
|
// if(bet < 2*actualHand->getSmallBlind()) bet = 2*actualHand->getSmallBlind();
|
||||||
@@ -679,7 +675,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// case 2: {
|
// case 2: {
|
||||||
// switch(info[3]) {
|
// switch(info[3]) {
|
||||||
// case 2: {
|
// case 2: {
|
||||||
// myTools.getRandNumber(0,100,1,&cBluff,0);
|
// Tools::getRandNumber(0,100,1,&cBluff,0);
|
||||||
// if(cBluff > 80) {
|
// if(cBluff > 80) {
|
||||||
// myAction = 2;
|
// myAction = 2;
|
||||||
// }
|
// }
|
||||||
@@ -695,7 +691,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
// default: {
|
// default: {
|
||||||
// myTools.getRandNumber(0,100,1,&cBluff,0);
|
// Tools::getRandNumber(0,100,1,&cBluff,0);
|
||||||
// if(cBluff > 90) {
|
// if(cBluff > 90) {
|
||||||
// myAction = 2;
|
// myAction = 2;
|
||||||
// }
|
// }
|
||||||
@@ -714,7 +710,7 @@ void LocalPlayer::flopEngine() {
|
|||||||
// break;
|
// break;
|
||||||
// case 1: {
|
// case 1: {
|
||||||
// if(!info[2]) {
|
// if(!info[2]) {
|
||||||
// myTools.getRandNumber(0,100,1,&sBluff,0);
|
// Tools::getRandNumber(0,100,1,&sBluff,0);
|
||||||
// switch(info[3]) {
|
// switch(info[3]) {
|
||||||
// case 2: {}
|
// case 2: {}
|
||||||
// case 1: {
|
// case 1: {
|
||||||
@@ -833,7 +829,6 @@ void LocalPlayer::turnEngine() {
|
|||||||
int i;
|
int i;
|
||||||
int cBluff;
|
int cBluff;
|
||||||
int pBluff;
|
int pBluff;
|
||||||
Tools myTool;
|
|
||||||
int rand;
|
int rand;
|
||||||
|
|
||||||
readFile();
|
readFile();
|
||||||
@@ -863,7 +858,7 @@ void LocalPlayer::turnEngine() {
|
|||||||
if(individualHighestSet > myCash) individualHighestSet = myCash;
|
if(individualHighestSet > myCash) individualHighestSet = myCash;
|
||||||
|
|
||||||
// Check-Bluff generieren
|
// Check-Bluff generieren
|
||||||
myTool.getRandNumber(1,100,1,&cBluff,0);
|
Tools::getRandNumber(1,100,1,&cBluff,0);
|
||||||
|
|
||||||
// aktiv oder passiv?
|
// aktiv oder passiv?
|
||||||
if(actualHand->getTurn()->getHighestSet() > 0) {
|
if(actualHand->getTurn()->getHighestSet() > 0) {
|
||||||
@@ -967,7 +962,7 @@ void LocalPlayer::turnEngine() {
|
|||||||
// Position
|
// Position
|
||||||
if(myButton == 1) {
|
if(myButton == 1) {
|
||||||
// Position-Bluff generieren
|
// Position-Bluff generieren
|
||||||
myTool.getRandNumber(1,100,1,&pBluff,0);
|
Tools::getRandNumber(1,100,1,&pBluff,0);
|
||||||
if(pBluff <= 16) {
|
if(pBluff <= 16) {
|
||||||
bet = (pBluff/4)*2*actualHand->getSmallBlind();
|
bet = (pBluff/4)*2*actualHand->getSmallBlind();
|
||||||
// bet zu klein
|
// bet zu klein
|
||||||
@@ -1004,7 +999,7 @@ void LocalPlayer::turnEngine() {
|
|||||||
// Standard-Raise-Routine
|
// Standard-Raise-Routine
|
||||||
else {
|
else {
|
||||||
// raise-Betrag ermitteln
|
// raise-Betrag ermitteln
|
||||||
myTool.getRandNumber(1,8,1,&rand,0);
|
Tools::getRandNumber(1,8,1,&rand,0);
|
||||||
raise = rand*actualHand->getSmallBlind();
|
raise = rand*actualHand->getSmallBlind();
|
||||||
// raise-Betrag zu klein -> mindestens Standard-raise
|
// raise-Betrag zu klein -> mindestens Standard-raise
|
||||||
if(raise < actualHand->getTurn()->getHighestSet()) {
|
if(raise < actualHand->getTurn()->getHighestSet()) {
|
||||||
@@ -1028,7 +1023,7 @@ void LocalPlayer::turnEngine() {
|
|||||||
|
|
||||||
// cout << "sBLUFF!" << endl;
|
// cout << "sBLUFF!" << endl;
|
||||||
|
|
||||||
myTool.getRandNumber(1,8,1,&rand,0);
|
Tools::getRandNumber(1,8,1,&rand,0);
|
||||||
bet = rand*actualHand->getSmallBlind();
|
bet = rand*actualHand->getSmallBlind();
|
||||||
// bet zu klein
|
// bet zu klein
|
||||||
if(bet == 0) {
|
if(bet == 0) {
|
||||||
@@ -1077,7 +1072,6 @@ void LocalPlayer::riverEngine() {
|
|||||||
int raise = 0;
|
int raise = 0;
|
||||||
int bet = 0;
|
int bet = 0;
|
||||||
int i;
|
int i;
|
||||||
Tools myTool;
|
|
||||||
int rand;
|
int rand;
|
||||||
int pBluff;
|
int pBluff;
|
||||||
|
|
||||||
@@ -1195,7 +1189,7 @@ void LocalPlayer::riverEngine() {
|
|||||||
// Position
|
// Position
|
||||||
if(myButton == 1) {
|
if(myButton == 1) {
|
||||||
// Position-Bluff generieren
|
// Position-Bluff generieren
|
||||||
myTool.getRandNumber(1,100,1,&pBluff,0);
|
Tools::getRandNumber(1,100,1,&pBluff,0);
|
||||||
if(pBluff <= 20) {
|
if(pBluff <= 20) {
|
||||||
bet = (pBluff/4)*2*actualHand->getSmallBlind();
|
bet = (pBluff/4)*2*actualHand->getSmallBlind();
|
||||||
// bet zu klein
|
// bet zu klein
|
||||||
@@ -1232,7 +1226,7 @@ void LocalPlayer::riverEngine() {
|
|||||||
// Standard-Raise-Routine
|
// Standard-Raise-Routine
|
||||||
else {
|
else {
|
||||||
// raise-Betrag ermitteln
|
// raise-Betrag ermitteln
|
||||||
myTool.getRandNumber(1,8,1,&rand,0);
|
Tools::getRandNumber(1,8,1,&rand,0);
|
||||||
raise = rand*actualHand->getSmallBlind();
|
raise = rand*actualHand->getSmallBlind();
|
||||||
// raise-Betrag zu klein -> mindestens Standard-raise
|
// raise-Betrag zu klein -> mindestens Standard-raise
|
||||||
if(raise < actualHand->getRiver()->getHighestSet()) {
|
if(raise < actualHand->getRiver()->getHighestSet()) {
|
||||||
@@ -1256,7 +1250,7 @@ void LocalPlayer::riverEngine() {
|
|||||||
|
|
||||||
// cout << "sBLUFF!" << endl;
|
// cout << "sBLUFF!" << endl;
|
||||||
|
|
||||||
myTool.getRandNumber(1,8,1,&rand,0);
|
Tools::getRandNumber(1,8,1,&rand,0);
|
||||||
bet = rand*actualHand->getSmallBlind();
|
bet = rand*actualHand->getSmallBlind();
|
||||||
// bet zu klein
|
// bet zu klein
|
||||||
if(bet == 0) {
|
if(bet == 0) {
|
||||||
@@ -2546,16 +2540,15 @@ void LocalPlayer::preflopEngine3() {
|
|||||||
|
|
||||||
// cout << "nextID " << actualHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl;
|
// cout << "nextID " << actualHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl;
|
||||||
|
|
||||||
Tools myTool;
|
|
||||||
int raise = 0;
|
int raise = 0;
|
||||||
|
|
||||||
// Bauchgefhl (zufï¿Ålig)
|
// Bauchgefhl (zufï¿Ålig)
|
||||||
int tempRand;
|
int tempRand;
|
||||||
myTool.getRandNumber(1,10,1,&tempRand,0);
|
Tools::getRandNumber(1,10,1,&tempRand,0);
|
||||||
|
|
||||||
// bluff, checkbluff
|
// bluff, checkbluff
|
||||||
int bluff;
|
int bluff;
|
||||||
myTool.getRandNumber(1,100,1,&bluff,0);
|
Tools::getRandNumber(1,100,1,&bluff,0);
|
||||||
|
|
||||||
// cout << "preflop-bluff " << bluff << endl;
|
// cout << "preflop-bluff " << bluff << endl;
|
||||||
|
|
||||||
@@ -2567,7 +2560,7 @@ void LocalPlayer::preflopEngine3() {
|
|||||||
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
||||||
int tempFold;
|
int tempFold;
|
||||||
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
|
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
|
||||||
myTool.getRandNumber(2,3,1,&tempFold,0);
|
Tools::getRandNumber(2,3,1,&tempFold,0);
|
||||||
|
|
||||||
// FOLD --> wenn Potential negativ oder HighestSet zu hoch
|
// FOLD --> wenn Potential negativ oder HighestSet zu hoch
|
||||||
if( (potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * actualHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) {
|
if( (potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * actualHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) {
|
||||||
@@ -2780,17 +2773,15 @@ void LocalPlayer::flopEngine3() {
|
|||||||
double percent = (countMy*1.0)/(countAll*1.0);
|
double percent = (countMy*1.0)/(countAll*1.0);
|
||||||
// cout << "Prozent: " << percent << endl;
|
// cout << "Prozent: " << percent << endl;
|
||||||
|
|
||||||
Tools myTool;
|
|
||||||
|
|
||||||
int raise = 0;
|
int raise = 0;
|
||||||
|
|
||||||
// Bauchgefhl (zufï¿Ålig)
|
// Bauchgefhl (zufï¿Ålig)
|
||||||
int tempRand;
|
int tempRand;
|
||||||
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
|
Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
|
||||||
|
|
||||||
// bluff, checkbluff
|
// bluff, checkbluff
|
||||||
int bluff;
|
int bluff;
|
||||||
myTool.getRandNumber(1,100,1,&bluff,0);
|
Tools::getRandNumber(1,100,1,&bluff,0);
|
||||||
|
|
||||||
// cout << "flop-bluff " << bluff << endl;
|
// cout << "flop-bluff " << bluff << endl;
|
||||||
|
|
||||||
@@ -2802,7 +2793,7 @@ void LocalPlayer::flopEngine3() {
|
|||||||
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
||||||
int tempFold;
|
int tempFold;
|
||||||
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
|
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
|
||||||
myTool.getRandNumber(2,3,1,&tempFold,0);
|
Tools::getRandNumber(2,3,1,&tempFold,0);
|
||||||
|
|
||||||
// FOLD --> wenn potential negativ oder HighestSet zu hoch
|
// FOLD --> wenn potential negativ oder HighestSet zu hoch
|
||||||
if(( potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * actualHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * actualHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 18) {
|
if(( potential*setToHighest<0 || (setToHighest > tempFold * actualHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * actualHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * actualHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * actualHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * actualHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 18) {
|
||||||
@@ -2948,16 +2939,15 @@ void LocalPlayer::turnEngine3() {
|
|||||||
double percent = (countMy*1.0)/(countAll*1.0);
|
double percent = (countMy*1.0)/(countAll*1.0);
|
||||||
// cout << "Prozent: " << percent << endl;
|
// cout << "Prozent: " << percent << endl;
|
||||||
|
|
||||||
Tools myTool;
|
|
||||||
int raise;
|
int raise;
|
||||||
|
|
||||||
// Bauchgefhl (zufï¿Ålig)
|
// Bauchgefhl (zufï¿Ålig)
|
||||||
int tempRand;
|
int tempRand;
|
||||||
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
|
Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
|
||||||
|
|
||||||
// bluff, checkbluff
|
// bluff, checkbluff
|
||||||
int bluff;
|
int bluff;
|
||||||
myTool.getRandNumber(1,100,1,&bluff,0);
|
Tools::getRandNumber(1,100,1,&bluff,0);
|
||||||
|
|
||||||
// cout << "turn-bluff " << bluff << endl;
|
// cout << "turn-bluff " << bluff << endl;
|
||||||
|
|
||||||
@@ -2969,7 +2959,7 @@ void LocalPlayer::turnEngine3() {
|
|||||||
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
||||||
int tempFold;
|
int tempFold;
|
||||||
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(7*actualHand->getSmallBlind());
|
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(7*actualHand->getSmallBlind());
|
||||||
myTool.getRandNumber(3,4,1,&tempFold,0);
|
Tools::getRandNumber(3,4,1,&tempFold,0);
|
||||||
|
|
||||||
// FOLD
|
// FOLD
|
||||||
// --> wenn potential negativ oder HighestSet zu hoch
|
// --> wenn potential negativ oder HighestSet zu hoch
|
||||||
@@ -3111,16 +3101,15 @@ void LocalPlayer::riverEngine3() {
|
|||||||
double percent = (countMy*1.0)/(countAll*1.0);
|
double percent = (countMy*1.0)/(countAll*1.0);
|
||||||
// cout << "Prozent: " << percent << endl;
|
// cout << "Prozent: " << percent << endl;
|
||||||
|
|
||||||
Tools myTool;
|
|
||||||
int raise;
|
int raise;
|
||||||
|
|
||||||
// Bauchgefhl (zufï¿Ålig)
|
// Bauchgefhl (zufï¿Ålig)
|
||||||
int tempRand;
|
int tempRand;
|
||||||
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
|
Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
|
||||||
|
|
||||||
// bluff, checkbluff
|
// bluff, checkbluff
|
||||||
int bluff;
|
int bluff;
|
||||||
myTool.getRandNumber(1,100,1,&bluff,0);
|
Tools::getRandNumber(1,100,1,&bluff,0);
|
||||||
|
|
||||||
// cout << "river-bluff " << bluff << endl;
|
// cout << "river-bluff " << bluff << endl;
|
||||||
|
|
||||||
@@ -3132,7 +3121,7 @@ void LocalPlayer::riverEngine3() {
|
|||||||
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
|
||||||
int tempFold;
|
int tempFold;
|
||||||
tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(6*actualHand->getSmallBlind());
|
tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(6*actualHand->getSmallBlind());
|
||||||
// myTool.getRandNumber(4,6,1,&tempFold,0);
|
// Tools::getRandNumber(4,6,1,&tempFold,0);
|
||||||
|
|
||||||
// FOLD
|
// FOLD
|
||||||
// --> wenn potential negativ oder HighestSet zu hoch
|
// --> wenn potential negativ oder HighestSet zu hoch
|
||||||
|
|||||||
@@ -22,16 +22,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Tools::Tools()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Tools::~Tools()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different) {
|
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different) {
|
||||||
|
|
||||||
int r = end-start+1;
|
int r = end-start+1;
|
||||||
|
|||||||
@@ -26,11 +26,7 @@
|
|||||||
|
|
||||||
class Tools{
|
class Tools{
|
||||||
public:
|
public:
|
||||||
Tools();
|
static void getRandNumber(int, int, int, int*, bool);
|
||||||
|
|
||||||
~Tools();
|
|
||||||
|
|
||||||
void getRandNumber(int, int, int, int*, bool);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+17
-4
@@ -35,8 +35,8 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
|||||||
startQuantityPlayers(gameData.numberOfPlayers),
|
startQuantityPlayers(gameData.numberOfPlayers),
|
||||||
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
||||||
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
||||||
myGameID(gameId), guiPlayerNum(gameData.guiPlayerNum), actualQuantityPlayers(gameData.numberOfPlayers),
|
myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers),
|
||||||
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(startData.startDealerPos)
|
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0)
|
||||||
{
|
{
|
||||||
// cout << "Create Game Object" << "\n";
|
// cout << "Create Game Object" << "\n";
|
||||||
int i;
|
int i;
|
||||||
@@ -47,14 +47,27 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
|||||||
playerArray[i] = 0;
|
playerArray[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dealer Position bestimmen
|
||||||
|
PlayerDataList::const_iterator player_i = playerDataList.begin();
|
||||||
|
PlayerDataList::const_iterator player_end = playerDataList.end();
|
||||||
|
|
||||||
|
while (player_i != player_end)
|
||||||
|
{
|
||||||
|
if ((*player_i)->GetUniqueId() == startData.startDealerPlayerId)
|
||||||
|
{
|
||||||
|
dealerPosition = (*player_i)->GetNumber();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++player_i;
|
||||||
|
}
|
||||||
|
|
||||||
// Board erstellen
|
// Board erstellen
|
||||||
actualBoard = myFactory->createBoard();
|
actualBoard = myFactory->createBoard();
|
||||||
|
|
||||||
|
|
||||||
// Player erstellen
|
// Player erstellen
|
||||||
PlayerDataList::const_iterator player_i = playerDataList.begin();
|
player_i = playerDataList.begin();
|
||||||
PlayerDataList::const_iterator player_end = playerDataList.end();
|
player_end = playerDataList.end();
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
|
||||||
string myName;
|
string myName;
|
||||||
|
|||||||
+1
-2
@@ -64,8 +64,7 @@ public:
|
|||||||
int getDealerPosition() const { return dealerPosition; }
|
int getDealerPosition() const { return dealerPosition; }
|
||||||
|
|
||||||
int getMyGameID() const { return myGameID; }
|
int getMyGameID() const { return myGameID; }
|
||||||
int getGuiPlayerNum() const { return guiPlayerNum; }
|
|
||||||
|
|
||||||
//Zufgriff Laufvariablen
|
//Zufgriff Laufvariablen
|
||||||
void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; }
|
void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; }
|
||||||
int getActualQuantityPlayers() const { return actualQuantityPlayers; }
|
int getActualQuantityPlayers() const { return actualQuantityPlayers; }
|
||||||
|
|||||||
+3
-5
@@ -26,20 +26,18 @@
|
|||||||
struct GameData
|
struct GameData
|
||||||
{
|
{
|
||||||
GameData() : numberOfPlayers(0), startCash(0), smallBlind(0),
|
GameData() : numberOfPlayers(0), startCash(0), smallBlind(0),
|
||||||
handsBeforeRaise(1), guiSpeed(4), guiPlayerNum(0), guiPlayerUniqueId(0) {}
|
handsBeforeRaise(1), guiSpeed(4) {}
|
||||||
int numberOfPlayers;
|
int numberOfPlayers;
|
||||||
int startCash;
|
int startCash;
|
||||||
int smallBlind;
|
int smallBlind;
|
||||||
int handsBeforeRaise;
|
int handsBeforeRaise;
|
||||||
int guiSpeed;
|
int guiSpeed;
|
||||||
int guiPlayerNum;
|
|
||||||
unsigned guiPlayerUniqueId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StartData
|
struct StartData
|
||||||
{
|
{
|
||||||
StartData() : startDealerPos(0) {}
|
StartData() : startDealerPlayerId(0) {}
|
||||||
int startDealerPos;
|
unsigned startDealerPlayerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -657,8 +657,9 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
|||||||
}
|
}
|
||||||
// Set dealer pos.
|
// Set dealer pos.
|
||||||
StartData startData;
|
StartData startData;
|
||||||
Tools myTool;
|
int tmpDealerPos = 0;
|
||||||
myTool.getRandNumber(0, gameData.numberOfPlayers-1, 1, &startData.startDealerPos, 0);
|
Tools::getRandNumber(0, gameData.numberOfPlayers-1, 1, &tmpDealerPos, 0);
|
||||||
|
startData.startDealerPlayerId = static_cast<unsigned>(tmpDealerPos);
|
||||||
|
|
||||||
//Start Game!!!
|
//Start Game!!!
|
||||||
mySession->startLocalGame(gameData, startData);
|
mySession->startLocalGame(gameData, startData);
|
||||||
@@ -1188,7 +1189,7 @@ void mainWindowImpl::dealHoleCards() {
|
|||||||
currentGame->getPlayerArray()[i]->getMyCards(tempCardsIntArray);
|
currentGame->getPlayerArray()[i]->getMyCards(tempCardsIntArray);
|
||||||
for(j=0; j<2; j++) {
|
for(j=0; j<2; j++) {
|
||||||
if(currentGame->getPlayerArray()[i]->getMyActiveStatus()) {
|
if(currentGame->getPlayerArray()[i]->getMyActiveStatus()) {
|
||||||
if ((i == currentGame->getGuiPlayerNum()) || debugMode) {
|
if ((i == 0) || debugMode) {
|
||||||
tempCardsPixmapArray[j].load(":/cards/resources/graphics/cards/"+QString::number(tempCardsIntArray[j], 10)+".png");
|
tempCardsPixmapArray[j].load(":/cards/resources/graphics/cards/"+QString::number(tempCardsIntArray[j], 10)+".png");
|
||||||
holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j],FALSE);
|
holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j],FALSE);
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ protected:
|
|||||||
void SetGameData(const GameData &gameData);
|
void SetGameData(const GameData &gameData);
|
||||||
const StartData &GetStartData() const;
|
const StartData &GetStartData() const;
|
||||||
void SetStartData(const StartData &startData);
|
void SetStartData(const StartData &startData);
|
||||||
|
int GetGuiPlayerNum() const;
|
||||||
|
void SetGuiPlayerNum(int guiPlayerNum);
|
||||||
|
|
||||||
boost::shared_ptr<Game> GetGame();
|
boost::shared_ptr<Game> GetGame();
|
||||||
|
|
||||||
@@ -80,7 +82,7 @@ protected:
|
|||||||
|
|
||||||
void AddPlayerData(boost::shared_ptr<PlayerData> playerData);
|
void AddPlayerData(boost::shared_ptr<PlayerData> playerData);
|
||||||
void RemovePlayerData(unsigned playerId);
|
void RemovePlayerData(unsigned playerId);
|
||||||
const PlayerDataList &GetPlayerDataList() const;
|
PlayerDataList GetMappedPlayerDataList() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -99,6 +101,7 @@ private:
|
|||||||
boost::shared_ptr<Game> m_game;
|
boost::shared_ptr<Game> m_game;
|
||||||
|
|
||||||
unsigned m_curGameId;
|
unsigned m_curGameId;
|
||||||
|
int m_guiPlayerNum;
|
||||||
|
|
||||||
friend class ClientStateInit;
|
friend class ClientStateInit;
|
||||||
friend class ClientStateStartResolve;
|
friend class ClientStateStartResolve;
|
||||||
|
|||||||
@@ -391,10 +391,11 @@ ClientStateWaitSession::Process(ClientThread &client)
|
|||||||
NetPacketJoinGameAck::Data joinGameAckData;
|
NetPacketJoinGameAck::Data joinGameAckData;
|
||||||
tmpPacket->ToNetPacketJoinGameAck()->GetData(joinGameAckData);
|
tmpPacket->ToNetPacketJoinGameAck()->GetData(joinGameAckData);
|
||||||
client.SetGameData(joinGameAckData.gameData);
|
client.SetGameData(joinGameAckData.gameData);
|
||||||
|
client.SetGuiPlayerNum(joinGameAckData.yourPlayerNum);
|
||||||
|
|
||||||
// TODO: Type Human is fixed here.
|
// TODO: Type Human is fixed here.
|
||||||
boost::shared_ptr<PlayerData> playerData(
|
boost::shared_ptr<PlayerData> playerData(
|
||||||
new PlayerData(joinGameAckData.gameData.guiPlayerUniqueId, joinGameAckData.gameData.guiPlayerNum, PLAYER_TYPE_HUMAN));
|
new PlayerData(joinGameAckData.yourPlayerUniqueId, joinGameAckData.yourPlayerNum, PLAYER_TYPE_HUMAN));
|
||||||
playerData->SetName(context.GetPlayerName());
|
playerData->SetName(context.GetPlayerName());
|
||||||
client.AddPlayerData(playerData);
|
client.AddPlayerData(playerData);
|
||||||
|
|
||||||
@@ -512,7 +513,9 @@ ClientStateWaitHand::Process(ClientThread &client)
|
|||||||
int myCards[2];
|
int myCards[2];
|
||||||
myCards[0] = (int)tmpData.yourCards[0];
|
myCards[0] = (int)tmpData.yourCards[0];
|
||||||
myCards[1] = (int)tmpData.yourCards[1];
|
myCards[1] = (int)tmpData.yourCards[1];
|
||||||
client.GetGame()->getPlayerArray()[client.GetGame()->getGuiPlayerNum()]->setMyCards(myCards);
|
client.GetGame()->getPlayerArray()[0]->setMyCards(myCards);
|
||||||
|
client.GetGame()->initHand();
|
||||||
|
client.GetGame()->startHand();
|
||||||
client.GetGui().dealHoleCards();
|
client.GetGui().dealHoleCards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
ClientThread::ClientThread(GuiInterface &gui)
|
ClientThread::ClientThread(GuiInterface &gui)
|
||||||
: m_curState(NULL), m_gui(gui), m_curGameId(0)
|
: m_curState(NULL), m_gui(gui), m_curGameId(0), m_guiPlayerNum(0)
|
||||||
{
|
{
|
||||||
m_context.reset(new ClientContext);
|
m_context.reset(new ClientContext);
|
||||||
m_senderCallback.reset(new ClientSenderCallback(*this));
|
m_senderCallback.reset(new ClientSenderCallback(*this));
|
||||||
@@ -118,7 +118,7 @@ ClientThread::Main()
|
|||||||
// EngineFactory erstellen
|
// EngineFactory erstellen
|
||||||
boost::shared_ptr<EngineFactory> factory(new ClientEngineFactory); // LocalEngine erstellen
|
boost::shared_ptr<EngineFactory> factory(new ClientEngineFactory); // LocalEngine erstellen
|
||||||
|
|
||||||
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameId++));
|
m_game.reset(new Game(&m_gui, factory, GetMappedPlayerDataList(), GetGameData(), GetStartData(), m_curGameId++));
|
||||||
GetCallback().SignalNetClientGameStart(m_game);
|
GetCallback().SignalNetClientGameStart(m_game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,6 +196,18 @@ ClientThread::SetStartData(const StartData &startData)
|
|||||||
m_startData = startData;
|
m_startData = startData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ClientThread::GetGuiPlayerNum() const
|
||||||
|
{
|
||||||
|
return m_guiPlayerNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientThread::SetGuiPlayerNum(int guiPlayerNum)
|
||||||
|
{
|
||||||
|
m_guiPlayerNum = guiPlayerNum;
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<Game>
|
boost::shared_ptr<Game>
|
||||||
ClientThread::GetGame()
|
ClientThread::GetGame()
|
||||||
{
|
{
|
||||||
@@ -215,9 +227,6 @@ ClientThread::AddPlayerData(boost::shared_ptr<PlayerData> playerData)
|
|||||||
if (playerData.get() && !playerData->GetName().empty())
|
if (playerData.get() && !playerData->GetName().empty())
|
||||||
{
|
{
|
||||||
m_playerDataList.push_back(playerData);
|
m_playerDataList.push_back(playerData);
|
||||||
// Sort the list by player number.
|
|
||||||
m_playerDataList.sort(*boost::lambda::_1 < *boost::lambda::_2);
|
|
||||||
|
|
||||||
GetCallback().SignalNetClientPlayerJoined(playerData->GetName());
|
GetCallback().SignalNetClientPlayerJoined(playerData->GetName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,9 +253,31 @@ ClientThread::RemovePlayerData(unsigned playerId)
|
|||||||
GetCallback().SignalNetClientPlayerLeft(playerName);
|
GetCallback().SignalNetClientPlayerLeft(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlayerDataList &
|
PlayerDataList
|
||||||
ClientThread::GetPlayerDataList() const
|
ClientThread::GetMappedPlayerDataList() const
|
||||||
{
|
{
|
||||||
return m_playerDataList;
|
PlayerDataList mappedList;
|
||||||
|
|
||||||
|
PlayerDataList::const_iterator i = m_playerDataList.begin();
|
||||||
|
PlayerDataList::const_iterator end = m_playerDataList.end();
|
||||||
|
|
||||||
|
// Create a copy of the player list so that the GUI player
|
||||||
|
// is player 0. This is mapped because the GUI depends on it.
|
||||||
|
while (i != end)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<PlayerData> tmpData(new PlayerData(*(*i)));
|
||||||
|
int numberDiff = tmpData->GetNumber() - GetGuiPlayerNum();
|
||||||
|
if (numberDiff >= 0)
|
||||||
|
tmpData->SetNumber(numberDiff);
|
||||||
|
else
|
||||||
|
tmpData->SetNumber(GetGameData().numberOfPlayers + numberDiff);
|
||||||
|
mappedList.push_back(tmpData);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort the list by player number.
|
||||||
|
mappedList.sort(*boost::lambda::_1 < *boost::lambda::_2);
|
||||||
|
|
||||||
|
return mappedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ struct NetPacketPlayerLeftData
|
|||||||
struct NetPacketGameStartData
|
struct NetPacketGameStartData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
u_int16_t startDealerPos;
|
u_int16_t startDealerPlayerId;
|
||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -528,13 +528,13 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData)
|
|||||||
assert(tmpData);
|
assert(tmpData);
|
||||||
|
|
||||||
tmpData->sessionId = htonl(inData.sessionId);
|
tmpData->sessionId = htonl(inData.sessionId);
|
||||||
|
tmpData->playerId = htons(inData.yourPlayerUniqueId);
|
||||||
|
tmpData->playerNumber = htons(inData.yourPlayerNum);
|
||||||
tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers);
|
tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers);
|
||||||
tmpData->smallBlind = htons(inData.gameData.smallBlind);
|
tmpData->smallBlind = htons(inData.gameData.smallBlind);
|
||||||
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
|
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
|
||||||
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
|
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
|
||||||
tmpData->startCash = htonl(inData.gameData.startCash);
|
tmpData->startCash = htonl(inData.gameData.startCash);
|
||||||
tmpData->playerId = htons(inData.gameData.guiPlayerUniqueId);
|
|
||||||
tmpData->playerNumber = htons(inData.gameData.guiPlayerNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -544,13 +544,13 @@ NetPacketJoinGameAck::GetData(NetPacketJoinGameAck::Data &outData) const
|
|||||||
assert(tmpData);
|
assert(tmpData);
|
||||||
|
|
||||||
outData.sessionId = ntohl(tmpData->sessionId);
|
outData.sessionId = ntohl(tmpData->sessionId);
|
||||||
|
outData.yourPlayerUniqueId = ntohs(tmpData->playerId);
|
||||||
|
outData.yourPlayerNum = ntohs(tmpData->playerNumber);
|
||||||
outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
|
outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
|
||||||
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
|
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
|
||||||
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
|
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
|
||||||
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
|
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
|
||||||
outData.gameData.startCash = ntohl(tmpData->startCash);
|
outData.gameData.startCash = ntohl(tmpData->startCash);
|
||||||
outData.gameData.guiPlayerUniqueId = ntohs(tmpData->playerId);
|
|
||||||
outData.gameData.guiPlayerNum = ntohs(tmpData->playerNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetPacketJoinGameAck *
|
const NetPacketJoinGameAck *
|
||||||
@@ -761,7 +761,7 @@ NetPacketGameStart::SetData(const NetPacketGameStart::Data &inData)
|
|||||||
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
||||||
assert(tmpData);
|
assert(tmpData);
|
||||||
|
|
||||||
tmpData->startDealerPos = htons(inData.startData.startDealerPos);
|
tmpData->startDealerPlayerId = htons(inData.startData.startDealerPlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -770,7 +770,7 @@ NetPacketGameStart::GetData(NetPacketGameStart::Data &outData) const
|
|||||||
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
||||||
assert(tmpData);
|
assert(tmpData);
|
||||||
|
|
||||||
outData.startData.startDealerPos = ntohs(tmpData->startDealerPos);
|
outData.startData.startDealerPlayerId = ntohs(tmpData->startDealerPlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetPacketGameStart *
|
const NetPacketGameStart *
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
|||||||
boost::shared_ptr<NetPacket> answer(new NetPacketJoinGameAck);
|
boost::shared_ptr<NetPacket> answer(new NetPacketJoinGameAck);
|
||||||
NetPacketJoinGameAck::Data joinGameAckData;
|
NetPacketJoinGameAck::Data joinGameAckData;
|
||||||
joinGameAckData.sessionId = session.sessionData->GetId(); // TODO: currently unused.
|
joinGameAckData.sessionId = session.sessionData->GetId(); // TODO: currently unused.
|
||||||
|
joinGameAckData.yourPlayerUniqueId = tmpPlayerData->GetUniqueId();
|
||||||
|
joinGameAckData.yourPlayerNum = tmpPlayerData->GetNumber();
|
||||||
joinGameAckData.gameData = server.GetGameData();
|
joinGameAckData.gameData = server.GetGameData();
|
||||||
joinGameAckData.gameData.guiPlayerUniqueId = tmpPlayerData->GetUniqueId();
|
|
||||||
joinGameAckData.gameData.guiPlayerNum = tmpPlayerData->GetNumber();
|
|
||||||
static_cast<NetPacketJoinGameAck *>(answer.get())->SetData(joinGameAckData);
|
static_cast<NetPacketJoinGameAck *>(answer.get())->SetData(joinGameAckData);
|
||||||
server.GetSender().Send(recvSock, answer);
|
server.GetSender().Send(recvSock, answer);
|
||||||
|
|
||||||
@@ -227,8 +227,9 @@ ServerRecvStateStartGame::Process(ServerRecvThread &server)
|
|||||||
{
|
{
|
||||||
// Set dealer pos.
|
// Set dealer pos.
|
||||||
StartData startData;
|
StartData startData;
|
||||||
Tools myTool;
|
int tmpDealerPos = 0;
|
||||||
myTool.getRandNumber(0, server.GetGameData().numberOfPlayers-1, 1, &startData.startDealerPos, 0);
|
Tools::getRandNumber(0, server.GetGameData().numberOfPlayers-1, 1, &tmpDealerPos, 0);
|
||||||
|
startData.startDealerPlayerId = static_cast<unsigned>(tmpDealerPos);
|
||||||
server.SetStartData(startData);
|
server.SetStartData(startData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ public:
|
|||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
u_int32_t sessionId;
|
u_int32_t sessionId;
|
||||||
|
int16_t yourPlayerNum;
|
||||||
|
u_int16_t yourPlayerUniqueId;
|
||||||
GameData gameData;
|
GameData gameData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
typedef unsigned __int16 u_int16_t;
|
typedef unsigned __int16 u_int16_t;
|
||||||
typedef unsigned __int32 u_int32_t;
|
typedef unsigned __int32 u_int32_t;
|
||||||
|
typedef __int16 int16_t;
|
||||||
|
typedef __int32 int32_t;
|
||||||
typedef unsigned char u_char;
|
typedef unsigned char u_char;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
{return m_uniqueId;}
|
{return m_uniqueId;}
|
||||||
int GetNumber() const
|
int GetNumber() const
|
||||||
{return m_number;}
|
{return m_number;}
|
||||||
|
void SetNumber(int number)
|
||||||
|
{m_number = number;}
|
||||||
|
|
||||||
bool operator<(const PlayerData &other)
|
bool operator<(const PlayerData &other)
|
||||||
{return m_number < other.GetNumber();}
|
{return m_number < other.GetNumber();}
|
||||||
|
|||||||
Reference in New Issue
Block a user