Skip to content

Commit

Permalink
more debugged ;)
Browse files Browse the repository at this point in the history
Signed-off-by: OEtzi007 <DavidSchmidt314@gmail.com>
  • Loading branch information
OEtzi007 authored and OEtzi007 committed Mar 12, 2014
1 parent 6938186 commit 432dc0d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
9 changes: 6 additions & 3 deletions hdr/game/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;)
*/

};

Expand Down
13 changes: 7 additions & 6 deletions src/userinterface/ShowSimulationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
66 changes: 31 additions & 35 deletions src/userinterface/Spielbrett.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand All @@ -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);
}

Expand Down Expand Up @@ -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 = " <<dynamicState->gameBoard.cityList[i]->place.x
<< " y = " << dynamicState->gameBoard.cityList[i]->place.y << endl;
// << " Stadt = " << dynamicState->gameBoard.cityList[i]->name<< endl;
Expand All @@ -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));
}
}
}
Expand All @@ -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(
Expand All @@ -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));
Expand All @@ -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) {
Expand Down

0 comments on commit 432dc0d

Please sign in to comment.