本文整理汇总了C++中CardList::at方法的典型用法代码示例。如果您正苦于以下问题:C++ CardList::at方法的具体用法?C++ CardList::at怎么用?C++ CardList::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CardList
的用法示例。
在下文中一共展示了CardList::at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showDeal
void GameLogDialog::showDeal(const int row)
{
Q_ASSERT(row < model->gameLog().size());
QString output;
for (int i=1; i<=3; i++)
{
output += QString("%1: ").arg(model->player(i)->nick());
CardList cl;
foreach(const Card& c, model->gameLog().at(row).cardList[i-1])
cl.insert(const_cast<Card*>(&c));
cl.mySort();
for( int ci = 0; ci < cl.count(); ci++ )
{
output += cl.at(ci)->toUniString();
output += ' ';
}
output += '\n';
}
QMessageBox::about(0, tr("Deal #") + QString::number(row + 1), output);
}
示例2: makeMove
/*
* aLeftPlayer: next in turn
* aRightPlayer: prev in turn
* 0, 1th
* 1th, 2nd
*/
Card *AlphaBetaPlayer::makeMove (Card *lMove, Card *rMove, Player *aLeftPlayer, Player *aRightPlayer, bool isPassOut) {
qDebug() << type() << "("<< mPlayerNo << ") moves";
card_t hands[3][10];
card_t desk[3];
int crdLeft = 0;
int trumpSuit = 0;
Player *plst[3];
//again:
plst[0] = plst[1] = plst[2] = 0;
plst[mPlayerNo-1] = this;
plst[aLeftPlayer->number()-1] = aLeftPlayer;
plst[aRightPlayer->number()-1] = aRightPlayer;
// build hands
for (int c = 0; c < 3; c++) {
Q_ASSERT(plst[c]);
CardList *clst = &(plst[c]->mCards);
//for (int f = 0; f < 10; f++) hds[c][f] = hands[c][f] = 0;
int pos = 0;
for (int f = 0; f < clst->size(); f++) {
Card *ct = clst->at(f);
if (!ct) continue;
hands[c][pos++] = CARD(ct->face(), ct->suit()-1);
if (pos > crdLeft) crdLeft = pos;
}
for (int f = pos; f < 10; f++) hands[c][f] = 0;
xsortCards(hands[c], pos);
}
if (!lMove && !rMove && crdLeft == 10) {
return AiPlayer::makeMove(lMove, rMove, aLeftPlayer, aRightPlayer, isPassOut);
}
// find game
const eGameBid bid = m_model->currentGame();
gPassOutOrMisere = (bid == g86 || bid == g86catch || bid == raspass);
trumpSuit = bid%10-1;//(bid-(bid/10)*10)-1;
/*
if (bid == g86catch || bid == g86 || bid == raspass) {
return Player::moveSelectCard(lMove, rMove, aLeftPlayer, aRightPlayer);
}
*/
if (bid == g86catch || bid == g86 || bid == raspass) {
trumpSuit = 4;
}
if (trumpSuit < 0) trumpSuit = 4;
fprintf(stderr, "po:%s; lm:%s, rm:%s\n", isPassOut?"y":"n", lMove?"y":"n", rMove?"y":"n");
if (isPassOut && rMove && !lMove) {
// это распасы, первый или второй круг, первый ход
gPassOutSuit = rMove->suit()-1;
fprintf(stderr, "pass-out: %i\n", gPassOutSuit);
rMove = 0;
} else gPassOutSuit = -1;
// build desk
int turn = 0;
if (lMove) {
desk[turn++] = CARD(lMove->face(), lMove->suit()-1);
if (rMove) desk[turn++] = CARD(rMove->face(), rMove->suit()-1);
} else if (rMove) {
desk[turn++] = CARD(rMove->face(), rMove->suit()-1);
}
// build hands
for (int f = 0; f < 3; f++) {
xHands[f].suitCount[0] = xHands[f].suitCount[1] = xHands[f].suitCount[2] = xHands[f].suitCount[3] = 0;
xHands[f].suitStart[0] = xHands[f].suitStart[1] = xHands[f].suitStart[2] = xHands[f].suitStart[3] = 11;
xHands[f].tricks = plst[f]->tricksTaken();
int st;
for (int z = 0; z < 10; z++) {
if (hands[f][z]) {
xHands[f].faces[z] = FACE(hands[f][z]);
st = xHands[f].suits[z] = SUIT(hands[f][z]);
if (xHands[f].suitCount[st]++ == 0) xHands[f].suitStart[st] = z;
} else xHands[f].faces[z] = 0;
}
}
// build desk
for (int f = 0; f < turn; f++) {
xDeskFaces[f] = FACE(desk[f]);
xDeskSuits[f] = SUIT(desk[f]);
}
int a, b, c, move;
int me = this->number()-1;
xCardsLeft = crdLeft;
gTrumpSuit = trumpSuit;
//.........这里部分代码省略.........