当前位置: 首页>>代码示例>>C++>>正文


C++ Match::getOwner方法代码示例

本文整理汇总了C++中Match::getOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::getOwner方法的具体用法?C++ Match::getOwner怎么用?C++ Match::getOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Match的用法示例。


在下文中一共展示了Match::getOwner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onTextMessage


//.........这里部分代码省略.........
        User* u = usersBySocket.value(socket);
        if(!u){
            qWarning() << "ERROR: createMatch() user not found";
            break;
        }

        if(u->getPendingMatch() != NULL){
            qWarning() << "SKIPPING: user already has a match pending";
            break;
        }

        Match *m = new Match(this);
        m->init(u);
        m->addPlayer(u);
        matches.append(m);
        u->setPendingMatch(m);

        QJsonObject obj;
        obj["request"] = 2;
        obj["result"] = "ok";
        QJsonDocument doc;
        doc.setObject(obj);
        QByteArray msg = doc.toJson(QJsonDocument::Compact);
        socket->sendTextMessage(msg);
        connect(m, &Match::finished, this, &ShtServer::onMatchFinished);
    }break;
    case 3:     //JOIN MATCH
    {
        User* u = usersBySocket.value(socket);
        if(!u){
            qWarning() << "ERROR: joinMatch() user not found";
            break;
        }

        Match* m = findMatch(docObj["uuid"].toString());
        if(!m){
            qWarning() << "ERROR: match not found";
            break;
        }
        m->addPlayer(u);
        u->setPendingMatch(m);
    }break;
    case 4:     //LEAVE MATCH
    {
        User* u = usersBySocket.value(socket);
        if(!u){
            qWarning() << "ERROR: leaveMatch() user not found";
            break;
        }

        Match* m = findMatch(docObj["uuid"].toString());
        if(!m){
            qWarning() << "ERROR: match not found";
            break;
        }
        m->leavePlayer(u);
    }break;
    case 5:     //PASS CARD
    {
        User* u = usersBySocket.value(socket);
        if(!u){
            qWarning() << "ERROR: passCard user not found";
            break;
        }

        Match* m = findMatch(docObj["uuid"].toString());
        if(!m){
            qWarning() << "ERROR: match not found";
            break;
        }
        m->passCard(u, docObj["card"].toString());
    }break;
    case 6:     //START MATCH
    {
        User* u = usersBySocket.value(socket);
        if(!u){
            qWarning() << "ERROR: matchStart user not found";
            break;
        }

        Match* m = findMatch(docObj["uuid"].toString());
        if(!m){
            qWarning() << "ERROR: match not found";
            break;
        }

        //Only match creator can start the match
        if(m->state()==Match::INIT && m->getOwner() == u){
            m->start();
        } else {
            u->sendMessage("match_server", "start_game", "denied", "");
        }

    }break;

    default:
        break;
    }
    qWarning() << "Request " << r << " evaded in " << totalTime.elapsed() << "ms";
}
开发者ID:illogica,项目名称:Sht,代码行数:101,代码来源:shtserver.cpp


注:本文中的Match::getOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。