Exemple #1
0
bool SceneGame::canMove(int moveid, int row, int col, int killid)
{
	Chess* s =_c->at(moveid);
	switch (s->_type)
	{
	case Chess::CHE:
		return canMoveChe(moveid, row, col);

	case Chess::MA:
		return canMoveMa(moveid, row, col);

	case Chess::PAO:
		// 炮有两种走法,走直线(吃) 和 跳子(不吃)
		return canMovePao(moveid, row, col, killid);

	case Chess::BING:
		return canMoveBing(moveid, row, col);

	case Chess::JIANG:
		return canMoveJiang(moveid, row, col, killid);

	case Chess::SHI:
		return canMoveShi(moveid, row, col);

	case Chess::XIANG:
		return canMoveXiang(moveid, row, col);
		break;
	}
	return false;
}
Exemple #2
0
bool Board::canMove(int moveid, int killid, int row, int col)
{
    // 如果moveid和killid颜色相同,则不能移动,还需要换选择
    if (_s[moveid]._red == _s[killid]._red) {
        _selectid = killid;
        update();
        return false;
    }


    switch (_s[moveid]._type) {
    case Stone::JIANG:
        return canMoveJiang(moveid, killid, row, col);

    case Stone::SHI:
        return canMoveShi(moveid, killid, row, col);

    case Stone::XIANG:
        return canMoveXiang(moveid, killid, row, col);

    case Stone::CHE:
        return canMoveChe(moveid, killid, row, col);

    case Stone::MA:
        return canMoveMa(moveid, killid, row, col);

    case Stone::PAO:
        return canMovePao(moveid, killid, row, col);

    case Stone::BING:
        return canMoveBing(moveid, killid, row, col);
    }

    return true;

}