From bd20994f25bc88ad91e4165dbeef0322b2a1e71c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 24 Oct 2013 10:13:21 +0200 Subject: [PATCH] Some clean up with rule handling. --- .../mage/abilities/TriggeredAbilityImpl.java | 30 ++++++++++--------- .../common/ZoneChangeTriggeredAbility.java | 5 ++-- .../ConditionalActivatedAbility.java | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Mage/src/mage/abilities/TriggeredAbilityImpl.java b/Mage/src/mage/abilities/TriggeredAbilityImpl.java index 074a489817..e8fa2dcd65 100644 --- a/Mage/src/mage/abilities/TriggeredAbilityImpl.java +++ b/Mage/src/mage/abilities/TriggeredAbilityImpl.java @@ -109,22 +109,24 @@ public abstract class TriggeredAbilityImpl> 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(); } diff --git a/Mage/src/mage/abilities/common/ZoneChangeTriggeredAbility.java b/Mage/src/mage/abilities/common/ZoneChangeTriggeredAbility.java index 60d49c03a7..3d9993b985 100644 --- a/Mage/src/mage/abilities/common/ZoneChangeTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/ZoneChangeTriggeredAbility.java @@ -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> @Override public String getRule() { - return rule + super.getRule(); + return new StringBuilder(rule).append(super.getRule()).toString(); } @Override diff --git a/Mage/src/mage/abilities/decorator/ConditionalActivatedAbility.java b/Mage/src/mage/abilities/decorator/ConditionalActivatedAbility.java index 1fa66798fe..2a2115db56 100644 --- a/Mage/src/mage/abilities/decorator/ConditionalActivatedAbility.java +++ b/Mage/src/mage/abilities/decorator/ConditionalActivatedAbility.java @@ -78,6 +78,6 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl