Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
修复了GUI界面的一个bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PikaCat committed Feb 8, 2022
1 parent a8268b4 commit f2607ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ChineseChess.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 6.0.2, 2022-02-07T13:23:02. -->
<!-- Written by QtCreator 6.0.2, 2022-02-08T22:25:28. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
11 changes: 5 additions & 6 deletions src/GUI/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ bool Dialog::eventFilter(QObject *watched, QEvent *event) {
mSelected->width(), mSelected->height()));
mChessEatAni->start();
} else {
//在选棋时不是自己方的不让选
// 在选棋时不是自己方的不让选
if (mTarget->text() == (this->m_chessEngine->side() ? "b" : "r")) {
mSelected = mTarget;
mSelected->raise();
Expand Down Expand Up @@ -423,17 +423,16 @@ void Dialog::on_MinButton_clicked() { this->showMinimized(); }
//选择红黑槽
void Dialog::on_PlayerSide_currentIndexChanged(int index) {
ui->PlayerSide->setDisabled(true);
this->m_chessEngine->setSide(index ? PikaChess::RED : PikaChess::BLACK);
// 电脑黑子
if (this->m_chessEngine->computerSide() == PikaChess::BLACK) {
//如果棋盘没翻转,那么翻转一下
// 玩家执黑方
if (1 == index) {
// 如果棋盘没翻转,那么翻转一下
if (!this->mIsFliped) {
on_Flip_clicked();
QEventLoop eventLoop;
QTimer::singleShot(600, &eventLoop, &QEventLoop::quit);
eventLoop.exec();
}
//电脑走红子,先行棋
// 电脑走红子,先行棋
computerMove();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/chessengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ std::optional<qint16> ChessEngine::getRepeatScore() {

void ChessEngine::setSide(quint8 side) { this->m_chessboard.setSide(side); }

quint8 ChessEngine::computerSide() const { return this->m_chessboard.side() ^ OPP_SIDE; }

quint8 ChessEngine::side() const { return this->m_chessboard.side(); }

QString ChessEngine::fen() const { return this->m_chessboard.getFen(); }
Expand Down
2 changes: 0 additions & 2 deletions src/chessengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class ChessEngine {

void setSide(quint8 side);

quint8 computerSide() const;

quint8 side() const;

QString fen() const;
Expand Down

0 comments on commit f2607ae

Please sign in to comment.