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

Method canMoveBING

ChessBoard.cpp:886–912  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

884}
885
886bool ChessBoard::canMoveBING(int moveId, int killId, int row, int col)
887{
888 Q_UNUSED(killId);
889 int d=relation(m_ChessPieces[moveId].m_nRow, m_ChessPieces[moveId].m_nCol, row, col);
890 if(d!= 1 && d!= 10)
891 return false;
892
893 if(isRed(moveId)) //红
894 {
895 //兵卒不可后退
896 if(row> m_ChessPieces[moveId].m_nRow)
897 return false;
898
899 //兵卒没过河不可横着走
900 if(m_ChessPieces[moveId].m_nRow>= 5 && m_ChessPieces[moveId].m_nRow== row)
901 return false;
902 }
903 else //黑
904 {
905 if(row< m_ChessPieces[moveId].m_nRow)
906 return false;
907 if(m_ChessPieces[moveId].m_nRow<= 4 && m_ChessPieces[moveId].m_nRow== row)
908 return false;
909 }
910
911 return true;
912}
913
914bool ChessBoard:: canSelect(int id)
915{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected