新建游戏时的保存棋谱会在文件名记录哪方获胜

This commit is contained in:
Calcitem 2020-05-03 17:59:55 +08:00
parent 76ce98e37b
commit 327f3fb28d
2 changed files with 32 additions and 10 deletions

View File

@ -132,6 +132,11 @@ public:
void humanGiveUp(); void humanGiveUp();
StateInfo getState()
{
return state;
}
signals: signals:
// 总盘数改变的信号 // 总盘数改变的信号

View File

@ -596,12 +596,36 @@ void MillGameWindow::on_actionNew_N_triggered()
{ {
auto *strlist = qobject_cast<QStringListModel *>(ui.listView->model()); auto *strlist = qobject_cast<QStringListModel *>(ui.listView->model());
// 棋未下完,且已经走了若干步以上,则算对手得分
if (strlist->stringList().size() > 12) {
gameController->humanGiveUp();
}
gameController->saveScore();
#ifdef SAVE_GAMEBOOK_WHEN_ACTION_NEW_TRIGGERED #ifdef SAVE_GAMEBOOK_WHEN_ACTION_NEW_TRIGGERED
QString strDateTime = QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss"); QString strDateTime = QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss");
QString strDate = QDateTime::currentDateTime().toString("yyyy-MM-dd");
QString whoWin;
QString path = QDir::currentPath() switch (gameController->getState().getWinner()) {
+ "/" + tr("book_") case PLAYER_BLACK:
+ strDateTime whoWin = "Black-Win";
break;
case PLAYER_WHITE:
whoWin = "White-Win";
break;
case PLAYER_DRAW:
whoWin = "Draw";
break;
default:
whoWin = "Unknown";
break;
}
QString path = QDir::currentPath() + "/"
+ tr("Book_")
+ whoWin + "_" + strDateTime
+ ".txt"; + ".txt";
// 下了一定步数之后新建游戏时才保存棋谱 // 下了一定步数之后新建游戏时才保存棋谱
@ -610,13 +634,6 @@ void MillGameWindow::on_actionNew_N_triggered()
} }
#endif /* SAVE_GAMEBOOK_WHEN_ACTION_NEW_TRIGGERED */ #endif /* SAVE_GAMEBOOK_WHEN_ACTION_NEW_TRIGGERED */
// 棋未下完,且已经走了若干步以上,则算对手得分
if (strlist->stringList().size() > 12) {
gameController->humanGiveUp();
}
gameController->saveScore();
// 取消自动运行 // 取消自动运行
ui.actionAutoRun_A->setChecked(false); ui.actionAutoRun_A->setChecked(false);