From 1f8a7fa485510aec7127636338e5fbb4ef5e267d Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 8 Dec 2019 22:27:34 +0800 Subject: [PATCH] Add Auto change 1st move (WIP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 功能未完成 --- gamewindow.ui | 15 +++++++++++++++ src/game/option.cpp | 10 ++++++++++ src/game/option.h | 6 ++++++ src/ui/qt/gamecontroller.cpp | 5 +++++ src/ui/qt/gamecontroller.h | 9 +++++++++ src/ui/qt/gamewindow.cpp | 6 ++++-- 6 files changed, 49 insertions(+), 2 deletions(-) diff --git a/gamewindow.ui b/gamewindow.ui index 84030069..4a647671 100644 --- a/gamewindow.ui +++ b/gamewindow.ui @@ -278,6 +278,7 @@ + @@ -1205,6 +1206,20 @@ 引擎对战(&F) + + + true + + + false + + + true + + + 先后手轮替(&C) + + diff --git a/src/game/option.cpp b/src/game/option.cpp index ff13b6a1..0d1420ac 100644 --- a/src/game/option.cpp +++ b/src/game/option.cpp @@ -31,6 +31,16 @@ bool Options::getAutoRestart() return isAutoRestart; } +void Options::setAutoChangeFirstMove(bool enabled) +{ + isAutoChangeFirstMove = enabled; +} + +bool Options::getAutoChangeFirstMove() +{ + return isAutoChangeFirstMove; +} + void Options::setGiveUpIfMostLose(bool enabled) { giveUpIfMostLose = enabled; diff --git a/src/game/option.h b/src/game/option.h index 678a8996..c9d06880 100644 --- a/src/game/option.h +++ b/src/game/option.h @@ -28,6 +28,9 @@ public: void setAutoRestart(bool enabled); bool getAutoRestart(); + void setAutoChangeFirstMove(bool enabled); + bool getAutoChangeFirstMove(); + void setGiveUpIfMostLose(bool enabled); bool getGiveUpIfMostLose(); @@ -42,6 +45,9 @@ private: // 是否棋局结束后自动重新开局 bool isAutoRestart { false }; + // 是否重新开局时自动改变先后手 + bool isAutoChangeFirstMove { false }; + // 是否必败时认输 bool giveUpIfMostLose { false }; diff --git a/src/ui/qt/gamecontroller.cpp b/src/ui/qt/gamecontroller.cpp index b8a8652e..eb617825 100644 --- a/src/ui/qt/gamecontroller.cpp +++ b/src/ui/qt/gamecontroller.cpp @@ -411,6 +411,11 @@ void GameController::setAutoRestart(bool enabled) gameOptions.setAutoRestart(enabled); } +void GameController::setAutoChangeFirstMove(bool enabled) +{ + gameOptions.setAutoChangeFirstMove(enabled); +} + void GameController::setRandomMove(bool enabled) { gameOptions.setRandomMoveEnabled(enabled); diff --git a/src/ui/qt/gamecontroller.h b/src/ui/qt/gamecontroller.h index 7cdbfbbb..95d57a12 100644 --- a/src/ui/qt/gamecontroller.h +++ b/src/ui/qt/gamecontroller.h @@ -166,6 +166,9 @@ public slots: // 是否自动开局 void setAutoRestart(bool enabled = false); + // 是否开局自动改变先后手 + void setAutoChangeFirstMove(bool enabled = false); + // AI 是否随机走子 void setRandomMove(bool enabled); @@ -367,6 +370,12 @@ private: // 是否必败时认输 bool giveUpIfMostLose_ {false}; + // 是否自动交换先后手 + bool isAutoChangeFirstMove { false }; + + // AI 是否为先手 + bool isAiFirstMove { false }; + // 定时器ID int timeID; diff --git a/src/ui/qt/gamewindow.cpp b/src/ui/qt/gamewindow.cpp index 9fae9c12..ed5ef771 100644 --- a/src/ui/qt/gamewindow.cpp +++ b/src/ui/qt/gamewindow.cpp @@ -204,8 +204,7 @@ void MillGameWindow::initialize() connect(ui.actionEngine2_R, SIGNAL(toggled(bool)), gameController, SLOT(setEngine2(bool))); - connect(ui. - actionSound_S, SIGNAL(toggled(bool)), + connect(ui.actionSound_S, SIGNAL(toggled(bool)), gameController, SLOT(setSound(bool))); connect(ui.actionAnimation_A, SIGNAL(toggled(bool)), @@ -217,6 +216,9 @@ void MillGameWindow::initialize() connect(ui.actionAutoRestart_A, SIGNAL(toggled(bool)), gameController, SLOT(setAutoRestart(bool))); + connect(ui.actionAutoChangeFirstMove_C, SIGNAL(toggled(bool)), + gameController, SLOT(setAutoChangeFirstMove(bool))); + connect(ui.actionRandomMove_R, SIGNAL(toggled(bool)), gameController, SLOT(setRandomMove(bool)));