Changes in preparation for the integration of the network server. GUI does not directly know Game and Hand any more, only Session. WARNING: This version crashes due to initialization order problems.
This commit is contained in:
@@ -111,6 +111,13 @@ void LocalFlop::flopRun() {
|
|||||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; }
|
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; }
|
||||||
|
|
||||||
|
if(myHand->getGuiInterface()->isNetworkServer())
|
||||||
|
{
|
||||||
|
myHand->getGuiInterface()->waitForNetworkAction(
|
||||||
|
GAME_STATE_FLOP, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(playersTurn == 0) {
|
if(playersTurn == 0) {
|
||||||
// Wir sind dran
|
// Wir sind dran
|
||||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||||
@@ -124,6 +131,7 @@ void LocalFlop::flopRun() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalFlop::nextPlayer2() {
|
void LocalFlop::nextPlayer2() {
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ LocalHand::LocalHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, Playe
|
|||||||
|
|
||||||
CardsValue myCardsValue;
|
CardsValue myCardsValue;
|
||||||
|
|
||||||
myGui->setHand(this);
|
|
||||||
myBoard->setHand(this);
|
myBoard->setHand(this);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,13 @@ void LocalPreflop::preflopRun() {
|
|||||||
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
||||||
myHand->getGuiInterface()->refreshGroupbox(playersTurn,2);
|
myHand->getGuiInterface()->refreshGroupbox(playersTurn,2);
|
||||||
|
|
||||||
|
if(myHand->getGuiInterface()->isNetworkServer())
|
||||||
|
{
|
||||||
|
myHand->getGuiInterface()->waitForNetworkAction(
|
||||||
|
GAME_STATE_PREFLOP, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(playersTurn == 0) {
|
if(playersTurn == 0) {
|
||||||
// Wir sind dran
|
// Wir sind dran
|
||||||
myHand->getGuiInterface()->meInAction();
|
myHand->getGuiInterface()->meInAction();
|
||||||
@@ -117,6 +124,7 @@ void LocalPreflop::preflopRun() {
|
|||||||
myHand->getGuiInterface()->preflopAnimation2();
|
myHand->getGuiInterface()->preflopAnimation2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPreflop::nextPlayer2() {
|
void LocalPreflop::nextPlayer2() {
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ void LocalRiver::riverRun() {
|
|||||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; }
|
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; }
|
||||||
|
|
||||||
|
if(myHand->getGuiInterface()->isNetworkServer())
|
||||||
|
{
|
||||||
|
myHand->getGuiInterface()->waitForNetworkAction(
|
||||||
|
GAME_STATE_RIVER, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(playersTurn == 0) {
|
if(playersTurn == 0) {
|
||||||
// Wir sind dran
|
// Wir sind dran
|
||||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||||
@@ -123,6 +130,7 @@ void LocalRiver::riverRun() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalRiver::postRiverRun() {
|
void LocalRiver::postRiverRun() {
|
||||||
|
|||||||
@@ -112,6 +112,13 @@ void LocalTurn::turnRun() {
|
|||||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstTurnRound = 0; }
|
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstTurnRound = 0; }
|
||||||
|
|
||||||
|
if(myHand->getGuiInterface()->isNetworkServer())
|
||||||
|
{
|
||||||
|
myHand->getGuiInterface()->waitForNetworkAction(
|
||||||
|
GAME_STATE_TURN, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(playersTurn == 0) {
|
if(playersTurn == 0) {
|
||||||
// Wir sind dran
|
// Wir sind dran
|
||||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||||
@@ -125,6 +132,7 @@ void LocalTurn::turnRun() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalTurn::nextPlayer2() {
|
void LocalTurn::nextPlayer2() {
|
||||||
|
|||||||
@@ -110,6 +110,11 @@ Game::~Game()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HandInterface * Game::getCurrentHand()
|
||||||
|
{
|
||||||
|
return actualHand;
|
||||||
|
}
|
||||||
|
|
||||||
void Game::startHand()
|
void Game::startHand()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
|
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
|
HandInterface *getCurrentHand();
|
||||||
|
|
||||||
//Zufgriff Startvariablen
|
//Zufgriff Startvariablen
|
||||||
void setStartQuantityPlayers(const int& theValue) { startQuantityPlayers = theValue; }
|
void setStartQuantityPlayers(const int& theValue) { startQuantityPlayers = theValue; }
|
||||||
int getStartQuantityPlayers() const { return startQuantityPlayers; }
|
int getStartQuantityPlayers() const { return startQuantityPlayers; }
|
||||||
|
|||||||
@@ -22,11 +22,12 @@
|
|||||||
|
|
||||||
#include <net/clientcallback.h>
|
#include <net/clientcallback.h>
|
||||||
#include <net/servercallback.h>
|
#include <net/servercallback.h>
|
||||||
|
#include <game_defs.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
|
||||||
class Game;
|
|
||||||
class Session;
|
class Session;
|
||||||
class HandInterface;
|
|
||||||
|
|
||||||
|
|
||||||
class GuiInterface : public ClientCallback, public ServerCallback {
|
class GuiInterface : public ClientCallback, public ServerCallback {
|
||||||
@@ -34,10 +35,12 @@ public:
|
|||||||
virtual ~GuiInterface();
|
virtual ~GuiInterface();
|
||||||
|
|
||||||
virtual void initGui(int speed) =0;
|
virtual void initGui(int speed) =0;
|
||||||
//set
|
|
||||||
virtual void setGame(Game*) =0;
|
virtual Session &getSession() =0;
|
||||||
virtual void setHand(HandInterface*) =0;
|
virtual void setSession(boost::shared_ptr<Session> session) =0;
|
||||||
virtual void setSession(Session*) =0;
|
|
||||||
|
virtual bool isNetworkServer() const =0;
|
||||||
|
virtual void waitForNetworkAction(GameState state, unsigned uniquePlayerId) =0;
|
||||||
|
|
||||||
//refresh-Funktionen
|
//refresh-Funktionen
|
||||||
virtual void refreshSet() const=0;
|
virtual void refreshSet() const=0;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "guiwrapper.h"
|
#include "guiwrapper.h"
|
||||||
|
#include "session.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -43,9 +44,11 @@ GuiWrapper::~GuiWrapper()
|
|||||||
|
|
||||||
void GuiWrapper::initGui(int speed) { myW->initGui(speed); }
|
void GuiWrapper::initGui(int speed) { myW->initGui(speed); }
|
||||||
|
|
||||||
void GuiWrapper::setGame(Game *g) { myW->setGame(g); }
|
Session &GuiWrapper::getSession() { return myW->getSession(); }
|
||||||
void GuiWrapper::setHand(HandInterface *lh) { myW->setHand(lh); }
|
void GuiWrapper::setSession(boost::shared_ptr<Session> session) { myW->setSession(session); }
|
||||||
void GuiWrapper::setSession(Session *s) { myW->setSession(s); }
|
|
||||||
|
bool GuiWrapper::isNetworkServer() const { /* TODO hack */ return false; }
|
||||||
|
void GuiWrapper::waitForNetworkAction(GameState state, unsigned uniquePlayerId) { /* TODO hack */ }
|
||||||
|
|
||||||
void GuiWrapper::refreshSet() const { myW->refreshSet(); }
|
void GuiWrapper::refreshSet() const { myW->refreshSet(); }
|
||||||
void GuiWrapper::refreshCash() const { myW->refreshCash(); }
|
void GuiWrapper::refreshCash() const { myW->refreshCash(); }
|
||||||
|
|||||||
@@ -30,10 +30,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "handinterface.h"
|
class Session;
|
||||||
#include "session.h"
|
|
||||||
#include "game.h"
|
|
||||||
|
|
||||||
|
|
||||||
class GuiWrapper : public GuiInterface
|
class GuiWrapper : public GuiInterface
|
||||||
{
|
{
|
||||||
@@ -44,9 +41,11 @@ public:
|
|||||||
|
|
||||||
void initGui(int speed);
|
void initGui(int speed);
|
||||||
|
|
||||||
void setGame(Game*);
|
Session &getSession();
|
||||||
void setHand(HandInterface*);
|
void setSession(boost::shared_ptr<Session> session);
|
||||||
void setSession(Session*);
|
|
||||||
|
bool isNetworkServer() const;
|
||||||
|
void waitForNetworkAction(GameState state, unsigned uniquePlayerId);
|
||||||
|
|
||||||
void refreshSet() const;
|
void refreshSet() const;
|
||||||
void refreshCash() const;
|
void refreshCash() const;
|
||||||
|
|||||||
+32
-27
@@ -20,6 +20,9 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include "mainwindowimpl.h"
|
#include "mainwindowimpl.h"
|
||||||
|
#include <handinterface.h>
|
||||||
|
#include <session.h>
|
||||||
|
#include <game.h>
|
||||||
#include <game_defs.h>
|
#include <game_defs.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -149,44 +152,45 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
|
|||||||
|
|
||||||
//Aktive Spieler zählen
|
//Aktive Spieler zählen
|
||||||
int activePlayersCounter = 0;
|
int activePlayersCounter = 0;
|
||||||
|
HandInterface *currentHand = myW->getSession().getCurrentGame()->getCurrentHand();
|
||||||
for (k=0; k<MAX_NUMBER_OF_PLAYERS; k++) {
|
for (k=0; k<MAX_NUMBER_OF_PLAYERS; k++) {
|
||||||
if (myW->getActualHand()->getPlayerArray()[k]->getMyActiveStatus() == 1) activePlayersCounter++;
|
if (currentHand->getPlayerArray()[k]->getMyActiveStatus() == 1) activePlayersCounter++;
|
||||||
}
|
}
|
||||||
k = 0;
|
k = 0;
|
||||||
if(activePlayersCounter > 2) {
|
if(activePlayersCounter > 2) {
|
||||||
|
|
||||||
for(i=0; i<myW->getActualHand()->getStartQuantityPlayers(); i++) {
|
for(i=0; i<currentHand->getStartQuantityPlayers(); i++) {
|
||||||
|
|
||||||
if(myW->getActualHand()->getPlayerArray()[i]->getMyActiveStatus()) {
|
if(currentHand->getPlayerArray()[i]->getMyActiveStatus()) {
|
||||||
//print cash only for active players
|
//print cash only for active players
|
||||||
|
|
||||||
|
|
||||||
if(myW->getActualHand()->getPlayerArray()[i]->getMyButton() == 1) {
|
if(currentHand->getPlayerArray()[i]->getMyButton() == 1) {
|
||||||
if(k==1) { stream << ", "; }
|
if(k==1) { stream << ", "; }
|
||||||
k=1;
|
k=1;
|
||||||
stream << QString::fromUtf8(myW->getActualHand()->getPlayerArray()[i]->getMyName().c_str())+" (Dealer): "+QString::number(myW->getActualHand()->getPlayerArray()[i]->getMyCash(),10)+"$";
|
stream << QString::fromUtf8(currentHand->getPlayerArray()[i]->getMyName().c_str())+" (Dealer): "+QString::number(currentHand->getPlayerArray()[i]->getMyCash(),10)+"$";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(k==1) { stream << ", "; }
|
if(k==1) { stream << ", "; }
|
||||||
k=1;
|
k=1;
|
||||||
stream << QString::fromUtf8(myW->getActualHand()->getPlayerArray()[i]->getMyName().c_str())+": "+QString::number(myW->getActualHand()->getPlayerArray()[i]->getMyCash()+myW->getActualHand()->getPlayerArray()[i]->getMySet(),10)+"$";
|
stream << QString::fromUtf8(currentHand->getPlayerArray()[i]->getMyName().c_str())+": "+QString::number(currentHand->getPlayerArray()[i]->getMyCash()+currentHand->getPlayerArray()[i]->getMySet(),10)+"$";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(i=0; i<myW->getActualHand()->getStartQuantityPlayers(); i++) {
|
for(i=0; i<currentHand->getStartQuantityPlayers(); i++) {
|
||||||
if(myW->getActualHand()->getPlayerArray()[i]->getMyActiveStatus()) {
|
if(currentHand->getPlayerArray()[i]->getMyActiveStatus()) {
|
||||||
//print cash only for active players
|
//print cash only for active players
|
||||||
if(myW->getActualHand()->getPlayerArray()[i]->getMyButton() == 3) {
|
if(currentHand->getPlayerArray()[i]->getMyButton() == 3) {
|
||||||
if(k==1) { stream << ", "; }
|
if(k==1) { stream << ", "; }
|
||||||
k=1;
|
k=1;
|
||||||
stream << QString::fromUtf8(myW->getActualHand()->getPlayerArray()[i]->getMyName().c_str())+" (Dealer): "+QString::number(myW->getActualHand()->getPlayerArray()[i]->getMyCash()+myW->getActualHand()->getPlayerArray()[i]->getMySet(),10)+"$";
|
stream << QString::fromUtf8(currentHand->getPlayerArray()[i]->getMyName().c_str())+" (Dealer): "+QString::number(currentHand->getPlayerArray()[i]->getMyCash()+currentHand->getPlayerArray()[i]->getMySet(),10)+"$";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(k==1) { stream << ", "; }
|
if(k==1) { stream << ", "; }
|
||||||
k=1;
|
k=1;
|
||||||
stream << QString::fromUtf8(myW->getActualHand()->getPlayerArray()[i]->getMyName().c_str())+": "+QString::number(myW->getActualHand()->getPlayerArray()[i]->getMyCash()+myW->getActualHand()->getPlayerArray()[i]->getMySet(),10)+"$";
|
stream << QString::fromUtf8(currentHand->getPlayerArray()[i]->getMyName().c_str())+": "+QString::number(currentHand->getPlayerArray()[i]->getMyCash()+currentHand->getPlayerArray()[i]->getMySet(),10)+"$";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,17 +202,17 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
|
|||||||
//Aktive Spieler zählen
|
//Aktive Spieler zählen
|
||||||
int activePlayersCounter = 0;
|
int activePlayersCounter = 0;
|
||||||
for (k=0; k<MAX_NUMBER_OF_PLAYERS; k++) {
|
for (k=0; k<MAX_NUMBER_OF_PLAYERS; k++) {
|
||||||
if (myW->getActualHand()->getPlayerArray()[k]->getMyAction() != 1 && myW->getActualHand()->getPlayerArray()[k]->getMyActiveStatus() == 1) activePlayersCounter++;
|
if (currentHand->getPlayerArray()[k]->getMyAction() != 1 && currentHand->getPlayerArray()[k]->getMyActiveStatus() == 1) activePlayersCounter++;
|
||||||
}
|
}
|
||||||
if(activePlayersCounter < 3) { j=1; }
|
if(activePlayersCounter < 3) { j=1; }
|
||||||
|
|
||||||
// cout << activePlayersCounter << endl;
|
// cout << activePlayersCounter << endl;
|
||||||
// cout << (i+myW->getActualHand()->getDealerPosition()+j)%5 << endl;
|
// cout << (i+currentHand->getDealerPosition()+j)%5 << endl;
|
||||||
|
|
||||||
switch (myW->getActualHand()->getPlayerArray()[(i+myW->getActualHand()->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyButton()) {
|
switch (currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyButton()) {
|
||||||
case 2 : stream << QString::fromUtf8(myW->getActualHand()->getPlayerArray()[(i+myW->getActualHand()->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyName().c_str())+" ("+QString::number(myW->getActualHand()->getPlayerArray()[(i+myW->getActualHand()->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMySet(),10)+"$), ";
|
case 2 : stream << QString::fromUtf8(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyName().c_str())+" ("+QString::number(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMySet(),10)+"$), ";
|
||||||
break;
|
break;
|
||||||
case 3 : stream << QString::fromUtf8(myW->getActualHand()->getPlayerArray()[(i+myW->getActualHand()->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyName().c_str())+" ("+QString::number(myW->getActualHand()->getPlayerArray()[(i+myW->getActualHand()->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMySet(),10)+"$)";
|
case 3 : stream << QString::fromUtf8(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyName().c_str())+" ("+QString::number(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMySet(),10)+"$)";
|
||||||
break;
|
break;
|
||||||
default :;
|
default :;
|
||||||
}
|
}
|
||||||
@@ -226,18 +230,19 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
|
|||||||
void Log::logPlayerWinsMsg(int playerID, int pot) {
|
void Log::logPlayerWinsMsg(int playerID, int pot) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
HandInterface *currentHand = myW->getSession().getCurrentGame()->getCurrentHand();
|
||||||
|
|
||||||
myLogFile->open( QIODevice::ReadWrite );
|
myLogFile->open( QIODevice::ReadWrite );
|
||||||
QTextStream stream( myLogFile );
|
QTextStream stream( myLogFile );
|
||||||
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
||||||
|
|
||||||
// if (cardsValueInt != -1) {
|
// if (cardsValueInt != -1) {
|
||||||
// myW->textBrowser_Log->append(QString::fromUtf8(myW->getActualHand()->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$ with "+translateCardsValueCode(cardsValueInt).at(0)+"!!! ");
|
// myW->textBrowser_Log->append(QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$ with "+translateCardsValueCode(cardsValueInt).at(0)+"!!! ");
|
||||||
// stream << "</br><i>"+QString::fromUtf8(myW->getActualHand()->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
|
// stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
myW->textBrowser_Log->append(QString::fromUtf8(myW->getActualHand()->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!! ");
|
myW->textBrowser_Log->append(QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!! ");
|
||||||
stream << "</br><i>"+QString::fromUtf8(myW->getActualHand()->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
|
stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
|
||||||
// }
|
// }
|
||||||
myLogFile->close();
|
myLogFile->close();
|
||||||
|
|
||||||
@@ -340,20 +345,20 @@ void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int
|
|||||||
|
|
||||||
// Kicker anzeigen?
|
// Kicker anzeigen?
|
||||||
// for(i=0; i<5; i++) {
|
// for(i=0; i<5; i++) {
|
||||||
// if(myW->getActualHand()->getPlayerArray()[i]->getMyAction() != 1 && myW->getActualHand()->getPlayerArray()[i]->getMyActiveStatus() == 1 && myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/100000000 == 3 && myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/1000000 - (int)(myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/100000000)*100 == secondPart) {
|
// if(currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() == 1 && currentHand->getPlayerArray()[i]->getMyCardsValueInt()/100000000 == 3 && currentHand->getPlayerArray()[i]->getMyCardsValueInt()/1000000 - (int)(currentHand->getPlayerArray()[i]->getMyCardsValueInt()/100000000)*100 == secondPart) {
|
||||||
// sameHandCounter++;
|
// sameHandCounter++;
|
||||||
// if(myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt() > tempHighestCardsValueInt) {
|
// if(currentHand->getPlayerArray()[i]->getMyCardsValueInt() > tempHighestCardsValueInt) {
|
||||||
// tempHighestCardsValueInt = myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt();
|
// tempHighestCardsValueInt = currentHand->getPlayerArray()[i]->getMyCardsValueInt();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Unterschied ermitteln
|
// Unterschied ermitteln
|
||||||
// for(i=0; i<5; i++) {
|
// for(i=0; i<5; i++) {
|
||||||
// if(myW->getActualHand()->getPlayerArray()[i]->getMyAction() != 1 && myW->getActualHand()->getPlayerArray()[i]->getMyActiveStatus() == 1 && myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/100000000 == 3 && myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/1000000 - (int)(myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/100000000)*100 == secondPart) {
|
// if(currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() == 1 && currentHand->getPlayerArray()[i]->getMyCardsValueInt()/100000000 == 3 && currentHand->getPlayerArray()[i]->getMyCardsValueInt()/1000000 - (int)(currentHand->getPlayerArray()[i]->getMyCardsValueInt()/100000000)*100 == secondPart) {
|
||||||
// sameHandCounter++;
|
// sameHandCounter++;
|
||||||
// if(myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt() > tempHighestCardsValueInt) {
|
// if(currentHand->getPlayerArray()[i]->getMyCardsValueInt() > tempHighestCardsValueInt) {
|
||||||
// tempHighestCardsValueInt = myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt();
|
// tempHighestCardsValueInt = currentHand->getPlayerArray()[i]->getMyCardsValueInt();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@@ -364,7 +369,7 @@ void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int
|
|||||||
/* } else {
|
/* } else {
|
||||||
if(cardsValueInt == tempHighestCardsValueInt) {
|
if(cardsValueInt == tempHighestCardsValueInt) {
|
||||||
for(i=0; i<5; i++) {
|
for(i=0; i<5; i++) {
|
||||||
if(myW->getActualHand()->getPlayerArray()[i]->getMyAction() != 1 && myW->getActualHand()->getPlayerArray()[i]->getMyActiveStatus() == 1 && myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/100000000 == 3 && myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/1000000 - (int)(myW->getActualHand()->getPlayerArray()[i]->getMyCardsValueInt()/100000000)*100 == secondPart) ;
|
if(currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() == 1 && currentHand->getPlayerArray()[i]->getMyCardsValueInt()/100000000 == 3 && currentHand->getPlayerArray()[i]->getMyCardsValueInt()/1000000 - (int)(currentHand->getPlayerArray()[i]->getMyCardsValueInt()/100000000)*100 == secondPart) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -21,20 +21,19 @@
|
|||||||
#define MAINWINDOWIMPL_H
|
#define MAINWINDOWIMPL_H
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
#include "game_defs.h"
|
||||||
|
#include <gamedata.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
#include "handinterface.h"
|
|
||||||
#include "game_defs.h"
|
|
||||||
#include <gamedata.h>
|
|
||||||
|
|
||||||
class Session;
|
|
||||||
class Game;
|
|
||||||
class Log;
|
class Log;
|
||||||
class ConfigFile;
|
class ConfigFile;
|
||||||
|
class Session;
|
||||||
|
|
||||||
class BoardInterface;
|
class BoardInterface;
|
||||||
// class HandInterface;
|
// class HandInterface;
|
||||||
@@ -60,15 +59,11 @@ public:
|
|||||||
|
|
||||||
void initGui(int speed);
|
void initGui(int speed);
|
||||||
|
|
||||||
void setGame(Game*);
|
Session &getSession();
|
||||||
void setHand(HandInterface*);
|
void setSession(boost::shared_ptr<Session> session);
|
||||||
void setSession(Session*);
|
|
||||||
void setLog(Log*);
|
void setLog(Log*);
|
||||||
|
|
||||||
void setActualHand(HandInterface* theValue) { actualHand = theValue;}
|
|
||||||
HandInterface* getActualHand() const { return actualHand;}
|
|
||||||
|
|
||||||
|
|
||||||
//refresh-Funktionen
|
//refresh-Funktionen
|
||||||
void refreshSet();
|
void refreshSet();
|
||||||
void refreshButton();
|
void refreshButton();
|
||||||
@@ -203,9 +198,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Game *actualGame;
|
boost::shared_ptr<Session> mySession;
|
||||||
HandInterface *actualHand;
|
|
||||||
Session *mySession;
|
|
||||||
Log *myLog;
|
Log *myLog;
|
||||||
ConfigFile *myConfig;
|
ConfigFile *myConfig;
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ ServerRecvThread::AddConnection(boost::shared_ptr<ConnectData> data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerRecvThread::AddNotification(unsigned notification)
|
ServerRecvThread::AddNotification(unsigned message, unsigned param1, unsigned param2)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_notificationQueueMutex);
|
boost::mutex::scoped_lock lock(m_notificationQueueMutex);
|
||||||
m_notificationQueue.push_back(notification);
|
m_notificationQueue.push_back(Notification(message, param1, param2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -135,14 +135,16 @@ ServerRecvThread::NotificationLoop()
|
|||||||
// Process all notifications.
|
// Process all notifications.
|
||||||
while (!m_notificationQueue.empty())
|
while (!m_notificationQueue.empty())
|
||||||
{
|
{
|
||||||
unsigned notification = m_notificationQueue.front();
|
Notification notification = m_notificationQueue.front();
|
||||||
m_notificationQueue.pop_front();
|
m_notificationQueue.pop_front();
|
||||||
|
|
||||||
switch(notification)
|
switch(notification.message)
|
||||||
{
|
{
|
||||||
case NOTIFY_GAME_START:
|
case NOTIFY_GAME_START:
|
||||||
SetState(SERVER_START_GAME_STATE::Instance());
|
SetState(SERVER_START_GAME_STATE::Instance());
|
||||||
break;
|
break;
|
||||||
|
case NOTIFY_WAIT_FOR_CLIENT_ACTION:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,17 @@ ServerThread::StartGame()
|
|||||||
return; // TODO: throw exception
|
return; // TODO: throw exception
|
||||||
|
|
||||||
// Thread-safe notification.
|
// Thread-safe notification.
|
||||||
GetRecvThread().AddNotification(NOTIFY_GAME_START);
|
GetRecvThread().AddNotification(NOTIFY_GAME_START, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerThread::WaitForClientAction(GameState state, unsigned uniquePlayerId)
|
||||||
|
{
|
||||||
|
if (!IsRunning())
|
||||||
|
return; // TODO: throw exception
|
||||||
|
|
||||||
|
// Thread-safe notification.
|
||||||
|
GetRecvThread().AddNotification(NOTIFY_WAIT_FOR_CLIENT_ACTION, state, uniquePlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerCallback &
|
ServerCallback &
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
#define NOTIFY_GAME_START 1
|
#define NOTIFY_GAME_START 1
|
||||||
|
#define NOTIFY_WAIT_FOR_CLIENT_ACTION 2
|
||||||
|
|
||||||
class ServerRecvState;
|
class ServerRecvState;
|
||||||
class SenderThread;
|
class SenderThread;
|
||||||
@@ -54,15 +55,24 @@ public:
|
|||||||
void Init(const std::string &pwd, const GameData &gameData);
|
void Init(const std::string &pwd, const GameData &gameData);
|
||||||
|
|
||||||
void AddConnection(boost::shared_ptr<ConnectData> data);
|
void AddConnection(boost::shared_ptr<ConnectData> data);
|
||||||
void AddNotification(unsigned notification);
|
void AddNotification(unsigned message, unsigned param1, unsigned param2);
|
||||||
|
|
||||||
ServerCallback &GetCallback();
|
ServerCallback &GetCallback();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
struct Notification
|
||||||
|
{
|
||||||
|
Notification(unsigned m, unsigned p1, unsigned p2)
|
||||||
|
: message(m), param1(p1), param2(p2) {}
|
||||||
|
unsigned message;
|
||||||
|
unsigned param1;
|
||||||
|
unsigned param2;
|
||||||
|
};
|
||||||
|
|
||||||
typedef std::deque<boost::shared_ptr<ConnectData> > ConnectQueue;
|
typedef std::deque<boost::shared_ptr<ConnectData> > ConnectQueue;
|
||||||
typedef std::map<SOCKET, boost::shared_ptr<SessionData> > SocketSessionMap;
|
typedef std::map<SOCKET, boost::shared_ptr<SessionData> > SocketSessionMap;
|
||||||
typedef std::deque<unsigned> NotificationQueue;
|
typedef std::deque<Notification> NotificationQueue;
|
||||||
typedef std::list<std::pair<boost::microsec_timer, boost::shared_ptr<SessionData> > > CloseSessionList;
|
typedef std::list<std::pair<boost::microsec_timer, boost::shared_ptr<SessionData> > > CloseSessionList;
|
||||||
|
|
||||||
// Main function of the thread.
|
// Main function of the thread.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#ifndef _SERVERTHREAD_H_
|
#ifndef _SERVERTHREAD_H_
|
||||||
#define _SERVERTHREAD_H_
|
#define _SERVERTHREAD_H_
|
||||||
|
|
||||||
|
#include <game_defs.h>
|
||||||
#include <core/thread.h>
|
#include <core/thread.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -42,6 +43,7 @@ public:
|
|||||||
void Init(unsigned serverPort, bool ipv6, const std::string &pwd,
|
void Init(unsigned serverPort, bool ipv6, const std::string &pwd,
|
||||||
const GameData &gameData);
|
const GameData &gameData);
|
||||||
void StartGame();
|
void StartGame();
|
||||||
|
void WaitForClientAction(GameState state, unsigned uniquePlayerId);
|
||||||
|
|
||||||
ServerCallback &GetCallback();
|
ServerCallback &GetCallback();
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -87,8 +87,10 @@ int main( int argc, char **argv )
|
|||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
GuiInterface *myGuiInterface = new GuiWrapper();
|
GuiInterface *myGuiInterface = new GuiWrapper();
|
||||||
Session theFirst(myGuiInterface);
|
{
|
||||||
myGuiInterface->setSession(&theFirst);
|
boost::shared_ptr<Session> session(new Session(myGuiInterface));
|
||||||
|
myGuiInterface->setSession(session);
|
||||||
|
}
|
||||||
|
|
||||||
int retVal = a.exec();
|
int retVal = a.exec();
|
||||||
|
|
||||||
|
|||||||
+24
-8
@@ -30,7 +30,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Session::Session(GuiInterface *g)
|
Session::Session(GuiInterface *g)
|
||||||
: currentGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(g)
|
: currentGameID(0), myNetClient(0), myNetServer(0), currentGame(0), myGui(g)
|
||||||
{
|
{
|
||||||
|
|
||||||
myConfig = new ConfigFile;
|
myConfig = new ConfigFile;
|
||||||
@@ -49,9 +49,8 @@ Session::~Session()
|
|||||||
|
|
||||||
void Session::startGame(const GameData &gameData) {
|
void Session::startGame(const GameData &gameData) {
|
||||||
|
|
||||||
myGui->setGame(0);
|
|
||||||
myGui->initGui(gameData.guiSpeed);
|
|
||||||
deleteGame();
|
deleteGame();
|
||||||
|
myGui->initGui(gameData.guiSpeed);
|
||||||
|
|
||||||
currentGameID++;
|
currentGameID++;
|
||||||
|
|
||||||
@@ -75,18 +74,21 @@ void Session::startGame(const GameData &gameData) {
|
|||||||
|
|
||||||
playerDataList.push_back(playerData);
|
playerDataList.push_back(playerData);
|
||||||
}
|
}
|
||||||
|
currentGame = new Game(myGui, playerDataList, gameData, currentGameID);
|
||||||
actualGame = new Game(myGui, playerDataList, gameData, currentGameID);
|
|
||||||
myGui->setGame(actualGame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::deleteGame() {
|
void Session::deleteGame() {
|
||||||
|
|
||||||
delete actualGame;
|
delete currentGame;
|
||||||
actualGame = 0;
|
currentGame = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Game *Session::getCurrentGame()
|
||||||
|
{
|
||||||
|
return currentGame;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::startNetworkClient(const string &serverAddress, unsigned serverPort, bool ipv6, const string &pwd)
|
void Session::startNetworkClient(const string &serverAddress, unsigned serverPort, bool ipv6, const string &pwd)
|
||||||
{
|
{
|
||||||
if (myNetClient || !myGui)
|
if (myNetClient || !myGui)
|
||||||
@@ -149,6 +151,13 @@ void Session::initiateNetworkServerGame()
|
|||||||
myNetServer->StartGame();
|
myNetServer->StartGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::waitForNetworkServerAction(GameState state, unsigned uniquePlayerId)
|
||||||
|
{
|
||||||
|
if (!myNetServer)
|
||||||
|
return; // TODO: throw exception
|
||||||
|
myNetServer->WaitForClientAction(state, uniquePlayerId);
|
||||||
|
}
|
||||||
|
|
||||||
void Session::terminateNetworkServer()
|
void Session::terminateNetworkServer()
|
||||||
{
|
{
|
||||||
if (!myNetServer)
|
if (!myNetServer)
|
||||||
@@ -163,3 +172,10 @@ void Session::terminateNetworkServer()
|
|||||||
myNetServer = 0;
|
myNetServer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Session::isNetworkServerRunning() const
|
||||||
|
{
|
||||||
|
// TODO: Hack
|
||||||
|
// TODO: Every function which calls this function is also hacked.
|
||||||
|
return myNetServer != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -20,6 +20,7 @@
|
|||||||
#ifndef STDSESSION_H
|
#ifndef STDSESSION_H
|
||||||
#define STDSESSION_H
|
#define STDSESSION_H
|
||||||
#include "gamedata.h"
|
#include "gamedata.h"
|
||||||
|
#include "game_defs.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class GuiInterface;
|
class GuiInterface;
|
||||||
@@ -38,14 +39,19 @@ public:
|
|||||||
void startGame(const GameData &gameData);
|
void startGame(const GameData &gameData);
|
||||||
void deleteGame();
|
void deleteGame();
|
||||||
|
|
||||||
|
Game *getCurrentGame();
|
||||||
|
|
||||||
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
||||||
void startNetworkClientForLocalServer();
|
void startNetworkClientForLocalServer();
|
||||||
void terminateNetworkClient();
|
void terminateNetworkClient();
|
||||||
|
|
||||||
void startNetworkServer(const GameData &gameData);
|
void startNetworkServer(const GameData &gameData);
|
||||||
void initiateNetworkServerGame();
|
void initiateNetworkServerGame();
|
||||||
|
void waitForNetworkServerAction(GameState state, unsigned uniquePlayerId);
|
||||||
void terminateNetworkServer();
|
void terminateNetworkServer();
|
||||||
|
|
||||||
|
bool isNetworkServerRunning() const;
|
||||||
|
|
||||||
void setCurrentGameID(const int& theValue) { currentGameID = theValue; }
|
void setCurrentGameID(const int& theValue) { currentGameID = theValue; }
|
||||||
int getCurrentGameID() const { return currentGameID; }
|
int getCurrentGameID() const { return currentGameID; }
|
||||||
|
|
||||||
@@ -56,7 +62,7 @@ private:
|
|||||||
ClientThread *myNetClient;
|
ClientThread *myNetClient;
|
||||||
ServerThread *myNetServer;
|
ServerThread *myNetServer;
|
||||||
|
|
||||||
Game *actualGame;
|
Game *currentGame;
|
||||||
GuiInterface *myGui;
|
GuiInterface *myGui;
|
||||||
ConfigFile *myConfig;
|
ConfigFile *myConfig;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user