From c04e2a444b63c66df089fb3214ac0871caa4a946 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Tue, 11 Mar 2025 20:03:08 -0700 Subject: [PATCH] refactor --- oracle/src/oracleimporter.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 07aad804d..518d42967 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -107,6 +107,19 @@ QString OracleImporter::getMainCardType(const QStringList &typeList) return typeList.first(); } +/** + * Parses the card text to determine if the card enters the battlefield tapped. + * + * @param name The name of the card + * @param text The full oracle text of the card + */ +static bool parseCipt(const QString &name, const QString &text) +{ + QRegularExpression ciptRegex("( it|" + QRegularExpression::escape(name) + + ") enters( the battlefield)? tapped(?! unless)"); + return ciptRegex.match(text).hasMatch(); +} + CardInfoPtr OracleImporter::addCard(QString name, QString text, bool isToken, @@ -157,9 +170,7 @@ CardInfoPtr OracleImporter::addCard(QString name, // DETECT CARD POSITIONING INFO // cards that enter the field tapped - QRegularExpression ciptRegex("( it|" + QRegularExpression::escape(name) + - ") enters( the battlefield)? tapped(?! unless)"); - bool cipt = ciptRegex.match(text).hasMatch(); + bool cipt = parseCipt(name, text); bool landscapeOrientation = properties.value("maintype").toString() == "Battle" || properties.value("layout").toString() == "split" ||