This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/SoftwareDesign/Lab5/lab5_2_gomoku/gamewidget.cpp

33 lines
795 B
C++
Raw Normal View History

2022-05-31 09:21:56 +00:00
#include "gamewidget.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QPushButton>
GameWidget::GameWidget(QWidget *parent)
: QWidget(parent)
{
setWindowTitle("五子棋");
boardWidget = new BoardWidget(this);
connect(boardWidget, &BoardWidget::gameOver, this, &GameWidget::showWinner);
}
GameWidget::~GameWidget()
{
}
void GameWidget::showWinner(int winner)
{
if (winner != 2)
{
QString playerName = (winner == BoardWidget::WHITE_PLAYER) ? "白方" : "黑方";
QMessageBox::information(this, "游戏结束", tr("恭喜%1获胜").arg(playerName), QMessageBox::Ok);
}
else
{
QMessageBox::information(this, "游戏结束", "和棋!", QMessageBox::Ok);
}
}