コード例 #1
0
ファイル: cardutil.cpp プロジェクト: song316/joker
/**
 * @brief CardUtil::makeAllCard 生成所有54张牌。
 * @return
 */
QList<CardItem *> CardUtil::makeAllCard()
{
    QList<CardItem *> itemList;
    for(int i=0;i<13;i++){
        CardItem *itema = new CardItem();
        itema->fkPic = QPixmap(":images/image/" + QString::number(i+1) + "a.png");
        itema->CardNum = i+1;
        itema->cardType = "a";
        itema->setSelected(true);
        itemList.append(itema);

        CardItem *itemb = new CardItem();
        itemb->fkPic = QPixmap(":images/image/" + QString::number(i+1) + "b.png");
        itemb->CardNum = i+1;
        itemb->cardType = "b";
        itemb->setSelected(true);
        itemList.append(itemb);

        CardItem *itemc = new CardItem();
        itemc->fkPic = QPixmap(":images/image/" + QString::number(i+1) + "c.png");
        itemc->CardNum = i+1;
        itemc->cardType = "c";
        itemc->setSelected(true);
        itemList.append(itemc);

        CardItem *itemd = new CardItem();
        itemd->fkPic = QPixmap(":images/image/" + QString::number(i+1) + "d.png");
        itemd->CardNum = i+1;
        itemd->cardType = "d";
        itemd->setSelected(true);
        itemList.append(itemd);
    }
    CardItem *itema = new CardItem();
    itema->fkPic = QPixmap(":images/image/14a.png");
    itema->CardNum = 14;
    itema->cardType = "a";
    itema->setSelected(true);
    itemList.append(itema);

    CardItem *itemb = new CardItem();
    itemb->fkPic = QPixmap(":images/image/15a.png");
    itemb->CardNum = 15;
    itemb->cardType = "a";
    itemb->setSelected(true);
    itemList.append(itemb);
    return itemList;
}
コード例 #2
0
ファイル: cardutil.cpp プロジェクト: song316/joker
/**
 * @brief CardUtil::dealCard        发牌
 * @param myList
 * @param leftList
 * @param rightList
 */
void CardUtil::dealCard(QList<CardItem *> &myList, QList<CardItem *> &leftList, QList<CardItem *> &rightList, QList<CardItem *> &bottomList)
{
    QList<CardItem *> itemList = makeAllCard();
    for(int i=0;i<17;i++){
        qsrand(QTime::currentTime().msec());
        int index = qrand()%(itemList.size());
        CardItem *item = itemList.takeAt(index);
        item->isFront = true;
		item->setSelected(true);
        myList.append(item);

        qsrand(QTime::currentTime().msec());
        index = qrand()%(itemList.size());
        item = itemList.takeAt(index);
        leftList.append(item);

        qsrand(QTime::currentTime().msec());
        index = qrand()%(itemList.size());
        item = itemList.takeAt(index);
        rightList.append(item);
    }
    bottomList = itemList;
}