setTips: Position 指针改引用
This commit is contained in:
parent
80188e0547
commit
6fcfad918c
|
@ -1385,40 +1385,40 @@ inline std::string GameController::char_to_string(char ch)
|
||||||
|
|
||||||
void GameController::setTips()
|
void GameController::setTips()
|
||||||
{
|
{
|
||||||
Position *p = &position;
|
Position &p = position;
|
||||||
|
|
||||||
string winnerStr, reasonStr, resultStr, scoreStr;
|
string winnerStr, reasonStr, resultStr, scoreStr;
|
||||||
string turnStr = char_to_string(color_to_char(p->sideToMove));
|
string turnStr = char_to_string(color_to_char(p.sideToMove));
|
||||||
|
|
||||||
switch (p->phase) {
|
switch (p.phase) {
|
||||||
case PHASE_READY:
|
case PHASE_READY:
|
||||||
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p->pieceCountInHand[BLACK]) + "子" +
|
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p.pieceCountInHand[BLACK]) + "子" +
|
||||||
" 比分 " + to_string(p->score[BLACK]) + ":" + to_string(p->score[WHITE]) + ", 和棋 " + to_string(p->score_draw);
|
" 比分 " + to_string(p.score[BLACK]) + ":" + to_string(p.score[WHITE]) + ", 和棋 " + to_string(p.score_draw);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_PLACING:
|
case PHASE_PLACING:
|
||||||
if (p->action == ACTION_PLACE) {
|
if (p.action == ACTION_PLACE) {
|
||||||
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p->pieceCountInHand[p->sideToMove]) + "子";
|
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p.pieceCountInHand[p.sideToMove]) + "子";
|
||||||
} else if (p->action == ACTION_REMOVE) {
|
} else if (p.action == ACTION_REMOVE) {
|
||||||
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p->pieceCountNeedRemove) + "子";
|
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.pieceCountNeedRemove) + "子";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_MOVING:
|
case PHASE_MOVING:
|
||||||
if (p->action == ACTION_PLACE || p->action == ACTION_SELECT) {
|
if (p.action == ACTION_PLACE || p.action == ACTION_SELECT) {
|
||||||
tips = "轮到" + turnStr + "选子移动";
|
tips = "轮到" + turnStr + "选子移动";
|
||||||
} else if (p->action == ACTION_REMOVE) {
|
} else if (p.action == ACTION_REMOVE) {
|
||||||
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p->pieceCountNeedRemove) + "子";
|
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.pieceCountNeedRemove) + "子";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_GAMEOVER:
|
case PHASE_GAMEOVER:
|
||||||
scoreStr = "比分 " + to_string(p->score[BLACK]) + " : " + to_string(p->score[WHITE]) + ", 和棋 " + to_string(p->score_draw);
|
scoreStr = "比分 " + to_string(p.score[BLACK]) + " : " + to_string(p.score[WHITE]) + ", 和棋 " + to_string(p.score_draw);
|
||||||
|
|
||||||
switch (p->winner) {
|
switch (p.winner) {
|
||||||
case BLACK:
|
case BLACK:
|
||||||
case WHITE:
|
case WHITE:
|
||||||
winnerStr = char_to_string(color_to_char(p->winner));
|
winnerStr = char_to_string(color_to_char(p.winner));
|
||||||
resultStr = winnerStr + "获胜!";
|
resultStr = winnerStr + "获胜!";
|
||||||
break;
|
break;
|
||||||
case DRAW:
|
case DRAW:
|
||||||
|
@ -1428,7 +1428,7 @@ void GameController::setTips()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (p->gameoverReason) {
|
switch (p.gameoverReason) {
|
||||||
case LOSE_EASON_LESS_THAN_THREE:
|
case LOSE_EASON_LESS_THAN_THREE:
|
||||||
break;
|
break;
|
||||||
case LOSE_REASON_NO_WAY:
|
case LOSE_REASON_NO_WAY:
|
||||||
|
|
Loading…
Reference in New Issue