From 432dc0df6698c1a608d694b77bb0189502deefd4 Mon Sep 17 00:00:00 2001 From: OEtzi007 Date: Wed, 12 Mar 2014 19:29:41 +0100 Subject: [PATCH] more debugged ;) Signed-off-by: OEtzi007 --- hdr/game/State.h | 9 ++- src/userinterface/ShowSimulationWindow.cpp | 13 +++-- src/userinterface/Spielbrett.cpp | 66 ++++++++++------------ 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/hdr/game/State.h b/hdr/game/State.h index 1c09a53..bf73f76 100644 --- a/hdr/game/State.h +++ b/hdr/game/State.h @@ -77,9 +77,12 @@ class State { void setPlayersTurn(PLAYERCOLOR x) { playersTurn = x; } - PLAYERCOLOR getPlayersTurn() { //TODO @OEtzi007 is this ok, dynamicState->lastMove->PLAYERCOLOR was buggy - return playersTurn; - } + //TODO @OEtzi007 is this ok, dynamicState->lastMove->PLAYERCOLOR was buggy + /*TODO @nikbo no it wasn't ;) my function wasn't buggy ;) + * you just needed to check, if(lastMove), if not, there isn't a player for this turn defined + * that makes in the beginning of the game sense, in the first move, you don't want to show random + * someones cards ;) + */ }; diff --git a/src/userinterface/ShowSimulationWindow.cpp b/src/userinterface/ShowSimulationWindow.cpp index 50cdb76..6a7e1e3 100644 --- a/src/userinterface/ShowSimulationWindow.cpp +++ b/src/userinterface/ShowSimulationWindow.cpp @@ -53,12 +53,13 @@ void ShowSimulationWindow::setZp() { roundCounter - 1, moveCounter)); } spielbrett->dynamicState = aZp; - spielbrett->setHand(simulationp->getHandOfPlayer( - aZp->getPlayersTurn(), - gameCounter-1, - roundCounter-1)); - - spielbrett->update(); + if (aZp->lastMove) + spielbrett->setHand( + simulationp->getHandOfPlayer(aZp->lastMove->getSpielerfarbe(), + gameCounter - 1, roundCounter - 1)); + else + spielbrett->setHand(0); + spielbrett->update(); } /** diff --git a/src/userinterface/Spielbrett.cpp b/src/userinterface/Spielbrett.cpp index b2f4115..339eefa 100644 --- a/src/userinterface/Spielbrett.cpp +++ b/src/userinterface/Spielbrett.cpp @@ -12,7 +12,7 @@ const QPen fatPen(Qt::black, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); const QPen fatGreyPen(Qt::lightGray, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); const QPen fatRedPen(QColor("#ff6c52"), 4, Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin); //TODO light red + Qt::RoundJoin); const double sL = 30.2; enum Farbart { @@ -21,15 +21,15 @@ enum Farbart { Spielbrett::Spielbrett(const Board& board, DynamicState* dynamicState, Counter points) : - board(board), dynamicState(dynamicState), points(points) { + board(board), dynamicState(dynamicState), points(points), hand(0) { drawCity = false; setBackgroundRole(QPalette::Base); setAutoFillBackground(false); setMouseTracking(true); - background = new QPixmap("images/bg1.png"); + background = new QPixmap("images/bg1.png"); - transform.translate(110.5, 57.5); + transform.translate(110.5, 57.5); transform.scale(1, sqrt(3) / 2.); transform.shear(-0.5, 0); invertedTransform = transform.inverted(); @@ -53,13 +53,11 @@ void Spielbrett::paintEvent(QPaintEvent*) { */ drawGrid(&painter); drawRailway(&painter); - - + drawCitys(&painter); + drawHand(&painter); + drawPawns(&painter); if (drawCity) drawCityNames(&painter); - drawCitys(&painter); - drawHand(&painter); - drawPawns(&painter); painter.setWorldTransform(scale.inverted(), true); } @@ -218,7 +216,7 @@ void Spielbrett::drawPawns(QPainter *painter) { void Spielbrett::drawCitys(QPainter *painter) { for (int i = 0; i < 35; i++) { - if (dynamicState->board.cityList[i]) { + if (dynamicState->board.cityList[i]) { /*cout << "i = " << i << " x = " <gameBoard.cityList[i]->place.x << " y = " << dynamicState->gameBoard.cityList[i]->place.y << endl; // << " Stadt = " << dynamicState->gameBoard.cityList[i]->name<< endl; @@ -230,7 +228,7 @@ void Spielbrett::drawCitys(QPainter *painter) { - 13, (dynamicState->board.cityList[i]->y) * sL - 8.5)), - getCityPixmap(dynamicState->board.cityList[i]->cityColor)); + getCityPixmap(dynamicState->board.cityList[i]->cityColor)); } } } @@ -239,7 +237,7 @@ void Spielbrett::drawCityNames(QPainter* painter) { QPixmap* schild = new QPixmap("images/schildkl.gif"); const City* const * townList = dynamicState->board.cityList; painter->setPen(fatPen); - painter->setFont(QFont("Times", 5, QFont::Bold)); + painter->setFont(QFont("Times", 5, QFont::Bold)); for (int i = 0; i < dynamicState->board.numberCities; i++) { QRect* rect = new QRect( transform.map( @@ -249,7 +247,7 @@ void Spielbrett::drawCityNames(QPainter* painter) { painter->drawText(*rect, Qt::AlignHCenter | Qt::AlignTop, QString::fromStdString(townList[i]->name), boundingRect); boundingRect->setWidth(boundingRect->width() + 4); - boundingRect->setHeight(boundingRect->height()); + boundingRect->setHeight(boundingRect->height()); boundingRect->setTopLeft( transform.map(QPoint(townList[i]->x * sL, townList[i]->y * sL)) + QPoint(-boundingRect->width() / 2, 8)); @@ -261,28 +259,26 @@ void Spielbrett::drawCityNames(QPainter* painter) { } } -void Spielbrett::drawHand(QPainter* painter) -{ - double size = 101.66; - painter->setPen(fatPen); - painter->setFont(QFont("Times", 10, QFont::Bold)); - QRect positionRect (0, background->height() - 20, size , 20); - //Higlighted Cities - for (int i = 0; i < 5; i++) { - if (hand[i]) { - painter->drawPixmap( - transform.map( - QPoint( - (hand[i]->x) * sL - - 13, - (hand[i]->y) * sL - - 8.5)), - getCity_hPixmap(hand[i]->cityColor)); - positionRect.moveRight(size * (i+2)); - painter->drawText(positionRect,Qt::AlignCenter, QString::fromStdString(hand[i]->name)); - } - } - +void Spielbrett::drawHand(QPainter* painter) { + if (hand) { + double size = 101.66; + painter->setPen(fatPen); + painter->setFont(QFont("Times", 10, QFont::Bold)); + QRect positionRect(0, background->height() - 20, size, 20); + //Higlighted Cities + for (int i = 0; i < 5; i++) { + if (hand[i]) { + painter->drawPixmap( + transform.map( + QPoint((hand[i]->x) * sL - 13, + (hand[i]->y) * sL - 8.5)), + getCity_hPixmap(hand[i]->cityColor)); + positionRect.moveRight(size * (i + 2)); + painter->drawText(positionRect, Qt::AlignCenter, + QString::fromStdString(hand[i]->name)); + } + } + } } void Spielbrett::resizeEvent(QResizeEvent *event) {