mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 06:43:54 -07:00
Extend decklist parsing (#5316)
* Extend the decklist parsing from clipboard to also support SetName, CollectorNumber and Foil Status. * Q_UNUSED foil for now but keep parsing logic for future PR's/compatibility. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
cc16b8779c
commit
81b85e97df
11 changed files with 140 additions and 28 deletions
|
|
@ -176,6 +176,42 @@ QString DeckLoader::exportDeckToDecklist()
|
|||
return deckString;
|
||||
}
|
||||
|
||||
// This struct is here to support the forEachCard function call, defined in decklist.
|
||||
// It requires a function to be called for each card, and it will set the providerId.
|
||||
struct SetProviderId
|
||||
{
|
||||
// Main operator for struct, allowing the foreachcard to work.
|
||||
SetProviderId()
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const InnerDecklistNode *node, DecklistCardNode *card) const
|
||||
{
|
||||
Q_UNUSED(node);
|
||||
// Retrieve the providerId based on setName and collectorNumber
|
||||
QString providerId =
|
||||
CardDatabaseManager::getInstance()
|
||||
->getSpecificSetForCard(card->getName(), card->getCardSetShortName(), card->getCardCollectorNumber())
|
||||
.getProperty("uuid");
|
||||
|
||||
// Set the providerId on the card
|
||||
card->setCardProviderId(providerId);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function iterates through each card in the decklist and sets the providerId
|
||||
* on each card based on its set name and collector number.
|
||||
*/
|
||||
void DeckLoader::resolveSetNameAndNumberToProviderID()
|
||||
{
|
||||
// Set up the struct to call.
|
||||
SetProviderId setProviderId;
|
||||
|
||||
// Call the forEachCard method for each card in the deck
|
||||
forEachCard(setProviderId);
|
||||
}
|
||||
|
||||
DeckLoader::FileFormat DeckLoader::getFormatFromName(const QString &fileName)
|
||||
{
|
||||
if (fileName.endsWith(".cod", Qt::CaseInsensitive)) {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ public:
|
|||
bool saveToFile(const QString &fileName, FileFormat fmt);
|
||||
QString exportDeckToDecklist();
|
||||
|
||||
void resolveSetNameAndNumberToProviderID();
|
||||
|
||||
// overload
|
||||
bool saveToStream_Plain(QTextStream &out, bool addComments = true);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ struct CopyIfNotAToken
|
|||
}
|
||||
};
|
||||
|
||||
void DeckStatsInterface::copyDeckWithoutTokens(const DeckList &source, DeckList &destination)
|
||||
void DeckStatsInterface::copyDeckWithoutTokens(DeckList &source, DeckList &destination)
|
||||
{
|
||||
CopyIfNotAToken copyIfNotAToken(cardDatabase, destination);
|
||||
source.forEachCard(copyIfNotAToken);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ private:
|
|||
* closest non-token card instead. So we construct a new deck which has no
|
||||
* tokens.
|
||||
*/
|
||||
void copyDeckWithoutTokens(const DeckList &source, DeckList &destination);
|
||||
void copyDeckWithoutTokens(DeckList &source, DeckList &destination);
|
||||
|
||||
private slots:
|
||||
void queryFinished(QNetworkReply *reply);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue