mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Combine card legalities in Oracle (#5370)
- Some printings have different legalities, which cause Oracle to bug out - Fix #4783
This commit is contained in:
parent
5e62069444
commit
32dd18998d
4 changed files with 19 additions and 0 deletions
|
|
@ -304,6 +304,17 @@ void CardInfo::addToSet(const CardSetPtr &_set, const CardInfoPerSet _info)
|
|||
refreshCachedSetNames();
|
||||
}
|
||||
|
||||
void CardInfo::combineLegalities(const QVariantHash &props)
|
||||
{
|
||||
QHashIterator<QString, QVariant> it(props);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.key().startsWith("format-")) {
|
||||
smartThis->setProperty(it.key(), it.value().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CardInfo::refreshCachedSetNames()
|
||||
{
|
||||
QStringList setList;
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@ public:
|
|||
}
|
||||
QString getCorrectedName() const;
|
||||
void addToSet(const CardSetPtr &_set, CardInfoPerSet _info = CardInfoPerSet());
|
||||
void combineLegalities(const QVariantHash &props);
|
||||
void emitPixmapUpdated()
|
||||
{
|
||||
emit pixmapUpdated();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ SplitCardPart::SplitCardPart(const QString &_name,
|
|||
{
|
||||
}
|
||||
|
||||
const QRegularExpression OracleImporter::formatRegex = QRegularExpression("^format-");
|
||||
|
||||
OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent) : CardDatabase(parent), dataDir(_dataDir)
|
||||
{
|
||||
}
|
||||
|
|
@ -118,6 +120,9 @@ CardInfoPtr OracleImporter::addCard(QString name,
|
|||
if (cards.contains(name)) {
|
||||
CardInfoPtr card = cards.value(name);
|
||||
card->addToSet(setInfo.getPtr(), setInfo);
|
||||
if (card->getProperties().filter(formatRegex).empty()) {
|
||||
card->combineLegalities(properties);
|
||||
}
|
||||
return card;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define ORACLEIMPORTER_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QRegularExpression>
|
||||
#include <QVariant>
|
||||
#include <game/cards/card_database.h>
|
||||
#include <utility>
|
||||
|
|
@ -122,6 +123,7 @@ class OracleImporter : public CardDatabase
|
|||
private:
|
||||
const QStringList mainCardTypes = {"Planeswalker", "Creature", "Land", "Sorcery",
|
||||
"Instant", "Artifact", "Enchantment"};
|
||||
static const QRegularExpression formatRegex;
|
||||
QList<SetToDownload> allSets;
|
||||
QVariantMap setsMap;
|
||||
QString dataDir;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue