Add rarity filter to deck editor
This commit is contained in:
parent
4ffec331dc
commit
829c96673b
8 changed files with 42 additions and 8 deletions
|
@ -173,7 +173,8 @@ CardInfo::CardInfo(const QString &_name,
|
||||||
const SetList &_sets,
|
const SetList &_sets,
|
||||||
const QStringMap &_customPicURLs,
|
const QStringMap &_customPicURLs,
|
||||||
MuidMap _muIds,
|
MuidMap _muIds,
|
||||||
QStringMap _setNumbers
|
QStringMap _setNumbers,
|
||||||
|
QStringMap _rarities
|
||||||
)
|
)
|
||||||
: name(_name),
|
: name(_name),
|
||||||
isToken(_isToken),
|
isToken(_isToken),
|
||||||
|
@ -192,6 +193,7 @@ CardInfo::CardInfo(const QString &_name,
|
||||||
customPicURLs(_customPicURLs),
|
customPicURLs(_customPicURLs),
|
||||||
muIds(_muIds),
|
muIds(_muIds),
|
||||||
setNumbers(_setNumbers),
|
setNumbers(_setNumbers),
|
||||||
|
rarities(_rarities),
|
||||||
cipt(_cipt),
|
cipt(_cipt),
|
||||||
tableRow(_tableRow)
|
tableRow(_tableRow)
|
||||||
{
|
{
|
||||||
|
@ -316,6 +318,7 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
xml.writeStartElement("set");
|
xml.writeStartElement("set");
|
||||||
|
|
||||||
tmpSet=sets[i]->getShortName();
|
tmpSet=sets[i]->getShortName();
|
||||||
|
xml.writeAttribute("rarity", info->getRarity(tmpSet));
|
||||||
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
|
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
|
||||||
|
|
||||||
tmpString = info->getSetNumber(tmpSet);
|
tmpString = info->getSetNumber(tmpSet);
|
||||||
|
@ -493,7 +496,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
QStringList colors, relatedCards, reverseRelatedCards;
|
QStringList colors, relatedCards, reverseRelatedCards;
|
||||||
QStringMap customPicURLs;
|
QStringMap customPicURLs;
|
||||||
MuidMap muids;
|
MuidMap muids;
|
||||||
QStringMap setNumbers;
|
QStringMap setNumbers, rarities;
|
||||||
SetList sets;
|
SetList sets;
|
||||||
int tableRow = 0;
|
int tableRow = 0;
|
||||||
int loyalty = 0;
|
int loyalty = 0;
|
||||||
|
@ -528,6 +531,9 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
if (attrs.hasAttribute("num")) {
|
if (attrs.hasAttribute("num")) {
|
||||||
setNumbers[setName] = attrs.value("num").toString();
|
setNumbers[setName] = attrs.value("num").toString();
|
||||||
}
|
}
|
||||||
|
if (attrs.hasAttribute("rarity")) {
|
||||||
|
rarities[setName] = attrs.value("rarity").toString();
|
||||||
|
}
|
||||||
} else if (xml.name() == "color")
|
} else if (xml.name() == "color")
|
||||||
colors << xml.readElementText();
|
colors << xml.readElementText();
|
||||||
else if (xml.name() == "related")
|
else if (xml.name() == "related")
|
||||||
|
@ -550,7 +556,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids, setNumbers));
|
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids, setNumbers, rarities));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ private:
|
||||||
QStringMap customPicURLs;
|
QStringMap customPicURLs;
|
||||||
MuidMap muIds;
|
MuidMap muIds;
|
||||||
QStringMap setNumbers;
|
QStringMap setNumbers;
|
||||||
|
QStringMap rarities;
|
||||||
bool cipt;
|
bool cipt;
|
||||||
int tableRow;
|
int tableRow;
|
||||||
QString pixmapCacheKey;
|
QString pixmapCacheKey;
|
||||||
|
@ -109,7 +110,8 @@ public:
|
||||||
const SetList &_sets = SetList(),
|
const SetList &_sets = SetList(),
|
||||||
const QStringMap &_customPicURLs = QStringMap(),
|
const QStringMap &_customPicURLs = QStringMap(),
|
||||||
MuidMap muids = MuidMap(),
|
MuidMap muids = MuidMap(),
|
||||||
QStringMap _setNumbers = QStringMap()
|
QStringMap _setNumbers = QStringMap(),
|
||||||
|
QStringMap _rarities = QStringMap()
|
||||||
);
|
);
|
||||||
~CardInfo();
|
~CardInfo();
|
||||||
inline const QString &getName() const { return name; }
|
inline const QString &getName() const { return name; }
|
||||||
|
@ -142,6 +144,8 @@ public:
|
||||||
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
|
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
|
||||||
int getMuId(const QString &set) const { return muIds.value(set); }
|
int getMuId(const QString &set) const { return muIds.value(set); }
|
||||||
QString getSetNumber(const QString &set) const { return setNumbers.value(set); }
|
QString getSetNumber(const QString &set) const { return setNumbers.value(set); }
|
||||||
|
QString getRarity(const QString &set) const { return rarities.value(set); }
|
||||||
|
QStringMap getRarities() const { return rarities; }
|
||||||
QString getMainCardType() const;
|
QString getMainCardType() const;
|
||||||
QString getCorrectedName() const;
|
QString getCorrectedName() const;
|
||||||
int getTableRow() const { return tableRow; }
|
int getTableRow() const { return tableRow; }
|
||||||
|
@ -150,6 +154,7 @@ public:
|
||||||
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
|
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
|
||||||
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
|
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
|
||||||
void setSetNumber(const QString &_set, const QString &_setNumber) { setNumbers.insert(_set, _setNumber); }
|
void setSetNumber(const QString &_set, const QString &_setNumber) { setNumbers.insert(_set, _setNumber); }
|
||||||
|
void setRarity(const QString &_set, const QString &_setNumber) { rarities.insert(_set, _setNumber); }
|
||||||
void addToSet(CardSet *set);
|
void addToSet(CardSet *set);
|
||||||
void emitPixmapUpdated() { emit pixmapUpdated(); }
|
void emitPixmapUpdated() { emit pixmapUpdated(); }
|
||||||
void refreshCachedSetNames();
|
void refreshCachedSetNames();
|
||||||
|
|
|
@ -33,6 +33,8 @@ const char *CardFilter::attrName(Attr a)
|
||||||
return "mana cost";
|
return "mana cost";
|
||||||
case AttrCmc:
|
case AttrCmc:
|
||||||
return "cmc";
|
return "cmc";
|
||||||
|
case AttrRarity:
|
||||||
|
return "rarity";
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
AttrSet,
|
AttrSet,
|
||||||
AttrManaCost,
|
AttrManaCost,
|
||||||
AttrCmc,
|
AttrCmc,
|
||||||
|
AttrRarity,
|
||||||
AttrEnd
|
AttrEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,17 @@ bool FilterItem::acceptCmc(const CardInfo *info) const
|
||||||
return (info->getCmc() == term);
|
return (info->getCmc() == term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FilterItem::acceptRarity(const CardInfo *info) const
|
||||||
|
{
|
||||||
|
foreach (QString rareLevel, info->getRarities())
|
||||||
|
{
|
||||||
|
if (rareLevel.compare(term, Qt::CaseInsensitive) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool FilterItem::acceptCardAttr(const CardInfo *info, CardFilter::Attr attr) const
|
bool FilterItem::acceptCardAttr(const CardInfo *info, CardFilter::Attr attr) const
|
||||||
{
|
{
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
|
@ -241,6 +252,8 @@ bool FilterItem::acceptCardAttr(const CardInfo *info, CardFilter::Attr attr) con
|
||||||
return acceptManaCost(info);
|
return acceptManaCost(info);
|
||||||
case CardFilter::AttrCmc:
|
case CardFilter::AttrCmc:
|
||||||
return acceptCmc(info);
|
return acceptCmc(info);
|
||||||
|
case CardFilter::AttrRarity:
|
||||||
|
return acceptRarity(info);
|
||||||
default:
|
default:
|
||||||
return true; /* ignore this attribute */
|
return true; /* ignore this attribute */
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
bool acceptSet(const CardInfo *info) const;
|
bool acceptSet(const CardInfo *info) const;
|
||||||
bool acceptManaCost(const CardInfo *info) const;
|
bool acceptManaCost(const CardInfo *info) const;
|
||||||
bool acceptCmc(const CardInfo *info) const;
|
bool acceptCmc(const CardInfo *info) const;
|
||||||
|
bool acceptRarity(const CardInfo *info) const;
|
||||||
bool acceptCardAttr(const CardInfo *info, CardFilter::Attr attr) const;
|
bool acceptCardAttr(const CardInfo *info, CardFilter::Attr attr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,8 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
const QStringList & colors,
|
const QStringList & colors,
|
||||||
const QStringList & relatedCards,
|
const QStringList & relatedCards,
|
||||||
const QStringList & reverseRelatedCards,
|
const QStringList & reverseRelatedCards,
|
||||||
bool upsideDown
|
bool upsideDown,
|
||||||
|
QString &rarity
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
QStringList cardTextRows = cardText.split("\n");
|
QStringList cardTextRows = cardText.split("\n");
|
||||||
|
@ -109,6 +110,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
}
|
}
|
||||||
card->setMuId(setName, cardId);
|
card->setMuId(setName, cardId);
|
||||||
card->setSetNumber(setName, setNumber);
|
card->setSetNumber(setName, setNumber);
|
||||||
|
card->setRarity(setName, rarity);
|
||||||
|
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
@ -149,6 +151,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
QStringList reverseRelatedCards; // dummy
|
QStringList reverseRelatedCards; // dummy
|
||||||
int cardId;
|
int cardId;
|
||||||
QString setNumber;
|
QString setNumber;
|
||||||
|
QString rarity;
|
||||||
int cardLoyalty;
|
int cardLoyalty;
|
||||||
bool upsideDown = false;
|
bool upsideDown = false;
|
||||||
QMap<int, QVariantMap> splitCards;
|
QMap<int, QVariantMap> splitCards;
|
||||||
|
@ -180,6 +183,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
cardText = map.contains("text") ? map.value("text").toString() : QString("");
|
cardText = map.contains("text") ? map.value("text").toString() : QString("");
|
||||||
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
|
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
|
||||||
setNumber = map.contains("number") ? map.value("number").toString() : QString("");
|
setNumber = map.contains("number") ? map.value("number").toString() : QString("");
|
||||||
|
rarity = map.contains("rarity") ? map.value("rarity").toString() : QString("");
|
||||||
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
|
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
|
||||||
relatedCards = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
relatedCards = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
||||||
relatedCards.removeAll(cardName);
|
relatedCards.removeAll(cardName);
|
||||||
|
@ -195,7 +199,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
colors.clear();
|
colors.clear();
|
||||||
extractColors(map.value("colors").toStringList(), colors);
|
extractColors(map.value("colors").toStringList(), colors);
|
||||||
|
|
||||||
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown);
|
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, rarity);
|
||||||
|
|
||||||
if (!set->contains(card)) {
|
if (!set->contains(card)) {
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
@ -229,6 +233,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
cardPT = "";
|
cardPT = "";
|
||||||
cardText = "";
|
cardText = "";
|
||||||
setNumber = "";
|
setNumber = "";
|
||||||
|
rarity = "";
|
||||||
colors.clear();
|
colors.clear();
|
||||||
// this is currently an integer; can't accept 2 values
|
// this is currently an integer; can't accept 2 values
|
||||||
cardLoyalty = 0;
|
cardLoyalty = 0;
|
||||||
|
@ -289,7 +294,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
upsideDown = false;
|
upsideDown = false;
|
||||||
|
|
||||||
// add the card
|
// add the card
|
||||||
CardInfo *card = addCard(set->getShortName(), cardName, false, muid, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown);
|
CardInfo *card = addCard(set->getShortName(), cardName, false, muid, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown, rarity);
|
||||||
|
|
||||||
if (!set->contains(card)) {
|
if (!set->contains(card)) {
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
|
|
@ -45,7 +45,8 @@ private:
|
||||||
const QStringList & colors,
|
const QStringList & colors,
|
||||||
const QStringList & relatedCards,
|
const QStringList & relatedCards,
|
||||||
const QStringList & reverseRelatedCards,
|
const QStringList & reverseRelatedCards,
|
||||||
bool upsideDown
|
bool upsideDown,
|
||||||
|
QString &rarity
|
||||||
);
|
);
|
||||||
signals:
|
signals:
|
||||||
void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
|
void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
|
||||||
|
|
Loading…
Reference in a new issue