Fix for capital offense (UST)
*/
package mage.cards.c;
+import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
+import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
+import mage.cards.repository.CardInfo;
import mage.constants.CardType;
+import mage.cards.repository.CardRepository;
import mage.constants.Duration;
-import static mage.filter.predicate.permanent.ControllerControlsIslandPredicate.filter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
@@ -78,18 +81,25 @@ class NumberOfCapitalsInTextOfTargetCreatureCount implements DynamicValue {
Permanent permanent = game.getPermanent(sourceAbility.getTargets().get(0).getFirstTarget());
if (permanent != null) {
int capitals = 0;
- for (String line : permanent.getRules()) {
+ List<CardInfo> cards = CardRepository.instance.findCards(permanent.getName());
+
+ if (cards != null) {
+ for (CardInfo cardInfo : cards) {
+ Card dummy = cardInfo != null ? cardInfo.getCard() : null;
+ for (String line : dummy.getRules()) {
line = line.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
line = line.replaceAll("\\{this\\}", permanent.getName());
capitals += line.length() - line.replaceAll("[A-Z]", "").length();
}
return -1 * capitals;
}
+ }
+ }
return 0;
}
@Override
public String getMessage() {
- return filter.getMessage() + " that player controls";
+ return "target creature gets -x/-x until end of turn, where x is the number of times a capital letter appears in its rules text. (ignore reminder text and flavor text.)";
}
}
