Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Добавлена логика кнопки помощи #2

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,34 @@ void MainWindow::on_guessButton_clicked()

void MainWindow::on_hintButton_clicked()
{
// Логика кнопки подсказки
if (!game) return;

static int hintCount = 0;
QString secretNumber = QString::fromStdString(game->getSecretNumber());
QString hint = "____";

for (int i = 0; i <= hintCount && i < 4; ++i) {
hint[i] = secretNumber[i];
}

ui->resultLabel->setText("Подсказка: " + hint);

hintCount++;
if (hintCount >= 4) {
currentAttempt = game->getMaxAttempts();
QMessageBox::information(this, "Проигрыш", "Игра окончена. Загаданное число было: " + secretNumber);
delete game;
game = nullptr;
hintCount = 0;
}
}
void MainWindow::on_helpButton_clicked()
{
// Логика кнопки помощи
QMessageBox::information(this, "Справка", "Правила игры 'Быки и коровы':\n\n"
"1. Компьютер загадывает 4-значное число.\n"
"2. Вы должны угадать это число за ограниченное количество попыток.\n"
"3. Введите 4 разные цифры и получите количество 'быков' и 'коров'.\n"
"4. 'Бык' - цифра на правильной позиции, 'Корова' - цифра есть, но на другой позиции.");
}

void MainWindow::on_guessInput1_textChanged(const QString &text)
Expand Down