コード例 #1
0
void CCardLabelNexus::showCardLabelToolTip(const CCard &card, int x, int y)
{
    if (!mCardLabelToolTip->isVisible() && card.isValid())
    {
        const CGlobalConfig &cfg = CGlobalConfig::getCfg();
        const CCardTable &cardTable = CCardTable::getCardTable();

        mCardLabelToolTipSummonLabel->setVisible(false);
        const QList<CCardSkill> &skills = card.getSkills();
        QStringList skillDescr;
        skillDescr.append(QString("<b>%1</b><br>").arg(card.getName()));
        QString subTitleStr = card.isUnique() ? "Unique " : "";
        switch(card.getFaction())
        {
        case EImperialFaction: subTitleStr += "Imperial"; break;
        case EBloodthirstyFaction: subTitleStr += "Bloodthirsty"; break;
        case EXenoFaction: subTitleStr += "Xeno"; break;
        case ERighteousFaction: subTitleStr += "Righteous"; break;
        case ERaiderFaction: subTitleStr += "Raider"; break;
        default: break;
        }
        skillDescr.append(QString("<i>%1</i><table valign='middle'>").arg(subTitleStr));
        for (int i = 0; i < skills.size(); ++i)
        {
            const CSkill& curSkill = cardTable.getSkillForId(skills.at(i).getId());
            if (curSkill.isValid())
            {
                skillDescr.append(QString("<tr><td><img src='%1.png'/></td><td> %2</td></tr>")
                    .arg(cfg.getResourcePicturePath() + curSkill.getPicture())
                    .arg(curSkill.makeSignature(skills.at(i), true)));
                if (curSkill.isSummon())
                {
                    const CCard &summonCard = cardTable.getCardForId(skills.at(i).getX());
                    mCardLabelToolTipSummonLabel->setCard(summonCard);
                    mCardLabelToolTipSummonLabel->setVisible(true);
                }
            }
        }
        skillDescr.append(QString("</table>"));
        mCardLabelToolTipText->setText(skillDescr.join(""));
        mCardLabelToolTipLayout->activate();
        mCardLabelToolTip->adjustSize();

        int reqW = mCardLabelToolTip->width() + 5;
        int reqH = mCardLabelToolTip->height() + 20;
        int xRel = (QApplication::desktop()->width() - x < reqW)
            ? -reqW
            : 5;
        int yRel = (QApplication::desktop()->height() - y < reqH)
            ? -reqH
            : 20;
        mCardLabelToolTip->setGeometry(x + xRel, y + yRel, 80, 40);
        mCardLabelToolTip->setVisible(true);
    }
}
コード例 #2
0
bool CCardFilterParameters::checkCard(const CCard &card, int &num) const
{
    if (mIsCompletionEnabled)
    {
        switch (card.getSet())
        {
        case EEnclaveSet: num = qMax(num, mComplement[1]); break;
        case ENexusSet: num = qMax(num, mComplement[2]); break;
        case EBlightSet: num = qMax(num, mComplement[3]); break;
        case EPuritySet: num = qMax(num, mComplement[4]); break;
        case EHomeWorldSet: num = qMax(num, mComplement[5]); break;
        case EPhobosSet: num = qMax(num, mComplement[6]); break;
        case EPhobosAftermathSet: num = qMax(num, mComplement[7]); break;
        case EAwakeningSet: num = qMax(num, mComplement[8]); break;
        case ETerminusSet: num = qMax(num, mComplement[9]); break;
        case EOccupationSet: num = qMax(num, mComplement[10]); break;
        case EWorldshipSet: num = qMax(num, mComplement[11]); break;
        case EFlashpointSet: num = qMax(num, mComplement[12]); break;
        case EStandardSet: num = qMax(num, mComplement[0]); break;
        case ERewardSet: num = qMax(num, mComplement[13]); break;
        case EPromotionalSet: num = qMax(num, mComplement[14]); break;
        case EUpgradedSet: num = qMax(num, mComplement[15]); break;
        default: break;
        }
    }

    if (mIsBlackListEnabled)
    {
        if (mBlackList.contains(card.getName()))
        {
            return false;
        }
    }

    if (mIsBlockListEnabled)
    {
        QHash<QString, int>::const_iterator iBlock = mBlockList.find(card.getName());
        if (iBlock != mBlockList.end())
        {
            num = qMax(0, num - iBlock.value());
        }
        if (num < 1)
        {
            return false;
        }
    }

    if (mIsWhiteListEnabled)
    {
        if (mWhiteList.contains(card.getName()))
        {
            return true;
        }
    }

    if (mIsFilterOptionEnabled)
    {
        bool passRarity(true);
        switch (card.getType())
        {
        case EAssaultType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsAssaultAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsAssaultAllowed[2]; break;
            case ERareRarity: passRarity = mIsAssaultAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsAssaultAllowed[0]; break;
            default: break;
            }
            break;
        case ECommanderType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsCommanderAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsCommanderAllowed[2]; break;
            case ERareRarity: passRarity = mIsCommanderAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsCommanderAllowed[0]; break;
            default: break;
            }
            break;
        case EStructureType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsStructureAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsStructureAllowed[2]; break;
            case ERareRarity: passRarity = mIsStructureAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsStructureAllowed[0]; break;
            default: break;
            }
            break;
        case EActionType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsActionAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsActionAllowed[2]; break;
            case ERareRarity: passRarity = mIsActionAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsActionAllowed[0]; break;
            default: break;
            }
            break;
        default:
            break;
        }

        bool passFaction(true);
        bool passHealth(true);
        bool passAttack(true);
        bool passDelay(true);
        if (mIsAssaultOptionEnabled && card.getType() == EAssaultType)
        {
            switch(card.getFaction())
            {
            case EBloodthirstyFaction: passFaction = mIsFactionAllowed[0]; break;
            case EImperialFaction: passFaction = mIsFactionAllowed[1]; break;
            case ERaiderFaction: passFaction = mIsFactionAllowed[2]; break;
            case ERighteousFaction: passFaction = mIsFactionAllowed[3]; break;
            case EXenoFaction: passFaction = mIsFactionAllowed[4]; break;
            default: break;
            }
            switch (card.getHealth())
            {
            case 1: passHealth = mIsHealthAllowed[0]; break;
            case 2: passHealth = mIsHealthAllowed[1]; break;
            case 3: passHealth = mIsHealthAllowed[2]; break;
            case 4: passHealth = mIsHealthAllowed[3]; break;
            case 5:
            default: passHealth = mIsHealthAllowed[4]; break;
            }
            switch (card.getAttack())
            {
            case 0: passAttack = mIsAttackAllowed[0]; break;
            case 1: passAttack = mIsAttackAllowed[1]; break;
            case 2: passAttack = mIsAttackAllowed[2]; break;
            case 3: passAttack = mIsAttackAllowed[3]; break;
            case 4:
            default: passAttack = mIsAttackAllowed[4]; break;
            }
            switch (card.getDelay())
            {
                case 0: passDelay = mIsDelayAllowed[0]; break;
                case 1: passDelay = mIsDelayAllowed[1]; break;
                case 2: passDelay = mIsDelayAllowed[2]; break;
                case 3: passDelay = mIsDelayAllowed[3]; break;
                case 4: passDelay = mIsDelayAllowed[4]; break;
                default: break;
            }
        }
        return passRarity && passFaction && passHealth && passAttack && passDelay;
    }
    return true;
}
コード例 #3
0
void CCardLabel::setCard(const CCard& card)
{
    const CGlobalConfig &cfg = CGlobalConfig::getCfg();
    mCard = card;
    mTitleIcon = QPixmap();
    switch(card.getType())
    {
    case EAssaultType:
        switch(card.getRarity())
        {
        case ECommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "AssaultRegIcon.png"); break;
        case EUncommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "AssaultSilverIcon.png"); break;
        case ERareRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "AssaultGoldIcon.png"); break;
        case ELegendaryRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "AssaultLegendaryIcon.png"); break;
        default: break;
        }
        break;
    case ECommanderType:
        switch(card.getRarity())
        {
        case ECommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "CommanderRegIcon.png"); break;
        case EUncommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "CommanderSilverIcon.png"); break;
        case ERareRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "CommanderGoldIcon.png"); break;
        case ELegendaryRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "CommanderLegendaryIcon.png"); break;
        default: break;
        }
        break;
    case EStructureType:
        switch(card.getRarity())
        {
        case ECommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "StructureRegIcon.png"); break;
        case EUncommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "StructureSilverIcon.png"); break;
        case ERareRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "StructureGoldIcon.png"); break;
        case ELegendaryRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "StructureLegendaryIcon.png"); break;
        default: break;
        }
        break;
    case EActionType:
        switch(card.getRarity())
        {
        case ECommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "ActionRegIcon.png"); break;
        case EUncommonRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "ActionSilverIcon.png"); break;
        case ERareRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "ActionGoldIcon.png"); break;
        case ELegendaryRarity: mTitleIcon.load(cfg.getResourcePicturePath() + "ActionLegendaryIcon.png"); break;
        default: break;
        }
        break;
    default:
        break;

    }
    QPixmap cardImg;
    switch(card.getFaction())
    {
    case EImperialFaction: cardImg.load(cfg.getResourcePicturePath() + "CardImperialStyled.png"); break;
    case EBloodthirstyFaction: cardImg.load(cfg.getResourcePicturePath() + "CardBloodthirstyStyle.png"); break;
    case EXenoFaction: cardImg.load(cfg.getResourcePicturePath() + "CardXenoStyle.png"); break;
    case ERighteousFaction: cardImg.load(cfg.getResourcePicturePath() + "CardRighteousStyle.png"); break;
    case ERaiderFaction: cardImg.load(cfg.getResourcePicturePath() + "CardRaiderStyle.png"); break;
    case ENoFaction: cardImg.load(cfg.getResourcePicturePath() + "CardBasic.png"); break;
    default: cardImg.load(cfg.getResourcePicturePath() + "CardBack.png"); break;
    }

    if (card.isValid())
    {
        QPixmap unitImg;
        mCards.getCardPicture(mCard, unitImg);
        QPainter painter(&cardImg);
        painter.drawPixmap(5, 24, 150, 120, unitImg.copy(0, 15, unitImg.width(), unitImg.height() - 30));
        painter.end();
    }
    QLabel::setPixmap(cardImg);
}
コード例 #4
0
bool CCardSearchParameters::checkCard(const CCard &card, int &/*num*/) const
{
    bool pass(true);

    if (pass)
    {
        pass = card.getLwCsName().contains(mLwCsName);
    }

    if (pass)
    {
        switch(mAttackCompare)
        {
        case ECompareLarger: pass = qMax(0, card.getAttack()) > mAttackValue; break;
        case ECompareEqualOrLarger: pass = qMax(0, card.getAttack()) >= mAttackValue; break;
        case ECompareEqual: pass = qMax(0, card.getAttack()) == mAttackValue; break;
        case ECompareEqualOrLesser: pass = qMax(0, card.getAttack()) <= mAttackValue; break;
        case ECompareLesser: pass = qMax(0, card.getAttack()) < mAttackValue; break;
        default: pass = false; break;
        }
    }

    if (pass)
    {
        switch(mHpCompare)
        {
        case ECompareLarger: pass = qMax(0, card.getHealth()) > mHpValue; break;
        case ECompareEqualOrLarger: pass = qMax(0, card.getHealth()) >= mHpValue; break;
        case ECompareEqual: pass = qMax(0, card.getHealth()) == mHpValue; break;
        case ECompareEqualOrLesser: pass = qMax(0, card.getHealth()) <= mHpValue; break;
        case ECompareLesser: pass = qMax(0, card.getHealth()) < mHpValue; break;
        default: pass = false; break;
        }
    }


    if (pass && mRarityMask != 0)
    {
        switch (card.getRarity())
        {
        case ELegendaryRarity: pass = (mRarityMask & 0x1) != 0; break;
        case ERareRarity: pass = (mRarityMask & 0x2) != 0; break;
        case EUncommonRarity: pass = (mRarityMask & 0x4) != 0; break;
        case ECommonRarity: pass = (mRarityMask & 0x8) != 0; break;
        default: pass = false; break;
        }
    }

    if (pass && mTypeMask != 0)
    {
        switch (card.getType())
        {
        case EAssaultType: pass = (mTypeMask & 0x1) != 0; break;
        case EStructureType: pass = (mTypeMask & 0x2) != 0; break;
        case ECommanderType: pass = (mTypeMask & 0x4) != 0; break;
        case EActionType: pass = (mTypeMask & 0x8) != 0; break;
        default: pass = false; break;
        }
    }

    if (pass && mFactionMask != 0)
    {
        switch (card.getFaction())
        {
        case EBloodthirstyFaction: pass = (mFactionMask & 0x1) != 0; break;
        case EImperialFaction: pass = (mFactionMask & 0x2) != 0; break;
        case ERaiderFaction: pass = (mFactionMask & 0x4) != 0; break;
        case ERighteousFaction: pass = (mFactionMask & 0x8) != 0; break;
        case EXenoFaction: pass = (mFactionMask & 0x10) != 0; break;
        default: pass = false; break;
        }
    }

    if (pass && mTimerMask != 0)
    {
        switch (card.getDelay())
        {
        case 0: pass = (mTimerMask & 0x1) != 0; break;
        case 1: pass = (mTimerMask & 0x2) != 0; break;
        case 2: pass = (mTimerMask & 0x4) != 0; break;
        case 3: pass = (mTimerMask & 0x8) != 0; break;
        case 4: pass = (mTimerMask & 0x10) != 0; break;
        default: pass = false; break;
        }
    }

    if (pass && mCheckUpgradeLevel)
    {
        switch(mUpgradeLevel)
        {
        case 0: pass = card.getUpgradeLevel() == EUpgradeNotAvailable; break;
        case 1: pass = card.getUpgradeLevel() == EUpgradeLevel1; break;
        case 2: pass = card.getUpgradeLevel() == EUpgradeLevel2; break;
        default: pass = false; break;
        }
    }

    if (pass && mIsUnique)
    {
        pass = card.isUnique();
    }

    if (pass)
    {
        int skillPass(0);
        const TSkillList& skills = card.getSkills();
        for (TSkillList::const_iterator i = skills.begin(); skillPass < mSkill.size() && i != skills.end(); ++i)
        {
            const CSkill& curSkill = mCards.getSkillForId(i->getId());
            const QString &curSkillSig = curSkill.makeSignature(*i).toLower();
            for(QStringList::const_iterator j = mLwCsSkill.begin(); j != mLwCsSkill.end(); ++j)
            {
                if (curSkillSig.contains(*j))
                {
                    ++skillPass;
                    break;
                }
            }
        }
        pass = (skillPass == mSkill.size());
    }

    return pass;

}