本文整理汇总了C++中Match::passCard方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::passCard方法的具体用法?C++ Match::passCard怎么用?C++ Match::passCard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::passCard方法的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";
}