mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 00:23:55 -07:00
Oracle: fetch release date and set type
and save them in cards.xml
This commit is contained in:
parent
a320af70da
commit
cb37073828
4 changed files with 31 additions and 11 deletions
|
|
@ -30,6 +30,8 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
|||
QString edition;
|
||||
QString editionLong;
|
||||
QVariant editionCards;
|
||||
QString setType;
|
||||
QDate releaseDate;
|
||||
bool import;
|
||||
|
||||
while (it.hasNext()) {
|
||||
|
|
@ -37,12 +39,14 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
|||
edition = map.value("code").toString();
|
||||
editionLong = map.value("name").toString();
|
||||
editionCards = map.value("cards");
|
||||
setType = map.value("type").toString();
|
||||
releaseDate = map.value("releaseDate").toDate();
|
||||
|
||||
// core and expansion sets are marked to be imported by default
|
||||
import = (0 == QString::compare(map.value("type").toString(), QString("core"), Qt::CaseInsensitive) ||
|
||||
0 == QString::compare(map.value("type").toString(), QString("expansion"), Qt::CaseInsensitive));
|
||||
import = (0 == QString::compare(setType, QString("core"), Qt::CaseInsensitive) ||
|
||||
0 == QString::compare(setType, QString("expansion"), Qt::CaseInsensitive));
|
||||
|
||||
newSetList.append(SetToDownload(edition, editionLong, editionCards, import));
|
||||
newSetList.append(SetToDownload(edition, editionLong, editionCards, import, setType, releaseDate));
|
||||
}
|
||||
|
||||
qSort(newSetList);
|
||||
|
|
@ -237,7 +241,7 @@ int OracleImporter::startImport()
|
|||
if(!curSet->getImport())
|
||||
continue;
|
||||
|
||||
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName());
|
||||
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
|
||||
if (!sets.contains(set->getShortName()))
|
||||
sets.insert(set->getShortName(), set);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,18 @@ private:
|
|||
QString shortName, longName;
|
||||
bool import;
|
||||
QVariant cards;
|
||||
QDate releaseDate;
|
||||
QString setType;
|
||||
public:
|
||||
const QString &getShortName() const { return shortName; }
|
||||
const QString &getLongName() const { return longName; }
|
||||
const QVariant &getCards() const { return cards; }
|
||||
const QString &getSetType() const { return setType; }
|
||||
const QDate &getReleaseDate() const { return releaseDate; }
|
||||
bool getImport() const { return import; }
|
||||
void setImport(bool _import) { import = _import; }
|
||||
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import)
|
||||
: shortName(_shortName), longName(_longName), import(_import), cards(_cards) { }
|
||||
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import, const QString &_setType = QString(), const QDate &_releaseDate = QDate())
|
||||
: shortName(_shortName), longName(_longName), import(_import), cards(_cards), setType(_setType), releaseDate(_releaseDate) { }
|
||||
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue