session:: shared pointer game refactoring

This commit is contained in:
doitux
2011-01-12 22:37:33 +00:00
parent a2d0272ed3
commit b6c820718a
5 changed files with 60 additions and 61 deletions
+28 -30
View File
@@ -552,7 +552,7 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) {
//Falls Spielernamen geändert wurden --> neu zeichnen --> erst beim nächsten Neustart neu ausgelesen
if (mySettingsDialog->getPlayerNickIsChanged() && myStartWindow->getSession()->getCurrentGame() && !myStartWindow->getSession()->isNetworkClientRunning()) {
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListIterator it = currentGame->getSeatsList()->begin();
(*it)->setMyName(mySettingsDialog->lineEdit_HumanPlayerName->text().toUtf8().constData());
(*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent1Name->text().toUtf8().constData());
@@ -571,7 +571,7 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) {
if(myStartWindow->getSession()->getCurrentGame() && !myStartWindow->getSession()->isNetworkClientRunning()) {
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListIterator it = currentGame->getSeatsList()->begin();
(*it)->setMyAvatar(mySettingsDialog->pushButton_HumanPlayerAvatar->getMyLink().toUtf8().constData());
(*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent1Avatar->getMyLink().toUtf8().constData());
@@ -709,7 +709,7 @@ boost::shared_ptr<Session> gameTableImpl::getSession() { assert(myStartWindow->g
//refresh-Funktionen
void gameTableImpl::refreshSet() {
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentGame->getSeatsList();
@@ -728,7 +728,7 @@ void gameTableImpl::refreshButton() {
QPixmap bigblindButton = QPixmap::fromImage(QImage(myGameTableStyle->getBigBlindPuck()));
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentGame->getSeatsList();
@@ -782,10 +782,11 @@ void gameTableImpl::refreshButton() {
void gameTableImpl::refreshPlayerName() {
if(myStartWindow->getSession()->getCurrentGame()) {
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
@@ -825,10 +826,10 @@ void gameTableImpl::refreshPlayerAvatar() {
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
int seatPlace;
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(), seatPlace=0; it_c!=seatsList->end(); it_c++, seatPlace++) {
QString countryString(QString(myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).countryCode.c_str()).toLower());
@@ -895,12 +896,12 @@ void gameTableImpl::refreshAction(int playerID, int playerAction) {
QStringList actionArray;
actionArray << "" << "fold" << "check" << "call" << "bet" << "raise" << "allin";
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
if(playerID == -1 || playerAction == -1) {
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
//if no action --> clear Pixmap
@@ -952,10 +953,10 @@ void gameTableImpl::refreshAction(int playerID, int playerAction) {
void gameTableImpl::refreshCash() {
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
@@ -973,9 +974,9 @@ void gameTableImpl::refreshGroupbox(int playerID, int status) {
if(playerID == -1 || status == -1) {
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyTurn()) {
@@ -1084,9 +1085,9 @@ void gameTableImpl::refreshAll() {
refreshSet();
refreshButton();
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction());
}
@@ -1101,9 +1102,9 @@ void gameTableImpl::refreshChangePlayer() {
refreshSet();
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentHand->getSeatsList();
PlayerList seatsList = currentGame->getSeatsList();
for (it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction());
}
@@ -1144,7 +1145,7 @@ void gameTableImpl::dealHoleCards() {
// Karten der Gegner und eigene Karten austeilen
int j;
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList seatsList = currentGame->getSeatsList();
@@ -1381,11 +1382,9 @@ void gameTableImpl::provideMyActions(int mode) {
QString pushButtonAllInString;
QString lastPushButtonCallCheckString = pushButton_CallCheck->text();
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<HandInterface> currentHand = currentGame->getCurrentHand();
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<PlayerInterface> humanPlayer = currentHand->getSeatsList()->front();
PlayerList activePlayerList = currentGame->getActivePlayerList();
PlayerList activePlayerList = currentHand->getActivePlayerList();
//really disabled buttons if human player is fold/all-in or ... and not called from dealberocards
if(/*pushButton_BetRaise->isCheckable() && */mode != 0 && (humanPlayer->getMyAction() == PLAYER_ACTION_ALLIN || humanPlayer->getMyAction() == PLAYER_ACTION_FOLD || (humanPlayer->getMySet() == currentHand->getCurrentBeRo()->getHighestSet() && (humanPlayer->getMyAction() != PLAYER_ACTION_NONE)))) {
@@ -2069,13 +2068,13 @@ void gameTableImpl::postRiverRunAnimation2() {
horizontalSlider_bet->setDisabled(TRUE);
spinBox_betValue->setDisabled(TRUE);
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
bool internetOrNetworkGame = (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK);
int nonfoldPlayersCounter = 0;
PlayerListConstIterator it_c;
PlayerList activePlayerList = currentHand->getActivePlayerList();
PlayerList activePlayerList = currentGame->getActivePlayerList();
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD)
nonfoldPlayersCounter++;
@@ -2390,13 +2389,13 @@ void gameTableImpl::showHoleCards(unsigned playerId, bool allIn)
void gameTableImpl::flipHolecardsAllIn() {
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
if(!flipHolecardsAllInAlreadyDone) {
//Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen
int nonfoldPlayersCounter = 0;
PlayerListConstIterator it_c;
PlayerList activePlayerList = currentHand->getActivePlayerList();
PlayerList activePlayerList = currentGame->getActivePlayerList();
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++;
}
@@ -2915,7 +2914,7 @@ void gameTableImpl::updateMyButtonsState(int mode) {
clearMyButtons();
}
else {
if(myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_ALLIN) { // dont show pre-actions after flip cards when allin
if(currentHand->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_ALLIN) { // dont show pre-actions after flip cards when allin
myButtonsCheckable(TRUE);
provideMyActions(mode);
}
@@ -2951,8 +2950,7 @@ void gameTableImpl::clearMyButtons() {
void gameTableImpl::myButtonsCheckable(bool state) {
Game *currentGame = myStartWindow->getSession()->getCurrentGame();
boost::shared_ptr<HandInterface> currentHand = currentGame->getCurrentHand();
boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
if(state) {
//checkable
+4 -4
View File
@@ -394,8 +394,8 @@ void guiLog::logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString b
logFileStreamString += bbName+" ($"+QString::number(bbSet,10)+")";
PlayerListConstIterator it_c;
boost::shared_ptr<HandInterface> currentHand = myW->getSession()->getCurrentGame()->getCurrentHand();
PlayerList activePlayerList = currentHand->getActivePlayerList();
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
PlayerList activePlayerList = currentGame->getActivePlayerList();
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
@@ -1543,9 +1543,9 @@ QString guiLog::determineHandName(int myCardsValueInt) {
list<int> sameHandCardsValueInt;
bool different = false;
bool equal = false;
boost::shared_ptr<HandInterface> currentHand = myW->getSession()->getCurrentGame()->getCurrentHand();
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
PlayerList activePlayerList = currentHand->getActivePlayerList();
PlayerList activePlayerList = currentGame->getActivePlayerList();
// collect cardsValueInt of all players who will show their cards
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
+2 -2
View File
@@ -52,7 +52,7 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
//only active players are allowed to start a vote
if(humanPlayer->getMyActiveStatus()) {
Game *currentGame = myW->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
PlayerListConstIterator it_c;
int activePlayerCounter=0;
PlayerList seatList = currentGame->getSeatsList();
@@ -204,7 +204,7 @@ void MyAvatarLabel::putPlayerOnIgnoreList() {
void MyAvatarLabel::reportBadAvatar() {
Game *currentGame = myW->getSession()->getCurrentGame();
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
int j=0;
PlayerListConstIterator it_c;
PlayerList seatList = currentGame->getSeatsList();
+2 -2
View File
@@ -135,9 +135,9 @@ void Session::startClientGame(boost::shared_ptr<Game> game)
currentGame = game;
}
Game *Session::getCurrentGame()
boost::shared_ptr<Game> Session::getCurrentGame()
{
return currentGame.get();
return currentGame;
}
GuiInterface *Session::getGui()
+2 -1
View File
@@ -58,7 +58,8 @@ public:
void startLocalGame(const GameData &gameData, const StartData &startData);
void startClientGame(boost::shared_ptr<Game> game);
Game *getCurrentGame();
boost::shared_ptr<Game> getCurrentGame();
GuiInterface *getGui();
Log* getMyLog() {return myLog; }
GameType getGameType();