XMuli / ChineseChess

Cross-platform and online battle platform game based on Qt: Chinese Chess. Also known as:『Xiangqi』『中国象棋』
https://www.bilibili.com/video/av45509758
GNU General Public License v3.0
709 stars 186 forks source link

对将的情况并没有考虑进去 #13

Closed kira-yamatoo closed 3 years ago

kira-yamatoo commented 3 years ago

ChessBoard类的:bool canMoveJIANG(int moveId, int killId, int row, int col)函数需要考虑对将的情况

bool ChessBoard::canMoveJIANG(int moveId, int killId, int row, int col)
{
    //对将的情况
    if (killId != -1 && m_ChessPieces[killId].m_emType == m_ChessPieces->JIANG)
        return canMoveCHE(moveId, killId, row, col );
    //请加上这一段

    if(m_ChessPieces[moveId].m_bRed) //红 将
    {
        if(row < 7 || col < 3 || col > 5)
            return false;
    }
    else  //黑 将
    {
        if(row > 2 || col < 3 || col > 5)
            return false;
    }

    int dr = m_ChessPieces[moveId].m_nRow - row;
    int dc = m_ChessPieces[moveId].m_nCol - col;
    int d = abs(dr)*10 + abs(dc);

    if(d== 1 || d == 10)
        return true;

    return false;
}
XMuli commented 3 years ago

你发现了一块没想到的地方,大佬可以直接来个 PR 的形式提交 QQ图片20210906231224

kira-yamatoo commented 3 years ago

你发现了一块没想到的地方,大佬可以直接来个 PR 的形式提交 QQ图片20210906231224

啊这 /doge我还没试过pull request

XMuli commented 3 years ago

这个就可以是你练手的地方,合并添加成功还有小绿格子🤪

kira-yamatoo commented 3 years ago

这个就可以是你练手的地方,合并添加成功还有小绿格子🤪

好耶 (๑•̀ㅂ•́)و✧

kira-yamatoo commented 3 years ago

这个就可以是你练手的地方,合并添加成功还有小绿格子🤪

可以看一下PR吗 提交了

XMuli commented 3 years ago

嗯嗯, 已回复

XMuli commented 3 years ago

如果在 commit 里面写上, #14 时候,当 PR 被合并时候,是 bot 会自动关闭 此 Issues 的;

XMuli commented 3 years ago

”对将“ 情况已修复,如有兴趣,可参见 https://github.com/xmuli/chinessChess/commit/4eb2cb9f0c01c463a906932f0e7f21c42ce0128d 实现

image