下完棋后左下角信息栏的信息加上比分

This commit is contained in:
CalciteM Team 2019-07-20 19:19:52 +08:00
parent 87ba471531
commit 6744c31a1f
3 changed files with 17 additions and 5 deletions

View File

@ -736,10 +736,12 @@ bool GameController::giveUp()
if (chess_.whosTurn() == NineChess::PLAYER1) {
result = chess_.giveup(NineChess::PLAYER1);
score2++;
chess_.score_2++;
}
else if (chess_.whosTurn() == NineChess::PLAYER2) {
result = chess_.giveup(NineChess::PLAYER2);
score1++;
chess_.score_2++;
}
if (result) {

View File

@ -133,6 +133,9 @@ NineChess::NineChess()
// 默认选择第1号规则即“打三棋”
setContext(&RULES[1]);
// 比分归零
score_1 = score_2 = 0;
}
NineChess::NineChess(const NineChess &chess)
@ -1771,7 +1774,8 @@ void NineChess::setTips()
{
switch (context.stage) {
case NineChess::GAME_NOTSTARTED:
tips = "轮到玩家1落子剩余" + std::to_string(context.nPiecesInHand_1) + "";
tips = "轮到玩家1落子剩余" + std::to_string(context.nPiecesInHand_1) + "" +
" 比分 " + to_string(score_1) + " : " + to_string(score_2);
break;
case NineChess::GAME_PLACING:
@ -1810,15 +1814,17 @@ void NineChess::setTips()
if (winner == DRAW)
tips = "超出限定步数,双方平局";
else if (winner == PLAYER1) {
score_1++;
if (tips.find("无子可走") != tips.npos)
tips += "玩家1获胜";
tips += "玩家1获胜比分 " + to_string(score_1) + ":" + to_string(score_2);
else
tips = "玩家1获胜";
tips = "玩家1获胜比分 " + to_string(score_1) + ":" + to_string(score_2);
} else if (winner == PLAYER2) {
score_2++;
if (tips.find("无子可走") != tips.npos)
tips += "玩家2获胜";
tips += "玩家2获胜比分 " + to_string(score_1) + ":" + to_string(score_2);
else
tips = "玩家2获胜";
tips = "玩家2获胜比分 " + to_string(score_1) + ":" + to_string(score_2);
}
break;

View File

@ -64,6 +64,10 @@ public:
// typedef typename std::vector<move_t>::iterator posIterator;
// typedef typename std::vector<move_t>::const_iterator constPosIterator;
// 赢盘数
int score_1;
int score_2;
// 嵌套的规则结构体
struct Rule
{