This commit is contained in:
doitux
2007-01-13 18:55:48 +00:00
parent 70ede8cc90
commit 1e8152e97c
46 changed files with 0 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "boardinterface.h"
BoardInterface::~BoardInterface()
{
}
+45
View File
@@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef BOARDINTERFACE_H
#define BOARDINTERFACE_H
class BoardInterface {
public:
virtual ~BoardInterface();
//
// virtual void setPlayer(LocalPlayer**) =0;
// virtual void setHand(LocalHand*) =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 collectSets() const=0;
// virtual void collectPot() const=0;
};
#endif
+31
View File
@@ -0,0 +1,31 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "flopinterface.h"
FlopInterface::FlopInterface()
{
}
FlopInterface::~FlopInterface()
{
}
+34
View File
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef FLOPINTERFACE_H
#define FLOPINTERFACE_H
/**
@author FThauer FHammer <f.thauer@web.de>
*/
class FlopInterface{
public:
FlopInterface();
~FlopInterface();
};
#endif
+31
View File
@@ -0,0 +1,31 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "handinterface.h"
HandInterface::HandInterface()
{
}
HandInterface::~HandInterface()
{
}
+34
View File
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef HANDINTERFACE_H
#define HANDINTERFACE_H
/**
@author FThauer FHammer <f.thauer@web.de>
*/
class HandInterface{
public:
HandInterface();
~HandInterface();
};
#endif
+335
View File
@@ -0,0 +1,335 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "cardsvalue.h"
CardsValue::CardsValue()
{
}
CardsValue::~CardsValue()
{
}
int CardsValue::holeCardsClass(int one, int two) {
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önig
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::cardsValue(int *cards) {
int array[7][2];
int j1, j2, j3, j4, j5, k1, k2, ktemp[2];
// Kartenwerte umwandeln (z.B. [ 11 (Karo König) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] )
for(j1=0; j1<7; j1++) {
array[j1][0] = cards[j1]/13;
array[j1][1] = cards[j1]%13;
}
// Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo
for(k1=0; k1<7; k1++) {
for(k2=k1+1; k2<7; k2++) {
if(array[k1][0]<array[k2][0]) {
ktemp[0] = array[k1][0];
ktemp[1] = array[k1][1];
array[k1][0] = array[k2][0];
array[k1][1] = array[k2][1];
array[k2][0] = ktemp[0];
array[k2][1] = ktemp[1];
}
}
}
// Karten innerhalb der Farben nach der Größe sortieren: Ass - König - Dame - ... - 4 - 3 - 2
for(k1=0; k1<7; k1++) {
for(k2=k1+1; k2<7; k2++) {
if(array[k1][0]==array[k2][0] && array[k1][1]<array[k2][1]) {
ktemp[0] = array[k1][0];
ktemp[1] = array[k1][1];
array[k1][0] = array[k2][0];
array[k1][1] = array[k2][1];
array[k2][0] = ktemp[0];
array[k2][1] = ktemp[1];
}
}
}
// Karten auf Blätter testen. Klasseneinteilung absteigend: 9 - Royal Flush, 8 - Straight Flush, ... 2 - Zwei Paare, 1 - Ein Paar, 0 - Nischt
// auf Royal Flush (Klasse 9) und Straight Flush (Klasse 8) testen
for(j1=0; j1<3; j1++) {
// 5 Karten gleiche Farbe ?
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
// zusätzlich in Straßenform ?
if(array[j1][1]-1 == array[j1+1][1] && array[j1+1][1]-1 == array[j1+2][1] && array[j1+2][1]-1 == array[j1+3][1] && array[j1+3][1]-1 == array[j1+4][1]) {
// mit Ass an der Spitze ?
if(array[j1][1] == 12) {
// Royal Flush (9*100000000)
return 900000000;
}
// sonst nur Straight Flush (8*100000000 + (höchste Straight-Karte)*1000000)
else return 800000000+array[j1][1]*1000000;
}
else {
// Straight Flush Ausnahme: 5-4-3-2-A
for(j2=j1+1; j2<7; j2++) {
if(array[j1][1]-9==array[j2][1] && array[j2][1]-1==array[j2+1][1] && array[j2+1][1]-1==array[j2+2][1] && array[j2+2][1]-1==array[j2+3][1] && array[j1][0]==array[j2+2][0] && array[j1][0]==array[j2+3][0]) {
// Straight Flush mit 5 als höhste Karte -> 8*100000000+3*1000000
return 800000000+3*1000000;
}
}
}
}
}
// auf Flush (Klasse 5) testen
for(j1=0; j1<3; j1++) {
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
// Flush -> 5*10000000 + höhste Flush Karten mit absteigender Wertung
return 500000000+array[j1][1]*1000000+array[j1+1][1]*10000+array[j1+2][1]*100+array[j1+3][1]*10+array[j1+4][1];
}
}
// Karten für den Vierling-, Full-House-, Drilling- und Paartest umsortieren
for(k1=0; k1<7; k1++) {
for(k2=k1+1; k2<7; k2++) {
if(array[k1][1]<array[k2][1]) {
ktemp[0] = array[k1][0];
ktemp[1] = array[k1][1];
array[k1][0] = array[k2][0];
array[k1][1] = array[k2][1];
array[k2][0] = ktemp[0];
array[k2][1] = ktemp[1];
}
}
}
// auf Vierling (Klasse 7) testen
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) return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000;
else return 700000000+array[j1][1]*1000000+array[0][1]*10000;
}
}
// Hilfsvariablen fr die Full-House-Paar- und -Drilling-Zuordnung
int drei, zwei;
// auf Straight (Klasse 4) und Full House (Klasse 6) testen
for(j1=0; j1<7; j1++) {
for(j2=j1+1; j2<7; j2++) {
for(j3=j2+1; j3<7; j3++) {
for(j4=j3+1; j4<7; j4++) {
for(j5=j4+1; j5<7; j5++) {
// Straight
if((array[j1][1]-1 == array[j2][1] || array[j1][1]-9 == array[j2][1] ) && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1] && array[j4][1]-1 == array[j5][1]) {
// höhste Karte der Straight ermitteln
if(array[j1][1]-9 == array[j2][1]) return 400000000+array[j2][1]*1000000;
else return 400000000+array[j1][1]*1000000;
}
// Full House
if((array[j1][1] == array[j2][1] && array[j1][1] == array[j3][1] && array[j4][1] == array[j5][1]) || (array[j3][1] == array[j4][1] && array[j3][1] == array[j5][1] && array[j1][1] == array[j2][1])) {
// 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[4][1]; zwei = array[j1][1]; }
return 600000000+drei*1000000+zwei*10000;
}
}
}
}
}
}
// auf Drilling (Klasse 3) testen
for(j1=0; j1<5; j1++) {
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) {
// Kicker ermitteln
if(j1==0) return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100;
else {
if(j1==1) return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100;
else return 300000000+array[j1][1]*1000000+array[0][1]*10000+array[1][1]*100;
}
}
}
// auf Zwei Paare (Klasse 2) testen
for(j1=0; j1<4; j1++) {
for(j2=j1+2; j2<6; j2++) {
if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) {
// Kicker ermitteln
if(j1==0) {
if(j2==2) return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j2+2][1]*100;
else return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100;
}
else return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[0][1]*100;
}
}
}
// auf Paar (Klasse 1) testen
for(j1=0; j1<6; j1++) {
if(array[j1][1] == array[j1+1][1]) {
// Kicker ermitteln
if(j1==0) return 100000000+array[j1][1]*1000000+array[j1+2][1]*10000+array[j1+3][1]*100+array[j1+4][1];
if(j1==1) return 100000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+2][1]*100+array[j1+3][1];
if(j1==2) return 100000000+array[j1][1]*1000000+array[j1-2][1]*10000+array[j1-1][1]*100+array[j1+2][1];
else return 100000000+array[j1][1]*1000000+array[0][1]*10000+array[1][1]*100+array[2][1];
}
}
// Highest Card (Klasse 0) + Kicker
return array[0][1]*1000000+array[1][1]*10000+array[2][1]*100+array[3][1]*10+array[4][1];
}
+35
View File
@@ -0,0 +1,35 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef CARDSVALUE_H
#define CARDSVALUE_H
class CardsValue{
public:
CardsValue();
~CardsValue();
int holeCardsClass(int one, int two);
int cardsValue(int *cards);
};
#endif
+54
View File
@@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localboard.h"
#include "localhand.h"
using namespace std;
LocalBoard::LocalBoard() : playerArray(0), actualHand(0), pot(0), sets(0)
{
}
LocalBoard::~LocalBoard()
{
}
void LocalBoard::setPlayer(LocalPlayer** p) { playerArray = p; }
void LocalBoard::setHand(LocalHand* br) { actualHand = br; }
void LocalBoard::collectSets() {
sets = 0;
int i;
for(i=0; i<actualHand->getGuiInterface()->getMaxQuantityPlayers(); i++) sets += playerArray[i]->getMySet();
}
void LocalBoard::collectPot() {
int i;
pot += sets;
sets = 0;
for(i=0; i<actualHand->getGuiInterface()->getMaxQuantityPlayers(); i++){ playerArray[i]->setMySetNull(); }
}
+59
View File
@@ -0,0 +1,59 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOCALBOARD_H
#define LOCALBOARD_H
#include <iostream>
class LocalPlayer;
class LocalHand;
class LocalBoard{
public:
LocalBoard();
~LocalBoard();
void setPlayer(LocalPlayer**);
void setHand(LocalHand*);
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]; }
int getPot() const { return pot;}
void setPot(int theValue) { pot = theValue;}
int getSets() const { return sets; }
void collectSets();
void collectPot();
private:
LocalPlayer **playerArray;
LocalHand *actualHand;
int myCards[5];
int pot;
int sets;
};
#endif
+127
View File
@@ -0,0 +1,127 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localflop.h"
#include "localhand.h"
using namespace std;
LocalFlop::LocalFlop(LocalHand* bR, int id, int qP, int dP, int sB) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), playersTurn(dP)
{
int i;
//SmallBlind-Position ermitteln
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
}
LocalFlop::~LocalFlop()
{
}
void LocalFlop::flopRun() {
// cout << "NextPlayerSpeed2 stop" << endl;
int i;
if (firstFlopRun) {
myHand->getGuiInterface()->dealFlopCards();
firstFlopRun = 0;
}
else {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
}
}
// cout << "firstflopround " << firstFlopRound << endl;
// prfen, ob Flop wirklich dran ist
if(!firstFlopRound && allHighestSet) {
// Flop nicht dran, weil alle Sets gleich sind
//also gehe in Turn
myHand->setActualRound(2);
//Action lchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
}
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
myHand->getBoard()->collectSets();
myHand->getBoard()->collectPot();
myHand->getGuiInterface()->refreshPot();
myHand->getGuiInterface()->refreshAll();
myHand->switchRounds();
}
else {
// Flop ist wirklich dran
// nhsten Spieler ermitteln
do { playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
//Spieler-Position vor SmallBlind-Position ermitteln
int activePlayerBeforeSmallBlind = smallBlindPosition;
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + myHand->getGuiInterface()->getMaxQuantityPlayers() - 1 ) % (myHand->getGuiInterface()->getMaxQuantityPlayers());
} while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6);
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
myHand->getGuiInterface()->refreshGroupbox();
// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl;
// cout << "playersTurn " << playersTurn << endl;
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; }
if(playersTurn == 0) {
// Wir sind dran
// cout << "actualRound " << myHand->getActualRound() << endl;
// cout << "highestSet vor meInAction " << highestSet << endl;
myHand->getGuiInterface()->meInAction();
}
else {
//Gegner sind dran
// cout << "NextPlayerSpeed3 start" << endl;
myHand->getGuiInterface()->flopAnimation2();
}
}
}
}
void LocalFlop::nextPlayer2() {
// cout << "NextPlayerSpeed3 stop" << endl;
myHand->getPlayerArray()[playersTurn]->action();
}
+71
View File
@@ -0,0 +1,71 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOCALFLOP_H
#define LOCALFLOP_H
#include <iostream>
class LocalHand;
class LocalFlop {
public:
LocalFlop(LocalHand*, int, int, int, int);
~LocalFlop();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setFirstFlopRound(bool theValue) { firstFlopRound = theValue;}
bool getFirstFlopRound() const { return firstFlopRound;}
void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void flopRun();
void nextPlayer2();
private:
LocalHand *myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int smallBlindPosition;
int smallBlind;
int highestSet;
bool firstFlopRun;
bool firstFlopRound;
int playersTurn;
};
#endif
+281
View File
@@ -0,0 +1,281 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localhand.h"
using namespace std;
LocalHand::LocalHand(GuiInterface *g, LocalBoard *b, LocalPlayer **p, int id, int qP, int dP, int sB,int sC) : myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0)
{
int i, j;
CardsValue myCardsValue;
myGui->setHand(this);
myBoard->setHand(this);
// myEngine->setHand(this);
for(i=0; i<actualQuantityPlayers; i++) playerArray[i]->setHand(this);
// roundStartCashArray fllen
for(i=0; i<5; i++) {
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
}
// Dealer, SB, BB bestimmen
assignButtons();
myGui->refreshAll();
// Karten generieren und Board sowie Player zuweisen
Tools myTool;
int cardsArray[2*actualQuantityPlayers+5];
myTool.getRandNumber(0, 51, 2*actualQuantityPlayers+5, cardsArray, 1);
int tempBoardArray[5];
int tempPlayerArray[2];
int tempPlayerAndBoardArray[7];
for(i=0; i<5; i++) {
tempBoardArray[i] = cardsArray[i];
tempPlayerAndBoardArray[i+2] = cardsArray[i];
}
myBoard->setMyCards(tempBoardArray);
for(i=0; i<actualQuantityPlayers; i++) {
for(j=0; j<2; j++) {
tempPlayerArray[j] = cardsArray[2*i+j+5];
tempPlayerAndBoardArray[j] = cardsArray[2*i+j+5];
}
playerArray[i]->setMyCards(tempPlayerArray);
playerArray[i]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray));
}
// Karten austeilen
myGui->dealHoleCards();
// Preflop, Flop, Turn und River erstellen
myPreflop = new LocalPreflop(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
myFlop = new LocalFlop(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
myTurn = new LocalTurn(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
myRiver = new LocalRiver(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
//Rundenwechsel | beim ersten Durchlauf --> Preflop starten
myGui->nextPlayerAnimation();
}
LocalHand::~LocalHand()
{
delete myPreflop;
myPreflop = 0;
delete myFlop;
myFlop = 0;
delete myTurn;
myTurn = 0;
delete myRiver;
myRiver = 0;
}
void LocalHand::assignButtons() {
int i;
// alle Buttons loeschen
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) { playerArray[i]->setMyButton(0); }
// DealerButton zuweisen
playerArray[dealerPosition]->setMyButton(1);
// Small Blind zuweisen und setzen
i = dealerPosition;
do {
i = (i+1)%(myGui->getMaxQuantityPlayers());
if(playerArray[i]->getMyActiveStatus()) {
playerArray[i]->setMyButton(2);
// mit SmallBlind All In ?
if(playerArray[i]->getMyCash() <= smallBlind) {
playerArray[i]->setMySet(playerArray[i]->getMyCash());
playerArray[i]->setMyAction(6);
}
// sonst
else {
playerArray[i]->setMySet(smallBlind);
}
}
} while(!(playerArray[i]->getMyActiveStatus()));
// Big Blind zuweisen
do {
i = (i+1)%(myGui->getMaxQuantityPlayers());
if(playerArray[i]->getMyActiveStatus()) {
playerArray[i]->setMyButton(3);
// mit BigBlind All In ?
if(playerArray[i]->getMyCash() <= 2*smallBlind) {
playerArray[i]->setMySet(playerArray[i]->getMyCash());
playerArray[i]->setMyAction(6);
}
// sonst
else {
playerArray[i]->setMySet(2*smallBlind);
}
}
} while(!(playerArray[i]->getMyActiveStatus()));
}
void LocalHand::switchRounds() {
int i;
// cout << "switchrounds" << endl;
//Aktive Spieler zlen --> wenn nur noch einer nicht-folded dann gleich den Pot verteilen
int activePlayersCounter = 0;
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) {
if (playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyActiveStatus() == 1) activePlayersCounter++;
}
// Anzahl der Spieler ermitteln, welche All In sind
int allInPlayersCounter = 0;
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) {
if (playerArray[i]->getMyAction() == 6) allInPlayersCounter++;
}
if(activePlayersCounter==1) {
myBoard->collectPot();
myGui->refreshPot();
myGui->refreshSet();
actualRound = 4;
}
// prfen der All In Kondition
// fr All In Prozedur mssen mindestens zwei aktive Player vorhanden sein
else {
// 1) wenn alle All In
if(allInPlayersCounter == activePlayersCounter) {
allInCondition = 1;
}
// 2) alle bis auf einen All In und der hat HighestSet
int tempHighestSet;
if(allInPlayersCounter+1 == activePlayersCounter) {
// Spieler ermitteln, der noch nicht All In ist
for (i=0; i<myGui->getMaxQuantityPlayers(); i++) {
if(playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) {
tempHighestSet = 0;
switch (actualRound) {
case 0: {tempHighestSet = myPreflop->getHighestSet();}
break;
case 1: {tempHighestSet = myFlop->getHighestSet();}
break;
case 2: {tempHighestSet = myTurn->getHighestSet();}
break;
case 3: {tempHighestSet = myRiver->getHighestSet();}
break;
default: {}
}
if(playerArray[i]->getMySet() >= tempHighestSet) {
allInCondition = 1;
}
}
}
}
}
// beim Vorliegen einer All In Kondition -> Ausfhrung einer Sonderprozedur
if(allInCondition) {
myBoard->collectPot();
myGui->refreshPot();
myGui->refreshSet();
actualRound++;
}
myGui->refreshGroupbox();
highlightRoundLabel();
// /*/*/*/*cout <<*/*/*/*/ "NextPlayerSpeed1 stop" << endl;
//
// cout << "NextPlayerSpeed2 start" << endl;
switch(actualRound) {
case 0: {
// Preflop starten
myGui->preflopAnimation1();
} break;
case 1: {
// Flop starten
myGui->flopAnimation1();
} break;
case 2: {
// Turn starten
myGui->turnAnimation1();
} break;
case 3: {
// River starten
myGui->riverAnimation1();
} break;
case 4: {
// PostRiver starten
myGui->postRiverAnimation1();
} break;
default: {}
}
}
void LocalHand::highlightRoundLabel() {
switch(actualRound) {
case 0: {
myGui->highlightRoundLabel("Preflop");
} break;
case 1: {
myGui->highlightRoundLabel("Flop");
} break;
case 2: {
myGui->highlightRoundLabel("Turn");
} break;
case 3: {
myGui->highlightRoundLabel("River");
} break;
case 4: {
myGui->highlightRoundLabel("");
} break;
default: {
myGui->highlightRoundLabel("!!! FEHLER !!!");
}
}
}
+105
View File
@@ -0,0 +1,105 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOCALHAND_H
#define LOCALHAND_H
#include "guiinterface.h"
#include "localboard.h"
#include "localplayer.h"
#include "tools.h"
#include "localpreflop.h"
#include "localflop.h"
#include "localturn.h"
#include "localriver.h"
class GuiInterface;
class LocalBoard;
class LocalPlayer;
class LocalPreflop;
class LocalFlop;
class LocalTurn;
class LocalRiver;
class LocalHand {
public:
LocalHand(GuiInterface*, LocalBoard*, LocalPlayer**, int, int, int, int, int);
~LocalHand();
LocalPlayer** getPlayerArray() const { return playerArray; }
LocalBoard* getBoard() const { return myBoard; }
LocalPreflop* getPreflop() const { return myPreflop; }
LocalFlop* getFlop() const { return myFlop; }
LocalTurn* getTurn() const { return myTurn; }
LocalRiver* getRiver() const { return myRiver; }
GuiInterface* getGuiInterface() const { return myGui; }
void setMyID(const int& theValue) { myID = theValue; }
int getMyID() const { return myID; }
void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; }
int getActualQuantityPlayers() const { return actualQuantityPlayers; }
void setActualRound(const int& theValue) { actualRound = theValue; }
int getActualRound() const { return actualRound; }
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setAllInCondition(bool theValue) { allInCondition = theValue; }
bool getAllInCondition() const { return allInCondition; }
void setStartCash(const int& theValue) { startCash = theValue; }
int getStartCash() const { return startCash; }
void assignButtons();
void highlightRoundLabel();
void switchRounds();
private:
GuiInterface *myGui;
LocalBoard *myBoard;
LocalPlayer **playerArray;
LocalPreflop *myPreflop;
LocalFlop *myFlop;
LocalTurn *myTurn;
LocalRiver *myRiver;
int myID;
int actualQuantityPlayers;
int dealerPosition; // -1 -> neutral
int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
int smallBlind;
int startCash;
bool allInCondition;
};
#endif
+778
View File
@@ -0,0 +1,778 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localplayer.h"
#include "localhand.h"
using namespace std;
LocalPlayer::LocalPlayer(LocalBoard *b, int id, int sC, bool aS, int mB) : actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myDude(0), myCardsValueInt(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), myAverageSets(0)
{
Tools myTool;
// Dude zuweisen
myTool.getRandNumber(3 , 5, 1, &myDude, 0);
// cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl;
myCardsValue = new CardsValue;
ostringstream temp;
temp << "Player " << myID;
myName = temp.str();
}
LocalPlayer::~LocalPlayer()
{
}
void LocalPlayer::setHand(LocalHand* br) { actualHand = br; }
void LocalPlayer::action() {
switch(actualHand->getActualRound()) {
case 0: {
preflopEngine();
actualBoard->collectSets();
actualHand->getGuiInterface()->refreshPot();
} break;
case 1: {
flopEngine();
actualBoard->collectSets();
actualHand->getGuiInterface()->refreshPot();
} break;
case 2: {
turnEngine();
actualBoard->collectSets();
actualHand->getGuiInterface()->refreshPot();
} break;
case 3: {
riverEngine();
actualBoard->collectSets();
actualHand->getGuiInterface()->refreshPot();
} break;
default: {}
}
myTurn = 0;
// cout << "jetzt" << endl;
actualHand->getGuiInterface()->showPlayerActionLogMsg(myName, myAction, mySet);
actualHand->getGuiInterface()->nextPlayerAnimation();
}
void LocalPlayer::preflopEngine() {
// cout << "nextID " << actualHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl;
Tools myTool;
int raise = 0;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber(1,10,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "preflop-bluff " << bluff << endl;
// Potential
int potential = 10*(4*(myCardsValue->holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude;
int setToHighest = actualHand->getPreflop()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
myTool.getRandNumber(2,3,1,&tempFold,0);
// 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) {
myAction=1;
}
else {
// RAISE --> wenn hohes Potential
if(potential >= 4 && 6 * actualHand->getSmallBlind() >= actualHand->getPreflop()->getHighestSet() || bluff <= 6) {
// extrem hohes Potential --> groᅵr Raise
if(potential>=6 || bluff <= 2) {
// bluff - raise
if(bluff <=2 && 4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet()) {
raise = 3 * actualHand->getPreflop()->getHighestSet();
}
else {
// bluff - call
if(bluff >= 98) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
} else {
// doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!!
if(! (4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet())) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
else raise = (potential - 4 ) * 2 * actualHand->getPreflop()->getHighestSet();
}
}
}
// hohes Potential --> gemäßigter Raise
else {
// bluff - raise
if(bluff <= 6 && 4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet()) {
raise = 2*actualHand->getPreflop()->getHighestSet();
}
else {
// bluff - call
if(bluff >= 93) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
else {
// doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!!
if(! (4 * actualHand->getSmallBlind() > actualHand->getPreflop()->getHighestSet())) {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
else raise = (potential - 3 ) * actualHand->getPreflop()->getHighestSet();
}
}
}
if (raise > 0) {
// All In
if(actualHand->getPreflop()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getPreflop()->getHighestSet()) actualHand->getPreflop()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getPreflop()->getHighestSet() - raise;
mySet = actualHand->getPreflop()->getHighestSet() + raise;
actualHand->getPreflop()->setHighestSet(mySet);
myAction = 5;
}
}
}
//CHECK und CALL
else {
// CHECK --> wenn alle Sets glieich bei BigBlind und nich zu hohem Potential
if(mySet == actualHand->getPreflop()->getHighestSet()) {
myAction = 2;
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getPreflop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getPreflop()->getHighestSet() + mySet;
mySet = actualHand->getPreflop()->getHighestSet();
myAction = 3;
}
}
}
}
}
void LocalPlayer::flopEngine() {
// Prozent ausrechnen
int i, j, k ,l;
int tempBoardCardsArray[5];
int tempMyCardsArray[7];
int tempOpponentCardsArray[7];
actualBoard->getMyCards(tempBoardCardsArray);
tempMyCardsArray[0] = myCards[0];
tempMyCardsArray[1] = myCards[1];
tempMyCardsArray[2] = tempBoardCardsArray[0];
tempMyCardsArray[3] = tempBoardCardsArray[1];
tempMyCardsArray[4] = tempBoardCardsArray[2];
tempOpponentCardsArray[2] = tempBoardCardsArray[0];
tempOpponentCardsArray[3] = tempBoardCardsArray[1];
tempOpponentCardsArray[4] = tempBoardCardsArray[2];
int tempMyCardsValue;
int tempOpponentCardsValue;
int countAll = 0;
int countMy = 0;
for(i=0; i<49; i++) {
if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) {
for(j=i+1; j<50; j++) {
if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) {
for(k=j+1; k<51; k++) {
if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) {
for(l=k+1; l<52; l++) {
if(l != myCards[0] && l != myCards[1] && l != tempBoardCardsArray[0] && l != tempBoardCardsArray[1] && l != tempBoardCardsArray[2]) {
countAll++;
tempOpponentCardsArray[0] = i;
tempOpponentCardsArray[1] = j;
tempOpponentCardsArray[5] = k;
tempOpponentCardsArray[6] = l;
tempMyCardsArray[5] = k;
tempMyCardsArray[6] = l;
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray);
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray);
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
}
}
}
}
}
}
}
}
double percent = (countMy*1.0)/(countAll*1.0);
// cout << "Prozent: " << percent << endl;
Tools myTool;
int raise = 0;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "flop-bluff " << bluff << endl;
// Potential
int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude;
int setToHighest = actualHand->getFlop()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(8*actualHand->getSmallBlind());
myTool.getRandNumber(2,3,1,&tempFold,0);
// 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) {
myAction=1;
}
else {
// CHECK und BET --> wenn noch keiner was gesetzt hat
if(actualHand->getFlop()->getHighestSet() == 0) {
// CHECK --> wenn Potential klein oder check-bluff sonst bet oder bet-bluff
if((potential<3 || bluff >= 80) && bluff > 15) {
// check
myAction = 2;
}
// BET --> wenn Potential hoch
else {
if(bluff <= 5) mySet = (bluff+1) * actualHand->getSmallBlind();
else {
if(bluff <=15 ) mySet = 4 * actualHand->getSmallBlind();
// je höher das Potential, desto höher der Einsatz (zur Basis SmallBlind)
else mySet = (potential-1) * 2 * actualHand->getSmallBlind();
}
// All In
if(mySet >= myCash) {
mySet = myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash -= mySet;
myAction = 4;
}
actualHand->getFlop()->setHighestSet(mySet);
}
}
// CALL und RAISE --> wenn bereits gesetzt wurde
else {
// RAISE --> wenn Potential besonders gut
if((potential >=4 && 2 * tempFold * actualHand->getSmallBlind() >= actualHand->getFlop()->getHighestSet()) || (bluff <= 5 && 4 * tempFold * actualHand->getSmallBlind() >= actualHand->getFlop()->getHighestSet())) {
// bluff - raise
if(bluff <=5) raise = ((bluff+1)/2) * actualHand->getFlop()->getHighestSet();
// Betrag, der ber dem aktuell HighestSet gesetzt werden soll
else raise = ((potential - 2 ) / 2) * actualHand->getFlop()->getHighestSet();
// All In
if(actualHand->getFlop()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getFlop()->getHighestSet()) actualHand->getFlop()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getFlop()->getHighestSet() - raise;
mySet = actualHand->getFlop()->getHighestSet() + raise;
actualHand->getFlop()->setHighestSet(mySet);
myAction = 5;
}
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getFlop()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getFlop()->getHighestSet() + mySet;
mySet = actualHand->getFlop()->getHighestSet();
myAction = 3;
}
}
}
}
}
void LocalPlayer::turnEngine() {
// Prozent ausrechnen
int i, j, k;
int tempBoardCardsArray[5];
int tempMyCardsArray[7];
int tempOpponentCardsArray[7];
actualBoard->getMyCards(tempBoardCardsArray);
tempMyCardsArray[0] = myCards[0];
tempMyCardsArray[1] = myCards[1];
tempMyCardsArray[2] = tempBoardCardsArray[0];
tempMyCardsArray[3] = tempBoardCardsArray[1];
tempMyCardsArray[4] = tempBoardCardsArray[2];
tempMyCardsArray[5] = tempBoardCardsArray[3];
tempOpponentCardsArray[2] = tempBoardCardsArray[0];
tempOpponentCardsArray[3] = tempBoardCardsArray[1];
tempOpponentCardsArray[4] = tempBoardCardsArray[2];
tempOpponentCardsArray[5] = tempBoardCardsArray[3];
int tempMyCardsValue;
int tempOpponentCardsValue;
int countAll = 0;
int countMy = 0;
for(i=0; i<49; i++) {
if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) {
for(j=i+1; j<50; j++) {
if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) {
for(k=j+1; k<51; k++) {
if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) {
countAll++;
tempOpponentCardsArray[0] = i;
tempOpponentCardsArray[1] = j;
tempOpponentCardsArray[6] = k;
tempMyCardsArray[6] = k;
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray);
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray);
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
}
}
}
}
}
}
double percent = (countMy*1.0)/(countAll*1.0);
// cout << "Prozent: " << percent << endl;
Tools myTool;
int raise;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "turn-bluff " << bluff << endl;
// Potential
int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude;
int setToHighest = actualHand->getTurn()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
// tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(7*actualHand->getSmallBlind());
myTool.getRandNumber(3,4,1,&tempFold,0);
// 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 > 15) {
myAction=1;
}
else {
// CHECK und BET --> wenn noch keiner was gesetzt hat
if(actualHand->getTurn()->getHighestSet() == 0) {
// CHECK --> wenn Potential klein
if((potential<2 || bluff >= 80) && bluff > 10) {
// check
myAction = 2;
}
// BET --> wenn Potential hoch
else {
if(bluff <= 3) mySet = bluff * 2 * actualHand->getSmallBlind();
else {
if(bluff <=10 ) mySet = ((bluff+2)/3) * actualHand->getSmallBlind();
// je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind)
else mySet = (potential-1) * 3 * actualHand->getSmallBlind();
}
// All In
if(mySet >= myCash) {
mySet = myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash -= mySet;
myAction = 4;
}
actualHand->getTurn()->setHighestSet(mySet);
}
}
// CALL und RAISE --> wenn bereits gesetzt wurde
else {
// RAISE --> wenn Potential besonders gut
if(potential >=4 && 2 * tempFold * actualHand->getSmallBlind() >= actualHand->getTurn()->getHighestSet() || (bluff <= 4 && 3 * tempFold * actualHand->getSmallBlind() >= actualHand->getTurn()->getHighestSet())) {
// bluff - raise
if(bluff <= 4) raise = ((bluff+1)/2) * actualHand->getTurn()->getHighestSet();
// Betrag, der ber dem aktuell HighestSet gesetzt werden soll
else raise = ( potential - 3 ) * actualHand->getTurn()->getHighestSet();
// All In
if(actualHand->getTurn()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getTurn()->getHighestSet()) actualHand->getTurn()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getTurn()->getHighestSet() - raise;
mySet = actualHand->getTurn()->getHighestSet() + raise;
actualHand->getTurn()->setHighestSet(mySet);
myAction = 5;
}
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getTurn()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getTurn()->getHighestSet() + mySet;
mySet = actualHand->getTurn()->getHighestSet();
myAction = 3;
}
}
}
}
}
void LocalPlayer::riverEngine() {
// Prozent ausrechnen
int i, j;
int tempBoardCardsArray[5];
int tempMyCardsArray[7];
int tempOpponentCardsArray[7];
actualBoard->getMyCards(tempBoardCardsArray);
tempMyCardsArray[0] = myCards[0];
tempMyCardsArray[1] = myCards[1];
tempMyCardsArray[2] = tempBoardCardsArray[0];
tempMyCardsArray[3] = tempBoardCardsArray[1];
tempMyCardsArray[4] = tempBoardCardsArray[2];
tempMyCardsArray[5] = tempBoardCardsArray[3];
tempMyCardsArray[6] = tempBoardCardsArray[4];
tempOpponentCardsArray[2] = tempBoardCardsArray[0];
tempOpponentCardsArray[3] = tempBoardCardsArray[1];
tempOpponentCardsArray[4] = tempBoardCardsArray[2];
tempOpponentCardsArray[5] = tempBoardCardsArray[3];
tempOpponentCardsArray[6] = tempBoardCardsArray[4];
int tempMyCardsValue;
int tempOpponentCardsValue;
int countAll = 0;
int countMy = 0;
for(i=0; i<49; i++) {
if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) {
for(j=i+1; j<50; j++) {
if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) {
countAll++;
tempOpponentCardsArray[0] = i;
tempOpponentCardsArray[1] = j;
tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray);
tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray);
if(tempMyCardsValue>=tempOpponentCardsValue) countMy++;
}
}
}
}
double percent = (countMy*1.0)/(countAll*1.0);
// cout << "Prozent: " << percent << endl;
Tools myTool;
int raise;
// Bauchgefhl (zufᅵlig)
int tempRand;
myTool.getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0);
// bluff, checkbluff
int bluff;
myTool.getRandNumber(1,100,1,&bluff,0);
// cout << "river-bluff " << bluff << endl;
// Potential
int potential = (10*(5*(int)(percent*100.)+10*tempRand*1))/600-myDude;
int setToHighest = actualHand->getRiver()->getHighestSet() - mySet;
// temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist
int tempFold;
tempFold = (actualHand->getPlayerArray()[0]->getMyAverageSets())/(6*actualHand->getSmallBlind());
// myTool.getRandNumber(4,6,1,&tempFold,0);
// 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 > 15) {
myAction=1;
}
else {
// CHECK und BET --> wenn noch keiner was gesetzt hat
if(actualHand->getRiver()->getHighestSet() == 0) {
// CHECK --> wenn Potential klein
if((potential<2 || bluff >= 92) && bluff > 15) {
// check
myAction = 2;
}
// BET --> wenn Potential hoch
else {
if(bluff <= 5) mySet = (bluff+3) * actualHand->getSmallBlind();
else {
if(bluff <= 15 ) mySet = ((bluff-1)/5) * 2 * actualHand->getSmallBlind();
// je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind)
else mySet = (potential-1) * 4 * actualHand->getSmallBlind();
}
// All In
if(mySet >= myCash) {
mySet = myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash -= mySet;
myAction = 4;
}
actualHand->getRiver()->setHighestSet(mySet);
}
}
// CALL und RAISE --> wenn bereits gesetzt wurde
else {
// RAISE --> wenn Potential besonders gut
if(potential >=4 && 2 * tempFold * actualHand->getSmallBlind() >= actualHand->getRiver()->getHighestSet() || (bluff <= 2 && 4 * tempFold * actualHand->getSmallBlind() >= actualHand->getRiver()->getHighestSet())) {
// bluff - raise
if(bluff <= 2 ) raise = bluff * actualHand->getRiver()->getHighestSet();
// Betrag, der ber dem aktuell HighestSet gesetzt werden soll
else raise = ( potential - 3 ) * actualHand->getRiver()->getHighestSet();
// All In
if(actualHand->getRiver()->getHighestSet() + raise >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
if(mySet > actualHand->getRiver()->getHighestSet()) actualHand->getRiver()->setHighestSet(mySet);
}
// sonst
else {
myCash = myCash + mySet - actualHand->getRiver()->getHighestSet() - raise;
mySet = actualHand->getRiver()->getHighestSet() + raise;
actualHand->getRiver()->setHighestSet(mySet);
myAction = 5;
}
}
// CALL --> bei normalen Potential
else {
// All In
if(actualHand->getRiver()->getHighestSet() >= myCash) {
mySet += myCash;
myCash = 0;
myAction = 6;
}
// sonst
else {
myCash = myCash - actualHand->getRiver()->getHighestSet() + mySet;
mySet = actualHand->getRiver()->getHighestSet();
myAction = 3;
}
}
}
}
}
+118
View File
@@ -0,0 +1,118 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOCALPLAYER_H
#define LOCALPLAYER_H
#include "cardsvalue.h"
#include <string>
#include <sstream>
class CardsValue;
class LocalHand;
class LocalBoard;
class LocalPlayer{
public:
LocalPlayer(LocalBoard*, int, int, bool, int);
~LocalPlayer();
void setHand(LocalHand*);
void setMyID(const int& theValue) { myID = theValue; }
int getMyID() const { return myID; }
void setMyDude(const int& theValue) { myDude = theValue; }
int getMyDude() const { return myDude; }
void setMyName(const std::string& theValue) { myName = theValue; }
std::string getMyName() const { return myName; }
void setMyCash(const int& theValue) { myCash = theValue; }
int getMyCash() const { return myCash; }
void setMySet(const int& theValue) { mySet += theValue; myCash -= theValue; }
void setMySetNull() { mySet = 0; }
int getMySet() const { return mySet;}
void setMyAction(const int& theValue) { myAction = theValue; }
int getMyAction() const { return myAction; }
void setMyButton(const int& theValue) { myButton = theValue; }
int getMyButton() const { return myButton; }
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; }
bool getMyActiveStatus() const { return myActiveStatus; }
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; }
void getMyCards(int* theValue) { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; }
void setMyTurn(bool theValue){ myTurn = theValue;}
bool getMyTurn() const{ return myTurn;}
void setMyCardsValueInt(const int& theValue) { myCardsValueInt = theValue;}
int getMyCardsValueInt() const { return myCardsValueInt; }
void setMyRoundStartCash(const int& theValue) { myRoundStartCash = theValue;}
int getMyRoundStartCash() const { return myRoundStartCash; }
void setMyAverageSets(const int& theValue) { myAverageSets = theValue; }
int getMyAverageSets() const { return myAverageSets; }
void action();
void preflopEngine();
void flopEngine();
void turnEngine();
void riverEngine();
private:
LocalHand *actualHand;
LocalBoard *actualBoard;
CardsValue *myCardsValue;
// Konstanten
int myID;
int myDude;
std::string myName;
// Laufvariablen
int myCards[2];
int myCardsValueInt;
int myCash;
int mySet;
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 myTurn; // 0 = no, 1 = yes
int myRoundStartCash;
int myAverageSets;
};
#endif
+121
View File
@@ -0,0 +1,121 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localpreflop.h"
#include "localhand.h"
using namespace std;
LocalPreflop::LocalPreflop(LocalHand* bR, int id, int qP, int dP, int sB) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0)
{
myHand->getBoard()->collectSets();
myHand->getGuiInterface()->refreshPot();
// // BigBlind ermitteln
bigBlindPosition = dealerPosition;
while (myHand->getPlayerArray()[bigBlindPosition]->getMyButton() != 3) {
bigBlindPosition = (bigBlindPosition+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
}
// // erste Spielernummer fr preflopRun() setzen
playersTurn = bigBlindPosition;
}
LocalPreflop::~LocalPreflop()
{
}
void LocalPreflop::preflopRun() {
// cout << "NextPlayerSpeed2 stop" << endl;
int i;
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
}
}
// BigBlind ermitteln
bigBlindPosition = dealerPosition;
while (myHand->getPlayerArray()[bigBlindPosition]->getMyButton() != 3) {
bigBlindPosition = (bigBlindPosition+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
}
// prfen, ob Preflop wirklich dran ist
if(!preflopFirstRound && allHighestSet) {
// Preflop nicht dran, weil wir nicht mehr in erster PreflopRunde und alle Sets gleich sind
//also gehe in Flop
myHand->setActualRound(1);
//Action lchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
}
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
myHand->getBoard()->collectSets();
myHand->getBoard()->collectPot();
myHand->getGuiInterface()->refreshPot();
myHand->getGuiInterface()->refreshAll();
myHand->switchRounds();
}
else {
// Preflop ist wirklich dran
// nhsten Spieler ermitteln
do {
playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
// falls BigBlind, dann PreflopFirstRound zuende
if(myHand->getPlayerArray()[playersTurn]->getMyButton() == 3) preflopFirstRound = 0;
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || myHand->getPlayerArray()[playersTurn]->getMyAction() == 1 || myHand->getPlayerArray()[playersTurn]->getMyAction() == 6);
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
myHand->getGuiInterface()->refreshGroupbox();
if(playersTurn == 0) {
// Wir sind dran
myHand->getGuiInterface()->meInAction();
}
else {
//Gegner sind dran
// cout << "NextPlayerSpeed3 start" << endl;
myHand->getGuiInterface()->preflopAnimation2();
}
}
}
void LocalPreflop::nextPlayer2() {
// cout << "NextPlayerSpeed3 stop" << endl;
myHand->getPlayerArray()[playersTurn]->action();
}
+65
View File
@@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
*************************************************************************/
#ifndef LOCALPREFLOP_H
#define LOCALPREFLOP_H
#include <iostream>
class LocalHand;
class LocalPreflop {
public:
LocalPreflop(LocalHand*, int, int, int, int);
~LocalPreflop();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setLocalPreflopFirstRound(bool theValue) { preflopFirstRound = theValue; }
bool setLocalPreflopFirstRound() const { return preflopFirstRound; }
void preflopRun();
void nextPlayer2();
private:
LocalHand *myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int bigBlindPosition;
int smallBlind;
int highestSet;
bool preflopFirstRound;
int playersTurn;
};
#endif
+426
View File
@@ -0,0 +1,426 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localriver.h"
#include "localhand.h"
using namespace std;
LocalRiver::LocalRiver(LocalHand* bR, int id, int qP, int dP, int sB) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRiverRun(1), firstRiverRound(1), playersTurn(dP), highestCardsValue(0)
{ int i;
//SmallBlind-Position ermitteln
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
}
LocalRiver::~LocalRiver()
{
}
void LocalRiver::riverRun() {
int i;
if (firstRiverRun) {
myHand->getGuiInterface()->dealRiverCard();
firstRiverRun = 0;
}
else {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl;
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
}
}
// cout << "allHighestSet " << allHighestSet << endl;
// cout << "firstflopround " << firstRiverRound << endl;
// prfen, ob River wirklich dran ist
if(!firstRiverRound && allHighestSet) {
// River nicht dran, weil alle Sets gleich sind
//also gehe in Turn
myHand->setActualRound(4);
//Action lᅵchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
}
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
myHand->getBoard()->collectSets();
myHand->getBoard()->collectPot();
myHand->getGuiInterface()->refreshPot();
myHand->getGuiInterface()->refreshAll();
myHand->switchRounds();
}
else {
// River ist wirklich dran
// nᅵhsten Spieler ermitteln
do { playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
//Spieler-Position vor SmallBlind-Position ermitteln
int activePlayerBeforeSmallBlind = smallBlindPosition;
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + myHand->getGuiInterface()->getMaxQuantityPlayers() - 1 ) % (myHand->getGuiInterface()->getMaxQuantityPlayers());
} while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6);
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
myHand->getGuiInterface()->refreshGroupbox();
// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl;
// cout << "playersTurn " << playersTurn << endl;
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; }
if(playersTurn == 0) {
// Wir sind dran
// cout << "actualRound " << myHand->getActualRound() << endl;
// cout << "highestSet vor meInAction " << highestSet << endl;
myHand->getGuiInterface()->meInAction();
}
else {
//Gegner sind dran
myHand->getGuiInterface()->riverAnimation2();
}
}
}
}
void LocalRiver::postRiverRun() {
int i;
// für die Engine die durchschnittlichen Sets von Player 0 setzen
if(myID < 5) {
myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*(myID-1))/myID + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/myID);
} else {
myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*4)/5 + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/5);
}
// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl;
//berechnen welcher Spieler gewonnen hat
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
// cout << "Spieler: " << i << " hat: " << myHand->getPlayerArray()[i]->getMyCardsValueInt() << endl;
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyCardsValueInt() > highestCardsValue ) {
highestCardsValue = myHand->getPlayerArray()[i]->getMyCardsValueInt();
}
}
// Pot-Verteilung
distributePot();
//Pot auf 0 setzen
myHand->getBoard()->setPot(0);
//starte die Animaionsreihe
myHand->getGuiInterface()->postRiverRunAnimation1();
}
void LocalRiver::nextPlayer2() {
myHand->getPlayerArray()[playersTurn]->action();
}
void LocalRiver::distributePot() {
// int potCalcAllinArray[5][2]; // 0 -> ID , 1 -> AllInCash
int i, j;
////////////////////
// (1) EINLEITUNG //
////////////////////
// die Potverteilung gliedert sich in mehrere Runden:
// in der ersten Runden sucht sich der Winner der BettingRound seinen zustehenden Anteil am Pot raus. das kann alles oder nur ein Teil sein (z.b. wenn er mit wenig allin gegangen ist und der Rest weitergespielt hat)
// in den darauffolgenden Verteilungsrunden suchen sich die jeweils nᅵhsten Winner aus dem noch brig gebliebenen Pot ihren zustehenden Anteil raus
// die gesamte Potverteilung ist zuende, wenn der Pot leer ist und nichts mehr zu holen ist
/////////////////////
// (2) HILFSMITTEL //
/////////////////////
// winnersArray erstellen -> hier werden die winner der jeweiligen Potverteilungsrunden eingetragen
int *winnersArray = new int[myHand->getGuiInterface()->getMaxQuantityPlayers()];
// Anzahl der winner in einer Potverteilungsrunde
int winnersCounter = 0;
// dieses Array ermittelt wieviel jeder Spieler wᅵrend der gesamten BettingRound gesetzt hat
int roundSetArray[myHand->getGuiInterface()->getMaxQuantityPlayers()];
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
// Standardwert fr nicht mehr aktive
roundSetArray[i] = 0;
// nur fr die Spieler ermitteln, die noch aktiv sind (inkl. der gefoldeten)
if(myHand->getPlayerArray()[i]->getMyActiveStatus()) {
roundSetArray[i] = myHand->getPlayerArray()[i]->getMyRoundStartCash()-myHand->getPlayerArray()[i]->getMyCash();
}
}
// hier steht der CardsValue der Spieler drin die an der Potverteilung teilnehmen (d.h. aktiv und nicht gefoldet), bei allen anderen steht ne 0
int cardsValueArray[myHand->getGuiInterface()->getMaxQuantityPlayers()];
int playerWantsPotCounter = 0;
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
// Standardwert
cardsValueArray[i] = 0;
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) {
// nur bei den Spielen den Kartenwert eintragen, die an der Potverteilung teilnehmen
cardsValueArray[i] = myHand->getPlayerArray()[i]->getMyCardsValueInt();
playerWantsPotCounter++;
}
}
int winner;
int highestCardsValueTemp;
// fr SplitPotBerechnung;
int winnersSets;
int winnersMaxSet;
int winnersPot;
bool playerIsWinner;
//////////////////////
// (3) DIE SCHLEIFE //
//////////////////////
// Potverteilungsrunden -> solange noch was aus dem pot zu vergeben ist
while(playerWantsPotCounter != 0 ) {
// highestCardsValueTemp zu Beginn der aktuellen Potverteilungsrunde auf Null setzen
highestCardsValueTemp = 0;
// aktuellen highestCardsValueTemp berechnen, von denen die noch an der Potverteilung teilnehmen
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(cardsValueArray[i] > highestCardsValueTemp ) {
highestCardsValueTemp = myHand->getPlayerArray()[i]->getMyCardsValueInt();
}
}
// zu Beginn der Potverteilungsrunde die Anzahl der winner auf 0 setzen
winnersCounter = 0;
// Siegerposition und -anzahl von denen ermitteln, die noch an der Potverteilung teilnehmen
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(cardsValueArray[i] == highestCardsValueTemp ) {
winnersArray[winnersCounter] = i;
winnersCounter++;
}
}
// --------------------------------------------------------------
// A) nur einer hat aktulle Potverteilungsrunde gewonnen gewonnen
// --------------------------------------------------------------
if(winnersCounter == 1) {
// winnerID ist an der ersten Stelle im winnersArray
winner = winnersArray[0];
// Winner ist nicht All In gegangen -> bekommt den gesamten Pot
// if(myHand->getPlayerArray()[winner]->getMyAction() != 6) {
//
// myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+myHand->getBoard()->getPot());
// myHand->getBoard()->setPot(0);
// playerWantsPotCounter = 1;
//
// }
// Winner ist All In gegangen -> von denen die weniger gesetzt oder gefoldet hatten alles nehmen und von denen die mehr gesetzt hatten nur die eigenen Sets nehmen
// else {
// alle Spieler nacheinander durchgehen und prfen von wem man wieviel Geld aus dem Pot bekommt
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
// zuerst prfen ob ein gefoldeter Spieler was gesetzt hatte
if(i != winner && myHand->getPlayerArray()[i]->getMyAction() == 1) {
// diesen Teil aus dem Pot holen
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]);
// Pot dementsprechend verkleinern
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
// deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nimmt der Winner dann von diesen Spielern 0 Dollar aus dem Pot
roundSetArray[i] = 0;
}
// nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht von einem selber
if(i != winner && cardsValueArray[i] != 0) {
// zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten
if(roundSetArray[winner] >= roundSetArray[i]) {
// von denen alles holen
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]);
// Pot dementsprechend verkleinern
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
// diese Spieler dann von der weiteren Potverteilung ausschlieᅵn
cardsValueArray[i] = 0;
playerWantsPotCounter--;
// deren Sets auf Null seztzen, da sie schon alles abgegeben haben
roundSetArray[i] = 0;
}
// nun alle Spieler die mehr gesetzt hatten
else {
// den eigenen Setanteil aus dem Pot holen
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]);
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]);
// den Set des Gegners um den bereits abgenommenen Setanteil verkleinern
roundSetArray[i] = roundSetArray[i] - roundSetArray[winner];
// diese Spieler nehmen an der weiteren Potverteilung teil
}
}
}
// // }
// zum Scluss noch eingenen Set wieder holen
myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]);
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]);
// nicht mehr an der weiteren Potverteilung teilnehmen, da man sich alles geholt hat was einem zusteht
cardsValueArray[winner] = 0;
playerWantsPotCounter--;
// eigene Sets auf Null seztzen, da sie eben eingesammelt wurden
roundSetArray[winner] = 0;
}
// ----------------------------------------------------------------------
// B) mehrere haben die aktuelle Potverteilungsrunde gewonnen -> SplitPot
// ----------------------------------------------------------------------
else {
// hierfr wird ein temporᅵer WinnersPot erstellt; dort flieᅵn erstmal alle zustehenden Anteile aus dem Pot rauf; am Ende wird dies auf die Winners verteilt
winnersPot = 0;
// hᅵhster Set aller Winner
winnersMaxSet = 0;
// den hᅵhsten Set aller Winner ermitteln
for(i=0; i<winnersCounter; i++) {
if(roundSetArray[winnersArray[i]] > winnersMaxSet) winnersMaxSet = roundSetArray[i];
}
// gesamtSet aller Winner
winnersSets = 0;
for(i=0; i<winnersCounter; i++) {
winnersSets += roundSetArray[winnersArray[i]];
}
// alle Spieler nacheinander durchgehen und prfen von wem die Winner wieviel Geld aus dem Pot bekommen
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
// prfen ob Spieler i zu den Winnern gehᅵt
playerIsWinner = 0;
for(j=0; j<winnersCounter; j++) {
if(winnersArray[j] == i) playerIsWinner = 1; // -> Spieler i gehᅵt zu den Winnern
}
// zuerst prfen ob ein gefoldeter Spieler was gesetzt hatte
if(!playerIsWinner && myHand->getPlayerArray()[i]->getMyAction() == 1) {
// diesen Teil aus dem Pot holen und dem winnersPot geben
winnersPot += roundSetArray[i];
// Pot dementsprechend verkleinern
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
// deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nehmen die Winner dann von diesen Spielern 0 Dollar aus dem Pot
roundSetArray[i] = 0;
}
// nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht zu den Winnern gehᅵen
if(!playerIsWinner && cardsValueArray[i] != 0) {
// zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten
if(winnersMaxSet >= roundSetArray[i]) {
// von denen alles holen
winnersPot += roundSetArray[i];
// Pot dementsprechend verkleinern
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]);
// diese Spieler dann von der weiteren Potverteilung ausschlieᅵn
cardsValueArray[i] = 0;
playerWantsPotCounter--;
// deren Sets auf Null seztzen, da sie schon alles abgegeben haben
roundSetArray[i] = 0;
}
// nun alle Spieler die mehr gesetzt hatten
else {
// den eigenen Setanteil aus dem Pot holen
winnersPot += winnersMaxSet;
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersMaxSet);
// den Set des Gegners um den bereits abgenommenen Setanteil verkleinern
roundSetArray[i] = roundSetArray[i] - winnersMaxSet;
// diese Spieler nehmen an der weiteren Potverteilung teil
}
}
}
// zum Schluss noch die eingenen Set aus dem Pot holen
winnersPot += winnersSets;
myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersSets);
// winnersPot verteilen (anteilmᅵig)
for(i=0; i<winnersCounter; i++) {
myHand->getPlayerArray()[winnersArray[i]]->setMyCash(myHand->getPlayerArray()[winnersArray[i]]->getMyCash()+((roundSetArray[winnersArray[i]]*winnersPot)/winnersSets));
}
for(i=0; i<winnersCounter; i++) {
// nicht mehr an der weiteren Potverteilung teilnehmen, da man sich alle Winner dieser Verteilungsrunde ihren Anteil geholt haben
cardsValueArray[winnersArray[i]] = 0;
playerWantsPotCounter--;
// Sets auf Null seztzen, da sie eben eingesammelt wurden
roundSetArray[winnersArray[i]] = 0;
}
}
}
if(myHand->getBoard()->getPot() != 0) cout << "!!! Pot: " << myHand->getBoard()->getPot() << endl;
delete[] winnersArray;
}
+77
View File
@@ -0,0 +1,77 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOCALRIVER_H
#define LOCALRIVER_H
#include <iostream>
class LocalHand;
class LocalRiver {
public:
LocalRiver(LocalHand*, int, int, int, int);
~LocalRiver();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;}
bool getFirstRiverRound() const { return firstRiverRound;}
void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setHighestCardsValue(const int& theValue) { highestCardsValue = theValue;}
int getHighestCardsValue() const { return highestCardsValue;}
void riverRun();
void postRiverRun();
void nextPlayer2();
void distributePot();
private:
LocalHand *myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int smallBlindPosition;
int smallBlind;
int highestSet;
bool firstRiverRun;
bool firstRiverRound;
int playersTurn;
int highestCardsValue;
};
#endif
+127
View File
@@ -0,0 +1,127 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "localturn.h"
#include "localhand.h"
using namespace std;
LocalTurn::LocalTurn(LocalHand* bR, int id, int qP, int dP, int sB) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), playersTurn(dP)
{ int i;
//SmallBlind-Position ermitteln
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
}
}
LocalTurn::~LocalTurn()
{
}
void LocalTurn::turnRun() {
// cout << "NextPlayerSpeed2 stop" << endl;
int i;
if (firstTurnRun) {
myHand->getGuiInterface()->dealTurnCard();
firstTurnRun = 0;
}
else {
bool allHighestSet = 1;
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl;
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
}
}
// cout << "allHighestSet " << allHighestSet << endl;
// cout << "firstflopround " << firstTurnRound << endl;
// prfen, ob Turn wirklich dran ist
if(!firstTurnRound && allHighestSet) {
// Turn nicht dran, weil alle Sets gleich sind
//also gehe in Turn
myHand->setActualRound(3);
//Action lchen und ActionButtons refresh
for(i=0; i<myHand->getGuiInterface()->getMaxQuantityPlayers(); i++) {
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
}
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
myHand->getBoard()->collectSets();
myHand->getBoard()->collectPot();
myHand->getGuiInterface()->refreshPot();
myHand->getGuiInterface()->refreshAll();
myHand->switchRounds();
}
else {
// Turn ist wirklich dran
// nhsten Spieler ermitteln
do { playersTurn = (playersTurn+1)%(myHand->getGuiInterface()->getMaxQuantityPlayers());
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
//Spieler-Position vor SmallBlind-Position ermitteln
int activePlayerBeforeSmallBlind = smallBlindPosition;
do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + myHand->getGuiInterface()->getMaxQuantityPlayers() - 1 ) % (myHand->getGuiInterface()->getMaxQuantityPlayers());
} while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6);
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
myHand->getGuiInterface()->refreshGroupbox();
// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl;
// cout << "playersTurn " << playersTurn << endl;
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstTurnRound = 0; }
if(playersTurn == 0) {
// Wir sind dran
// cout << "actualRound " << myHand->getActualRound() << endl;
// cout << "highestSet vor meInAction " << highestSet << endl;
myHand->getGuiInterface()->meInAction();
}
else {
//Gegner sind dran
// cout << "NextPlayerSpeed3 start" << endl;
myHand->getGuiInterface()->turnAnimation2();
}
}
}
}
void LocalTurn::nextPlayer2() {
// cout << "NextPlayerSpeed3 stop" << endl;
myHand->getPlayerArray()[playersTurn]->action();
}
+70
View File
@@ -0,0 +1,70 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOCALTURN_H
#define LOCALTURN_H
#include <iostream>
class LocalHand;
class LocalTurn {
public:
LocalTurn(LocalHand*, int, int, int, int);
~LocalTurn();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setFirstTurnRound(bool theValue) { firstTurnRound = theValue;}
bool getFirstTurnRound() const { return firstTurnRound;}
void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void turnRun();
void nextPlayer2();
private:
LocalHand *myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int smallBlindPosition;
int smallBlind;
int highestSet;
bool firstTurnRun;
bool firstTurnRound;
int playersTurn;
};
#endif
+72
View File
@@ -0,0 +1,72 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "tools.h"
using namespace std;
Tools::Tools()
{
}
Tools::~Tools()
{
}
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different) {
double r = end-start+1;
if (!different) {
int i;
for (i=0; i<howMany; i++) {
randArray[i] = start+(int)(r*rand()/(RAND_MAX+1.0));
}
}
else {
int tempArray[end-start];
int i;
for (i=0; i<(end-start); i++) tempArray[i]=1;
int temp;
int counter(0);
while (counter < howMany) {
temp = (int)(r*rand()/(RAND_MAX+1.0));
if (tempArray[temp] == 1) {
randArray[counter] = temp+start;
tempArray[temp] = 0;
counter++;
}
else { continue; }
}
}
}
+36
View File
@@ -0,0 +1,36 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef TOOLS_H
#define TOOLS_H
#include <iostream>
class Tools{
public:
Tools();
~Tools();
void getRandNumber(int, int, int, int*, bool);
};
#endif
+31
View File
@@ -0,0 +1,31 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "playerinterface.h"
PlayerInterface::PlayerInterface()
{
}
PlayerInterface::~PlayerInterface()
{
}
+34
View File
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PLAYERINTERFACE_H
#define PLAYERINTERFACE_H
/**
@author FThauer FHammer <f.thauer@web.de>
*/
class PlayerInterface{
public:
PlayerInterface();
~PlayerInterface();
};
#endif
+26
View File
@@ -0,0 +1,26 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "preflopinterface.h"
PreflopInterface::~PreflopInterface()
{
}
+32
View File
@@ -0,0 +1,32 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PREFLOPINTERFACE_H
#define PREFLOPINTERFACE_H
class PreflopInterface{
public:
virtual ~PreflopInterface();
};
#endif
+31
View File
@@ -0,0 +1,31 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "riverinterface.h"
RiverInterface::RiverInterface()
{
}
RiverInterface::~RiverInterface()
{
}
+34
View File
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef RIVERINTERFACE_H
#define RIVERINTERFACE_H
/**
@author FThauer FHammer <f.thauer@web.de>
*/
class RiverInterface{
public:
RiverInterface();
~RiverInterface();
};
#endif
+31
View File
@@ -0,0 +1,31 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "turninterface.h"
TurnInterface::TurnInterface()
{
}
TurnInterface::~TurnInterface()
{
}
+34
View File
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef TURNINTERFACE_H
#define TURNINTERFACE_H
/**
@author FThauer FHammer <f.thauer@web.de>
*/
class TurnInterface{
public:
TurnInterface();
~TurnInterface();
};
#endif