[refactoring] Fixed issues with EntersBattlefieldEffect

This commit is contained in:
North 2012-07-18 01:25:38 +03:00
parent 13e023ca7a
commit 3eac7cbd42
7 changed files with 22 additions and 19 deletions

View file

@ -33,8 +33,8 @@ import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
@ -64,7 +64,7 @@ public class EvilTwin extends CardImpl<EvilTwin> {
this.toughness = new MageInt(0);
// You may have Evil Twin enter the battlefield as a copy of any creature on the battlefield except it gains "{U}{B}, {T}: Destroy target creature with the same name as this creature.
Ability ability1 = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new CopyPermanentEffect()), "You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains {U}{B}, {T}: Destroy target creature with the same name as this creature");
Ability ability1 = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new CopyPermanentEffect(), "You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains {U}{B}, {T}: Destroy target creature with the same name as this creature"));
Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
ability2.addCost(new TapSourceCost());
ability2.addTarget(new TargetCreaturePermanent(new EvilTwinFilter()));

View file

@ -27,13 +27,15 @@
*/
package mage.sets.magic2012;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTargetTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
@ -46,8 +48,6 @@ import mage.target.Target;
import mage.target.TargetPermanent;
import mage.util.functions.ApplyToPermanent;
import java.util.UUID;
/**
*
* @author North
@ -65,7 +65,7 @@ public class PhantasmalImage extends CardImpl<PhantasmalImage> {
this.power = new MageInt(0);
this.toughness = new MageInt(0);
Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new PhantasmalImageCopyEffect(), abilityText));
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new PhantasmalImageCopyEffect(), abilityText));
this.addAbility(ability);
}

View file

@ -28,12 +28,14 @@
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -47,8 +49,6 @@ import mage.target.Target;
import mage.target.TargetPermanent;
import mage.util.functions.ApplyToPermanent;
import java.util.UUID;
/**
*
* @author Loki
@ -62,7 +62,7 @@ public class PhyrexianMetamorph extends CardImpl<PhyrexianMetamorph> {
this.color.setBlue(true);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new PhyrexianMetamorphEffect()), "You may have {this} enter the battlefield as a copy of any artifact or creature on the battlefield, except it's an artifact in addition to its other types");
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new PhyrexianMetamorphEffect(), "You may have {this} enter the battlefield as a copy of any artifact or creature on the battlefield, except it's an artifact in addition to its other types"));
this.addAbility(ability);
}

View file

@ -31,9 +31,10 @@ package mage.sets.tenth;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.cards.CardImpl;
@ -52,7 +53,7 @@ public class Clone extends CardImpl<Clone> {
this.power = new MageInt(0);
this.toughness = new MageInt(0);
Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new CopyPermanentEffect()), "You may have {this} enter the battlefield as a copy of any creature on the battlefield");
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new CopyPermanentEffect(), "You may have {this} enter the battlefield as a copy of any creature on the battlefield"));
this.addAbility(ability);
}

View file

@ -30,8 +30,9 @@ package mage.sets.tenth;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.cards.CardImpl;
@ -55,7 +56,7 @@ public class SculptingSteel extends CardImpl<SculptingSteel> {
this.expansionSetCode = "10E";
// You may have Sculpting Steel enter the battlefield as a copy of any artifact on the battlefield.
Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new CopyPermanentEffect(filter)), "You may have {this} enter the battlefield as a copy of any artifact on the battlefield");
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new CopyPermanentEffect(filter), "You may have {this} enter the battlefield as a copy of any artifact on the battlefield"));
this.addAbility(ability);
}

View file

@ -40,7 +40,7 @@ import mage.abilities.effects.EntersBattlefieldEffect;
public class EntersBattlefieldAbility extends StaticAbility<EntersBattlefieldAbility> {
public EntersBattlefieldAbility(Effect effect) {
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect, null));
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect));
}
public EntersBattlefieldAbility(Effect effect, String rule) {
@ -56,4 +56,8 @@ public class EntersBattlefieldAbility extends StaticAbility<EntersBattlefieldAbi
return new EntersBattlefieldAbility(this);
}
@Override
public String getRule() {
return "{this} enters the battlefield " + super.getRule();
}
}

View file

@ -109,10 +109,7 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlef
@Override
public String getText(Mode mode) {
if (text == null || text.length() == 0)
return "{this} enters the battlefield " + baseEffects.getText(mode);
else
return text;
return (text == null || text.isEmpty()) ? baseEffects.getText(mode) : text;
}
@Override