Remove a redundant var

Reusing a var instead of making 2 vars
This commit is contained in:
2023-06-15 15:27:15 +02:00
parent d9bb801d6b
commit b327c564d0
4 changed files with 11 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 10.0.1, 2023-06-12T17:27:48. --> <!-- Written by QtCreator 10.0.1, 2023-06-15T15:25:40. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@@ -94,7 +94,6 @@ playWindow::playWindow(QWidget *parent) : QMainWindow(parent),
connect(ui->playagainButton, &QPushButton::clicked, this, [=]{reset();}); connect(ui->playagainButton, &QPushButton::clicked, this, [=]{reset();});
turnCount = 0; turnCount = 0;
computerTurnCount = 0;
player_wins = 0; player_wins = 0;
computer_wins = 0; computer_wins = 0;
} }
@@ -143,6 +142,7 @@ void playWindow::computerTurn(void)
QPixmap lose(":/images/lose.png"); QPixmap lose(":/images/lose.png");
QPixmap draw(":/images/draw.png"); QPixmap draw(":/images/draw.png");
turnCount = 0;
while (dealer->getHandValue() < 16){ while (dealer->getHandValue() < 16){
dealer->addCard(deck->drawCard()); dealer->addCard(deck->drawCard());
QPixmap img = QPixmap(":/images/cards/" + cardToImg[dealer->getLastCard()] + ".png"); QPixmap img = QPixmap(":/images/cards/" + cardToImg[dealer->getLastCard()] + ".png");
@@ -150,9 +150,9 @@ void playWindow::computerTurn(void)
ui->computerScoreLabel->setText("Computer: " + QString::number(dealer->getHandValue())); ui->computerScoreLabel->setText("Computer: " + QString::number(dealer->getHandValue()));
countToDealerLabel[computerTurnCount]->setPixmap(img); countToDealerLabel[turnCount]->setPixmap(img);
computerTurnCount++; turnCount++;
} }
//if computer is bust //if computer is bust
@@ -189,7 +189,6 @@ void playWindow::reset(void)
//Clear Labels and Variables //Clear Labels and Variables
turnCount = 0; turnCount = 0;
computerTurnCount = 0;
ui->playertotalLabel->setText("Total: " + QString::number(0)); ui->playertotalLabel->setText("Total: " + QString::number(0));

View File

@@ -53,7 +53,6 @@ private:
std::unique_ptr<Player> dealer; std::unique_ptr<Player> dealer;
std::unique_ptr<Player> player; std::unique_ptr<Player> player;
uint8_t turnCount; uint8_t turnCount;
uint8_t computerTurnCount;
int player_wins; int player_wins;
int computer_wins; int computer_wins;
}; };

View File

@@ -192,7 +192,7 @@ border-image:url(:/images/blackjack_table.png) 0 0 0 0 stretch stretch;
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QLabel" name="statusLabel"> <widget class="QLabel" name="statusLabel">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
<colorrole role="WindowText"> <colorrole role="WindowText">
@@ -814,6 +814,9 @@ border-image:url(:/images/blackjack_table.png) 0 0 0 0 stretch stretch;
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>40</width>
@@ -851,6 +854,9 @@ border-image:url(:/images/blackjack_table.png) 0 0 0 0 stretch stretch;
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>40</width>