make the protected methods static

This commit is contained in:
RickyRister 2025-04-20 21:45:35 -07:00
parent 9f4c98d0f4
commit 0ebedb3bd8
2 changed files with 22 additions and 22 deletions

View file

@ -100,6 +100,27 @@ QString OracleImporter::getMainCardType(const QStringList &typeList)
return typeList.first();
}
/**
* Sorts and deduplicates the color chars in the string by WUBRG order.
*
* @param colors The string containing the color chars. Will be modified in-place
*/
static void sortAndReduceColors(QString &colors)
{
// sort
static const QHash<QChar, unsigned int> colorOrder{{'W', 0}, {'U', 1}, {'B', 2}, {'R', 3}, {'G', 4}};
std::sort(colors.begin(), colors.end(),
[](const QChar a, const QChar b) { return colorOrder.value(a, INT_MAX) < colorOrder.value(b, INT_MAX); });
// reduce
QChar lastChar = '\0';
for (int i = 0; i < colors.size(); ++i) {
if (colors.at(i) == lastChar)
colors.remove(i, 1);
else
lastChar = colors.at(i);
}
}
CardInfoPtr OracleImporter::addCard(QString name,
QString text,
bool isToken,
@ -189,7 +210,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
return newCard;
}
QString OracleImporter::getStringPropertyFromMap(const QVariantMap &card, const QString &propertyName)
static QString getStringPropertyFromMap(const QVariantMap &card, const QString &propertyName)
{
return card.contains(propertyName) ? card.value(propertyName).toString() : QString("");
}
@ -434,23 +455,6 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
return numCards;
}
void OracleImporter::sortAndReduceColors(QString &colors)
{
// sort
const QHash<QChar, unsigned int> colorOrder{{'W', 0}, {'U', 1}, {'B', 2}, {'R', 3}, {'G', 4}};
std::sort(colors.begin(), colors.end(), [&colorOrder](const QChar a, const QChar b) {
return colorOrder.value(a, INT_MAX) < colorOrder.value(b, INT_MAX);
});
// reduce
QChar lastChar = '\0';
for (int i = 0; i < colors.size(); ++i) {
if (colors.at(i) == lastChar)
colors.remove(i, 1);
else
lastChar = colors.at(i);
}
}
int OracleImporter::startImport()
{
int setCards = 0, setIndex = 0;

View file

@ -164,10 +164,6 @@ public:
return allSets;
}
void clear();
protected:
inline QString getStringPropertyFromMap(const QVariantMap &card, const QString &propertyName);
void sortAndReduceColors(QString &colors);
};
#endif