MCPcopy Create free account
hub / github.com/XMuli/ChineseChess / isGeneral

Method isGeneral

ChessBoard.cpp:548–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546}
547
548bool ChessBoard:: isGeneral()
549{
550 int generalId=20; //当前回合方将军id
551 if(!m_bIsRed)
552 generalId=4;
553
554 int row= m_ChessPieces[generalId].m_nRow; //当前回合方的将军row
555 int col= m_ChessPieces[generalId].m_nCol; //当前回合方的将军col
556
557 for(int i=0; i<32; ++i)
558 {
559 if(m_bIsRed && i >= 16) //红方回合:只检查黑子(0-15)能否将红帅
560 break;
561 if(!m_bIsRed && i < 16) //黑方回合:跳过黑子,只检查红子(16-31)
562 continue;
563
564 if(canMove(i,generalId,row,col) && !m_ChessPieces[i].m_bDead) //依次遍历存活子能否移动到指定坐标
565 {
566 return true;
567 }
568 }
569 return false;
570}
571
572void ChessBoard::showNetworkGui(const bool &show)
573{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected