2011-07-03 22:27:36 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* PokerTH - The open source texas holdem engine *
|
2012-12-25 15:06:23 +01:00
|
|
|
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
2011-07-03 22:27:36 +00:00
|
|
|
* *
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
2012-12-25 15:06:23 +01:00
|
|
|
* *
|
|
|
|
|
* *
|
|
|
|
|
* Additional permission under GNU AGPL version 3 section 7 *
|
|
|
|
|
* *
|
|
|
|
|
* If you modify this program, or any covered work, by linking or *
|
|
|
|
|
* combining it with the OpenSSL project's OpenSSL library (or a *
|
|
|
|
|
* modified version of that library), containing parts covered by the *
|
|
|
|
|
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
|
|
|
|
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
|
|
|
|
* permission to convey the resulting work. *
|
|
|
|
|
* Corresponding Source for a non-source form of such a combination *
|
|
|
|
|
* shall include the source code for the parts of OpenSSL used as well *
|
|
|
|
|
* as that of the covered work. *
|
2011-07-03 22:27:36 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
#ifndef LOCALPLAYER_H
|
|
|
|
|
#define LOCALPLAYER_H
|
|
|
|
|
|
2007-05-15 20:37:37 +00:00
|
|
|
#include <playerinterface.h>
|
2007-03-06 00:50:35 +00:00
|
|
|
|
2007-05-15 20:37:37 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2007-01-13 02:40:33 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
2007-05-15 20:37:37 +00:00
|
|
|
class ConfigFile;
|
2007-01-14 12:15:45 +00:00
|
|
|
class HandInterface;
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
class LocalPlayer : public PlayerInterface
|
|
|
|
|
{
|
2007-01-13 02:40:33 +00:00
|
|
|
public:
|
2011-12-18 22:34:55 +00:00
|
|
|
LocalPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB);
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-05-08 06:45:46 +00:00
|
|
|
~LocalPlayer();
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2014-05-24 15:13:49 +02:00
|
|
|
void setHand(HandInterface *theValue) {
|
|
|
|
|
currentHand = theValue;
|
|
|
|
|
}
|
2011-02-11 20:02:08 +00:00
|
|
|
int getMyID() const {
|
|
|
|
|
return myID;
|
|
|
|
|
}
|
|
|
|
|
unsigned getMyUniqueID() const {
|
|
|
|
|
return myUniqueID;
|
|
|
|
|
}
|
2011-09-28 20:20:08 +00:00
|
|
|
void setMyUniqueID(unsigned newId) {
|
|
|
|
|
myUniqueID = newId;
|
|
|
|
|
}
|
2011-08-28 17:14:03 +00:00
|
|
|
|
|
|
|
|
void setMyGuid(const std::string &theValue) {
|
|
|
|
|
myGuid = theValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string getMyGuid() const {
|
|
|
|
|
return myGuid;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
PlayerType getMyType() const {
|
|
|
|
|
return myType;
|
2007-05-26 12:40:45 +00:00
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyDude(int theValue) {
|
|
|
|
|
myDude = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyDude() const {
|
|
|
|
|
return myDude;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyDude4(int theValue) {
|
|
|
|
|
myDude4 = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyDude4() const {
|
|
|
|
|
return myDude4;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyName(const std::string& theValue) {
|
|
|
|
|
myName = theValue;
|
|
|
|
|
}
|
|
|
|
|
std::string getMyName() const {
|
|
|
|
|
return myName;
|
|
|
|
|
}
|
2009-04-22 22:32:45 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyAvatar(const std::string& theValue) {
|
|
|
|
|
myAvatar = theValue;
|
|
|
|
|
}
|
|
|
|
|
std::string getMyAvatar() const {
|
|
|
|
|
return myAvatar;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyCash(int theValue) {
|
|
|
|
|
myCash = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyCash() const {
|
|
|
|
|
return myCash;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMySet(int theValue) {
|
|
|
|
|
myLastRelativeSet = theValue;
|
|
|
|
|
mySet += theValue;
|
|
|
|
|
myCash -= theValue;
|
|
|
|
|
}
|
|
|
|
|
void setMySetAbsolute(int theValue) {
|
|
|
|
|
mySet = theValue;
|
|
|
|
|
}
|
|
|
|
|
void setMySetNull() {
|
|
|
|
|
mySet = 0;
|
|
|
|
|
myLastRelativeSet = 0;
|
|
|
|
|
}
|
|
|
|
|
int getMySet() const {
|
|
|
|
|
return mySet;
|
|
|
|
|
}
|
|
|
|
|
int getMyLastRelativeSet() const {
|
|
|
|
|
return myLastRelativeSet;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-22 00:19:53 +01:00
|
|
|
void setMyAction(PlayerAction theValue, bool human = 0) {
|
2011-02-11 20:02:08 +00:00
|
|
|
myAction = theValue;
|
2012-12-22 00:19:53 +01:00
|
|
|
// logging for seat 0
|
|
|
|
|
if(myAction && human) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, myLastRelativeSet);
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2011-10-26 22:29:47 +00:00
|
|
|
PlayerAction getMyAction() const {
|
2011-02-11 20:02:08 +00:00
|
|
|
return myAction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setMyButton(int theValue) {
|
|
|
|
|
myButton = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyButton() const {
|
|
|
|
|
return myButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setMyActiveStatus(bool theValue) {
|
|
|
|
|
myActiveStatus = theValue;
|
|
|
|
|
}
|
|
|
|
|
bool getMyActiveStatus() const {
|
|
|
|
|
return myActiveStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setMyStayOnTableStatus(bool theValue) {
|
|
|
|
|
myStayOnTableStatus = theValue;
|
|
|
|
|
}
|
|
|
|
|
bool getMyStayOnTableStatus() const {
|
|
|
|
|
return myStayOnTableStatus;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 12:41:21 +02:00
|
|
|
void setMyHoleCards(int* theValue) {
|
2011-02-11 20:02:08 +00:00
|
|
|
int i;
|
2014-05-26 12:41:21 +02:00
|
|
|
for(i=0; i<2; i++) myHoleCards[i] = theValue[i];
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2014-05-26 12:41:21 +02:00
|
|
|
void getMyHoleCards(int* theValue) const {
|
2011-02-11 20:02:08 +00:00
|
|
|
int i;
|
2014-05-26 12:41:21 +02:00
|
|
|
for(i=0; i<2; i++) theValue[i] = myHoleCards[i];
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setMyTurn(bool theValue) {
|
|
|
|
|
myTurn = theValue;
|
|
|
|
|
}
|
|
|
|
|
bool getMyTurn() const {
|
|
|
|
|
return myTurn;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 12:41:21 +02:00
|
|
|
void setMyHoleCardsFlip(bool theValue, int state) {
|
|
|
|
|
myHoleCardsFlip = theValue;
|
2007-05-29 13:15:58 +00:00
|
|
|
// log flipping cards
|
2014-05-26 12:41:21 +02:00
|
|
|
if(myHoleCardsFlip) {
|
2007-05-29 13:15:58 +00:00
|
|
|
switch(state) {
|
2011-02-11 20:02:08 +00:00
|
|
|
case 1:
|
2014-05-26 12:41:21 +02:00
|
|
|
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1], myCardsValueInt);
|
2007-05-29 13:15:58 +00:00
|
|
|
break;
|
2011-02-11 20:02:08 +00:00
|
|
|
case 2:
|
2014-05-26 12:41:21 +02:00
|
|
|
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1]);
|
2007-05-29 13:15:58 +00:00
|
|
|
break;
|
2011-02-11 20:02:08 +00:00
|
|
|
case 3:
|
2014-05-26 12:41:21 +02:00
|
|
|
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1], myCardsValueInt, "has");
|
2007-05-29 13:15:58 +00:00
|
|
|
break;
|
2011-02-11 20:02:08 +00:00
|
|
|
default:
|
|
|
|
|
;
|
2007-05-29 13:15:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-26 12:41:21 +02:00
|
|
|
bool getMyHoleCardsFlip() const {
|
|
|
|
|
return myHoleCardsFlip;
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2007-02-28 20:51:43 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyCardsValueInt(int theValue) {
|
|
|
|
|
myCardsValueInt = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyCardsValueInt() const {
|
|
|
|
|
return myCardsValueInt;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-11-13 01:05:28 +00:00
|
|
|
void setLogHoleCardsDone(bool theValue) {
|
|
|
|
|
logHoleCardsDone = theValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool getLogHoleCardsDone() const {
|
|
|
|
|
return logHoleCardsDone;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyBestHandPosition(int* theValue) {
|
2007-06-14 20:29:59 +00:00
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
myBestHandPosition[i] = theValue[i];
|
|
|
|
|
}
|
2011-02-11 20:02:08 +00:00
|
|
|
void getMyBestHandPosition(int* theValue) const {
|
2007-06-14 20:29:59 +00:00
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
theValue[i] = myBestHandPosition[i];
|
|
|
|
|
}
|
2007-01-28 00:17:49 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setMyRoundStartCash(int theValue) {
|
|
|
|
|
myRoundStartCash = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyRoundStartCash() const {
|
|
|
|
|
return myRoundStartCash;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setLastMoneyWon ( int theValue ) {
|
|
|
|
|
lastMoneyWon = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getLastMoneyWon() const {
|
|
|
|
|
return lastMoneyWon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setMyAverageSets(int theValue) {
|
|
|
|
|
myAverageSets[0] = myAverageSets[1];
|
|
|
|
|
myAverageSets[1] = myAverageSets[2];
|
|
|
|
|
myAverageSets[2] = myAverageSets[3];
|
|
|
|
|
myAverageSets[3] = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getMyAverageSets() const {
|
|
|
|
|
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
|
|
|
|
|
}
|
2007-10-29 22:26:50 +00:00
|
|
|
|
2007-05-24 20:26:23 +00:00
|
|
|
void setMyAggressive(bool theValue) {
|
2007-03-24 00:40:22 +00:00
|
|
|
int i;
|
2007-03-28 17:44:22 +00:00
|
|
|
for(i=0; i<6; i++) {
|
2007-03-24 00:40:22 +00:00
|
|
|
myAggressive[i] = myAggressive[i+1];
|
|
|
|
|
}
|
2007-03-28 17:44:22 +00:00
|
|
|
myAggressive[6] = theValue;
|
2007-03-24 00:40:22 +00:00
|
|
|
}
|
|
|
|
|
int getMyAggressive() const {
|
|
|
|
|
int i, sum = 0;
|
2007-03-28 17:44:22 +00:00
|
|
|
for(i=0; i<7; i++) {
|
2007-03-24 00:40:22 +00:00
|
|
|
sum += myAggressive[i];
|
|
|
|
|
}
|
|
|
|
|
return sum;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setSBluff ( int theValue ) {
|
|
|
|
|
sBluff = theValue;
|
|
|
|
|
}
|
|
|
|
|
int getSBluff() const {
|
|
|
|
|
return sBluff;
|
|
|
|
|
}
|
2007-03-30 12:44:16 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void setSBluffStatus ( bool theValue ) {
|
|
|
|
|
sBluffStatus = theValue;
|
|
|
|
|
}
|
|
|
|
|
bool getSBluffStatus() const {
|
|
|
|
|
return sBluffStatus;
|
|
|
|
|
}
|
2007-03-30 13:03:04 +00:00
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
void action();
|
2007-10-09 21:19:22 +00:00
|
|
|
|
2007-10-10 22:21:24 +00:00
|
|
|
int checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind);
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
void preflopEngine();
|
|
|
|
|
void flopEngine();
|
|
|
|
|
void turnEngine();
|
|
|
|
|
void riverEngine();
|
|
|
|
|
|
2007-03-27 17:16:25 +00:00
|
|
|
void preflopEngine3();
|
|
|
|
|
void flopEngine3();
|
|
|
|
|
void turnEngine3();
|
|
|
|
|
void riverEngine3();
|
|
|
|
|
|
2007-03-22 23:19:16 +00:00
|
|
|
int flopCardsValue(int*);
|
2007-03-18 00:14:09 +00:00
|
|
|
int turnCardsValue(int*);
|
2007-03-17 21:33:46 +00:00
|
|
|
|
2007-09-04 09:38:32 +00:00
|
|
|
void calcMyOdds();
|
2007-03-27 17:16:25 +00:00
|
|
|
|
2007-03-27 21:36:56 +00:00
|
|
|
void evaluation(int, int);
|
2007-03-30 13:03:04 +00:00
|
|
|
|
2011-12-11 19:37:51 +00:00
|
|
|
void setIsSessionActive(bool active);
|
|
|
|
|
bool isSessionActive() const;
|
2011-11-13 14:28:54 +00:00
|
|
|
void setIsKicked(bool kicked);
|
|
|
|
|
bool isKicked() const;
|
2012-01-08 13:02:29 +00:00
|
|
|
void setIsMuted(bool muted);
|
|
|
|
|
bool isMuted() const;
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2010-09-05 14:33:34 +00:00
|
|
|
bool checkIfINeedToShowCards();
|
2007-05-29 13:15:58 +00:00
|
|
|
|
2011-12-16 22:39:24 +00:00
|
|
|
void markRemoteAction();
|
|
|
|
|
unsigned getTimeSecSinceLastRemoteAction() const;
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
private:
|
2007-05-13 18:17:25 +00:00
|
|
|
|
|
|
|
|
ConfigFile *myConfig;
|
2007-10-18 17:40:12 +00:00
|
|
|
HandInterface *currentHand;
|
2007-04-20 23:14:08 +00:00
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
// Konstanten
|
|
|
|
|
int myID;
|
2007-05-08 06:45:46 +00:00
|
|
|
unsigned myUniqueID;
|
2011-08-28 17:14:03 +00:00
|
|
|
std::string myGuid;
|
2007-05-08 06:45:46 +00:00
|
|
|
PlayerType myType;
|
2007-01-13 02:40:33 +00:00
|
|
|
std::string myName;
|
2007-03-29 00:15:43 +00:00
|
|
|
std::string myAvatar;
|
2007-01-19 19:13:59 +00:00
|
|
|
int myDude;
|
2007-03-06 00:50:35 +00:00
|
|
|
int myDude4;
|
2007-01-19 19:13:59 +00:00
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
|
|
|
|
|
// Laufvariablen
|
|
|
|
|
int myCardsValueInt;
|
2007-01-28 00:17:49 +00:00
|
|
|
int myBestHandPosition[5];
|
2007-03-27 17:16:25 +00:00
|
|
|
double myOdds;
|
2007-03-06 00:50:35 +00:00
|
|
|
int myNiveau[3];
|
2011-11-13 01:05:28 +00:00
|
|
|
bool logHoleCardsDone;
|
2007-03-06 00:50:35 +00:00
|
|
|
|
2014-05-26 12:41:21 +02:00
|
|
|
int myHoleCards[2];
|
2007-01-13 02:40:33 +00:00
|
|
|
int myCash;
|
|
|
|
|
int mySet;
|
2007-05-24 20:26:23 +00:00
|
|
|
int myLastRelativeSet;
|
2011-10-26 22:29:47 +00:00
|
|
|
PlayerAction myAction;
|
2007-01-13 02:40:33 +00:00
|
|
|
int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big
|
|
|
|
|
bool myActiveStatus; // 0 = inactive, 1 = active
|
2011-02-11 20:02:08 +00:00
|
|
|
bool myStayOnTableStatus; // 0 = left, 1 = stay
|
2007-01-13 02:40:33 +00:00
|
|
|
bool myTurn; // 0 = no, 1 = yes
|
2014-05-26 12:41:21 +02:00
|
|
|
bool myHoleCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
|
2007-01-13 02:40:33 +00:00
|
|
|
int myRoundStartCash;
|
2007-10-29 22:26:50 +00:00
|
|
|
int lastMoneyWon;
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-03-09 03:53:39 +00:00
|
|
|
int myAverageSets[4];
|
2007-03-28 17:44:22 +00:00
|
|
|
bool myAggressive[7];
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-03-30 12:44:16 +00:00
|
|
|
int sBluff;
|
2007-03-30 13:03:04 +00:00
|
|
|
bool sBluffStatus;
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2010-09-05 14:33:34 +00:00
|
|
|
unsigned m_actionTimeoutCounter;
|
2011-12-11 19:37:51 +00:00
|
|
|
bool m_isSessionActive;
|
2011-11-13 14:28:54 +00:00
|
|
|
bool m_isKicked;
|
2012-01-08 13:02:29 +00:00
|
|
|
bool m_isMuted;
|
2011-12-16 22:39:24 +00:00
|
|
|
boost::timers::portable::microsec_timer m_lastRemoteActionTimer;
|
2007-01-13 02:40:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|