refactor: giveup 更名为 resign

This commit is contained in:
Calcitem 2020-09-20 21:52:41 +08:00
parent ae4c8a8b36
commit df58e02132
16 changed files with 51 additions and 51 deletions

View File

@ -89,7 +89,7 @@
<file>resources/sound/Win_B.wav</file>
<file>resources/sound/Win_W.wav</file>
<file>resources/sound/WinsAndLossesAreObvious.wav</file>
<file>resources/sound/GiveUp_B.wav</file>
<file>resources/sound/GiveUp_W.wav</file>
<file>resources/sound/Resign_B.wav</file>
<file>resources/sound/Resign_W.wav</file>
</qresource>
</RCC>

View File

@ -138,7 +138,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_giveUp">
<widget class="QPushButton" name="pushButton_resign">
<property name="font">
<font>
<family>黑体</family>
@ -263,7 +263,7 @@
<addaction name="actionEnd_E"/>
<addaction name="actionAutoRun_A"/>
<addaction name="separator"/>
<addaction name="actionGiveUp_G"/>
<addaction name="actionResign_G"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_E">
@ -293,7 +293,7 @@
<addaction name="actionSound_S"/>
<addaction name="actionAnimation_A"/>
<addaction name="separator"/>
<addaction name="actionGiveUpIfMostLose_G"/>
<addaction name="actionResignIfMostLose_G"/>
<addaction name="actionAutoRestart_A"/>
<addaction name="actionRandomMove_R"/>
</widget>
@ -988,7 +988,7 @@
<string>自动演示(A)</string>
</property>
</action>
<action name="actionGiveUp_G">
<action name="actionResign_G">
<property name="icon">
<iconset resource="gamewindow.qrc">
<normaloff>:/icon/resources/icon/BreakpointHS.png</normaloff>:/icon/resources/icon/BreakpointHS.png</iconset>
@ -1222,7 +1222,7 @@
<string>电脑着法随机(&amp;R)</string>
</property>
</action>
<action name="actionGiveUpIfMostLose_G">
<action name="actionResignIfMostLose_G">
<property name="checkable">
<bool>true</bool>
</property>

View File

@ -865,8 +865,8 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</Media>
<Media Include="resources\sound\GameStart.wav" />
<Media Include="resources\sound\GiveUp_B.wav" />
<Media Include="resources\sound\GiveUp_W.wav" />
<Media Include="resources\sound\Resign_B.wav" />
<Media Include="resources\sound\Resign_W.wav" />
<Media Include="resources\sound\loss.wav">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>

View File

@ -524,10 +524,10 @@
<Media Include="resources\sound\WinsAndLossesAreObvious.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="resources\sound\GiveUp_B.wav">
<Media Include="resources\sound\Resign_B.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="resources\sound\GiveUp_W.wav">
<Media Include="resources\sound\Resign_W.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="resources\sound\Capture_B.wav">

View File

@ -41,14 +41,14 @@ bool GameOptions::getAutoChangeFirstMove()
return isAutoChangeFirstMove;
}
void GameOptions::setGiveUpIfMostLose(bool enabled)
void GameOptions::setResignIfMostLose(bool enabled)
{
giveUpIfMostLose = enabled;
resignIfMostLose = enabled;
}
bool GameOptions::getGiveUpIfMostLose()
bool GameOptions::getResignIfMostLose()
{
return giveUpIfMostLose;
return resignIfMostLose;
}
void GameOptions::setRandomMoveEnabled(bool enabled)

View File

@ -31,8 +31,8 @@ public:
void setAutoChangeFirstMove(bool enabled);
bool getAutoChangeFirstMove();
void setGiveUpIfMostLose(bool enabled);
bool getGiveUpIfMostLose();
void setResignIfMostLose(bool enabled);
bool getResignIfMostLose();
void setRandomMoveEnabled(bool enabled);
bool getRandomMoveEnabled();
@ -56,7 +56,7 @@ protected:
private:
bool isAutoRestart { false };
bool isAutoChangeFirstMove { false };
bool giveUpIfMostLose { false };
bool resignIfMostLose { false };
bool randomMoveEnabled { true };
#ifdef ENDGAME_LEARNING_FORCE
bool learnEndgame { true };

View File

@ -839,7 +839,7 @@ bool Position::select_piece(Square s)
return false;
}
bool Position::giveup(Color loser)
bool Position::resign(Color loser)
{
if (phase & PHASE_NOTPLAYING ||
phase == PHASE_NONE) {
@ -849,7 +849,7 @@ bool Position::giveup(Color loser)
phase = PHASE_GAMEOVER;
winner = ~loser;
gameoverReason = LOSE_REASON_GIVE_UP;
gameoverReason = LOSE_REASON_RESIGN;
//sprintf(cmdline, "Player%d give up!", loser);
update_score();
@ -892,7 +892,7 @@ bool Position::command(const char *cmd)
args = sscanf(cmd, "Player%1u give up!", &t);
if (args == 1) {
return giveup((Color)t);
return resign((Color)t);
}
#ifdef THREEFOLD_REPETITION

View File

@ -133,7 +133,7 @@ public:
bool reset();
bool start();
bool giveup(Color loser);
bool resign(Color loser);
bool command(const char *cmd);
int update();
void update_score();

View File

@ -573,9 +573,9 @@ string AIAlgorithm::nextMove()
}
#endif /* ENDGAME_LEARNING */
if (gameOptions.getGiveUpIfMostLose() == true) {
if (gameOptions.getResignIfMostLose() == true) {
if (root->value <= -VALUE_MATE) {
gameoverReason = LOSE_REASON_GIVE_UP;
gameoverReason = LOSE_REASON_RESIGN;
//sprintf(cmdline, "Player%d give up!", position->sideToMove);
return cmdline;
}

View File

@ -162,7 +162,7 @@ enum GameOverReason
LOSE_REASON_LESS_THAN_THREE,
LOSE_REASON_NO_WAY,
LOSE_REASON_BOARD_IS_FULL,
LOSE_REASON_GIVE_UP,
LOSE_REASON_RESIGN,
LOSE_REASON_TIME_OVER,
DRAW_REASON_THREEFOLD_REPETITION,
DRAW_REASON_RULE_50,

View File

@ -442,8 +442,8 @@ void GameController::playSound(sound_t soundType, Color c)
case GAME_SOUND_GAME_START:
filename = "GameStart.wav";
break;
case GAME_SOUND_GIVE_UP:
filename = "GiveUp_" + sideStr + ".wav";
case GAME_SOUND_RESIGN:
filename = "Resign_" + sideStr + ".wav";
break;
case GAME_SOUND_LOSS:
filename = "loss.wav";
@ -517,9 +517,9 @@ void GameController::playSound(sound_t soundType, Color c)
#endif // TRAINING_MODE
}
void GameController::setGiveUpIfMostLose(bool enabled)
void GameController::setResignIfMostLose(bool enabled)
{
gameOptions.setGiveUpIfMostLose(enabled);
gameOptions.setResignIfMostLose(enabled);
}
void GameController::setAutoRestart(bool enabled)
@ -895,9 +895,9 @@ bool GameController::actionPiece(QPointF pos)
}
bool GameController::giveUp()
bool GameController::resign()
{
bool result = position.giveup(position.sideToMove);
bool result = position.resign(position.sideToMove);
if (!result) {
return false;
@ -919,7 +919,7 @@ bool GameController::giveUp()
}
if (position.get_winner() != NOBODY) {
playSound(GAME_SOUND_GIVE_UP, position.side_to_move());
playSound(GAME_SOUND_RESIGN, position.side_to_move());
}
#endif // TRAINING_MODE
@ -1323,10 +1323,10 @@ void GameController::showTestWindow()
gameTest->show();
}
void GameController::humanGiveUp()
void GameController::humanResign()
{
if (position.get_winner() == NOBODY) {
giveUp();
resign();
}
}
@ -1433,7 +1433,7 @@ void GameController::appendGameOverReasonToCmdlist()
case LOSE_REASON_LESS_THAN_THREE:
sprintf(cmdline, "Player%d win!", position.winner);
break;
case LOSE_REASON_GIVE_UP:
case LOSE_REASON_RESIGN:
sprintf(cmdline, "Player%d give up!", ~position.winner);
break;
default:
@ -1505,7 +1505,7 @@ void GameController::setTips()
case LOSE_REASON_NO_WAY:
reasonStr = turnStr + "无子可走被闷。";
break;
case LOSE_REASON_GIVE_UP:
case LOSE_REASON_RESIGN:
reasonStr = turnStr + "投子认负。";
break;
case LOSE_REASON_TIME_OVER:

View File

@ -56,7 +56,7 @@ enum sound_t
GAME_SOUND_DROG,
GAME_SOUND_BANNED,
GAME_SOUND_GAME_START,
GAME_SOUND_GIVE_UP,
GAME_SOUND_RESIGN,
GAME_SOUND_LOSS,
GAME_SOUND_MILL,
GAME_SOUND_MILL_REPEATLY,
@ -129,7 +129,7 @@ public:
void setAiDepthTime(int time1, int time2);
void getAiDepthTime(int &time1, int &time2);
void humanGiveUp();
void humanResign();
Position *getPosition()
{
@ -210,7 +210,7 @@ public slots:
static void playSound(sound_t soundType, Color c);
// 是否必败时认输
void setGiveUpIfMostLose(bool enabled);
void setResignIfMostLose(bool enabled);
// 是否自动开局
void setAutoRestart(bool enabled = false);
@ -323,7 +323,7 @@ public slots:
bool actionPiece(QPointF p);
// 认输
bool giveUp();
bool resign();
// 棋谱的命令行执行
bool command(const string &cmd, bool update = true);
@ -422,7 +422,7 @@ private:
inline static bool hasSound {true};
// 是否必败时认输
bool giveUpIfMostLose_ {false};
bool resignIfMostLose_ {false};
// 是否自动交换先后手
bool isAutoChangeFirstMove { false };

View File

@ -190,12 +190,12 @@ void MillGameWindow::initialize()
// 关联主窗口动作信号和控制器的槽
connect(ui.actionGiveUp_G, SIGNAL(triggered()),
gameController, SLOT(giveUp()));
connect(ui.actionResign_G, SIGNAL(triggered()),
gameController, SLOT(resign()));
#ifdef MOBILE_APP_UI
connect(ui.pushButton_giveUp, SIGNAL(released()),
gameController, SLOT(giveUp()));
connect(ui.pushButton_resign, SIGNAL(released()),
gameController, SLOT(resign()));
#endif
connect(ui.actionEngine1_T, SIGNAL(toggled(bool)),
@ -219,11 +219,11 @@ void MillGameWindow::initialize()
connect(ui.actionAnimation_A, SIGNAL(toggled(bool)),
gameController, SLOT(setAnimation(bool)));
connect(ui.actionGiveUpIfMostLose_G, SIGNAL(toggled(bool)),
gameController, SLOT(setGiveUpIfMostLose(bool)));
connect(ui.actionResignIfMostLose_G, SIGNAL(toggled(bool)),
gameController, SLOT(setResignIfMostLose(bool)));
#ifdef TEST_MODE
//ui.actionGiveUpIfMostLose_G->setChecked(true);
//ui.actionResignIfMostLose_G->setChecked(true);
#endif // TEST_MODE
connect(ui.actionAutoRestart_A, SIGNAL(toggled(bool)),
@ -393,7 +393,7 @@ void MillGameWindow::initialize()
ui.label_2->setVisible(false);
ui.label->setVisible(false);
ui.pushButton_newGame->setVisible(false);
ui.pushButton_giveUp->setVisible(false);
ui.pushButton_resign->setVisible(false);
ui.pushButton_retractMove->setVisible(false);
ui.pushButton_hint->setVisible(false);
#endif /* MOBILE_APP_UI */
@ -598,7 +598,7 @@ void MillGameWindow::on_actionNew_N_triggered()
// 棋未下完,且已经走了若干步以上,则算对手得分
if (strlist->stringList().size() > 12) {
gameController->humanGiveUp();
gameController->humanResign();
}
gameController->saveScore();

View File

@ -91,7 +91,7 @@ private slots:
// 前后招的公共槽
void on_actionRowChange();
void on_actionAutoRun_A_toggled(bool arg1);
//void on_actionGiveUp_G_triggered();
//void on_actionResign_G_triggered();
void on_actionLimited_T_triggered();
void on_actionLocal_L_triggered();
void on_actionEngineFight_E_triggered();