Some clean up with rule handling.

This commit is contained in:
LevelX2 2013-10-24 10:13:21 +02:00
parent 50e0a2c2a8
commit bd20994f25
3 changed files with 20 additions and 17 deletions

View file

@ -109,22 +109,24 @@ public abstract class TriggeredAbilityImpl<T extends TriggeredAbilityImpl<T>> ex
public String getRule() {
String superRule = super.getRule(true);
StringBuilder sb = new StringBuilder();
String ruleLow = superRule.toLowerCase();
if (optional && !ruleLow.startsWith("you ")) {
if (this.getTargets().isEmpty()
|| ruleLow.startsWith("exile")
|| ruleLow.startsWith("destroy")
|| ruleLow.startsWith("return")
|| ruleLow.startsWith("tap")
|| ruleLow.startsWith("untap")) {
sb.append("you may ");
} else {
sb.append("you may have ");
}
if (!superRule.isEmpty()) {
String ruleLow = superRule.toLowerCase();
if (optional && !ruleLow.startsWith("you ")) {
if (this.getTargets().isEmpty()
|| ruleLow.startsWith("exile")
|| ruleLow.startsWith("destroy")
|| ruleLow.startsWith("return")
|| ruleLow.startsWith("tap")
|| ruleLow.startsWith("untap")) {
sb.append("you may ");
} else {
sb.append("you may have ");
}
}
sb.append(superRule.substring(0, 1).toLowerCase());
sb.append(superRule.substring(1));
}
sb.append(superRule.substring(0, 1).toLowerCase());
sb.append(superRule.substring(1));
return sb.toString();
}

View file

@ -28,13 +28,14 @@
package mage.abilities.common;
import mage.constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
/**
* Is applied when the {@link Permanent} with this ability instance changes zones.
@ -81,7 +82,7 @@ public class ZoneChangeTriggeredAbility<T extends ZoneChangeTriggeredAbility<T>>
@Override
public String getRule() {
return rule + super.getRule();
return new StringBuilder(rule).append(super.getRule()).toString();
}
@Override

View file

@ -78,6 +78,6 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl<Conditiona
if (ruleText != null && !ruleText.isEmpty()) {
return ruleText;
}
return new StringBuilder(super.getRule()).append(" Activate this ability only if ").append(condition.toString()).append(".").toString();
return new StringBuilder(super.getRule()).append(" Activate this ability only ").append(condition.toString()).append(".").toString();
}
}