Render and filter Continuum Universes Essence symbols instead of MTG mana

This commit is contained in:
Christian Daniel Jensen 2026-11-02 05:49:51 -07:00
parent dce9efcf81
commit 10d68be254

View file

@ -1,6 +1,7 @@
#include "mana_cost_widget.h"
#include "libcockatrice/card/card_info.h"
#include <libcockatrice/card/essence_types.h>
#include "mana_symbol_widget.h"
#include <QHBoxLayout>
@ -51,28 +52,7 @@ void ManaCostWidget::resizeEvent(QResizeEvent *event)
}
}
QStringList ManaCostWidget::parseManaCost(const QString &cmc)
QStringList ManaCostWidget::parseManaCost(const QString &essenceCost)
{
QStringList symbols;
// Handle split costs (e.g., "3U // 4UU")
QStringList splitCosts = cmc.split(" // ");
for (const QString &part : splitCosts) {
QRegularExpression regex(R"(\{([^}]+)\}|(\d+)|([WUBRGCSPX]))");
QRegularExpressionMatchIterator matches = regex.globalMatch(part);
while (matches.hasNext()) {
QRegularExpressionMatch match = matches.next();
if (match.captured(1).isEmpty()) { // If no `{}` group was captured, check other groups
if (!match.captured(2).isEmpty()) {
symbols.append(match.captured(2)); // Number match
} else {
symbols.append(match.captured(3)); // Single mana letter match
}
} else {
symbols.append(match.captured(1)); // `{}` enclosed match
}
}
}
return symbols;
return Essence::parseCost(essenceCost);
}