Fix for capital offense (UST)

This commit is contained in:
spjspj 2017-12-23 11:25:53 +11:00
parent 43fe80313f
commit b569f89559

View file

@ -27,16 +27,19 @@
*/
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()) {
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();
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 -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.)";
}
}