From a31850c1c98af5b7c11ee9127e1e39f3c4752e3e Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Fri, 21 Jul 2023 12:15:36 +0200 Subject: [PATCH] Add win percentage in the statusbar --- playwindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/playwindow.cpp b/playwindow.cpp index 8907224..a04470e 100644 --- a/playwindow.cpp +++ b/playwindow.cpp @@ -119,6 +119,7 @@ void playWindow::playerTurn(void) { ui->statusLabel->setText("Bust!"); ui->twistButton->setEnabled(false); + ui->stickButton->setEnabled(false); // Generating Computer score computerTurn(); @@ -175,7 +176,8 @@ void playWindow::computerTurn(void) ui->outcomeLabel->setPixmap(win); player_wins++; } - ui->statusbar->showMessage("Player " + QString::number(player_wins) + " - Gamescore - " + "Computer " + QString::number(computer_wins)); + + ui->statusbar->showMessage("Gamescore Player: " + QString::number(player_wins) + " - " + "Computer: " + QString::number(computer_wins) + " - Win Percentage: " + QString::number(static_cast(player_wins) / static_cast(player_wins + computer_wins) * 100) + "%"); this->setEnabled(true); }