simplify auras copied from Burrowing

don't need a custom effect to add landwalk
This commit is contained in:
Neil Gentleman 2016-10-15 17:44:46 -07:00
parent 9e24bff19f
commit 115b6b88f4
6 changed files with 37 additions and 237 deletions

View file

@ -30,20 +30,16 @@ package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.MountainwalkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -60,13 +56,15 @@ public class Burrowing extends CardImpl {
// Enchant creature
// Enchanted creature has mountainwalk.
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BurrowingEffect()));
// Enchanted creature has mountainwalk.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAttachedEffect(new MountainwalkAbility(), AttachmentType.AURA)));
}
public Burrowing(final Burrowing card) {
@ -77,51 +75,4 @@ public class Burrowing extends CardImpl {
public Burrowing copy() {
return new Burrowing(this);
}
}
class BurrowingEffect extends ContinuousEffectImpl {
public BurrowingEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature);
staticText = "Enchanted creature has mountainwalk";
}
public BurrowingEffect(final BurrowingEffect effect) {
super(effect);
}
@Override
public BurrowingEffect copy() {
return new BurrowingEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
creature.addAbility(new MountainwalkAbility(), game);
}
break;
}
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6;
}
}

View file

@ -31,20 +31,16 @@ package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.ForestwalkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -61,11 +57,13 @@ public class DryadsFavor extends CardImpl {
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit));
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Enchanted creature has forestwalk.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DryadsFavorEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAttachedEffect(new ForestwalkAbility(), AttachmentType.AURA)));
}
public DryadsFavor(final DryadsFavor card) {
@ -77,50 +75,3 @@ public class DryadsFavor extends CardImpl {
return new DryadsFavor(this);
}
}
class DryadsFavorEffect extends ContinuousEffectImpl {
public DryadsFavorEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Enchanted creature has forestwalk";
}
public DryadsFavorEffect(final DryadsFavorEffect effect) {
super(effect);
}
@Override
public DryadsFavorEffect copy() {
return new DryadsFavorEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
creature.addAbility(new ForestwalkAbility(), source.getSourceId(), game);
}
break;
}
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6;
}
}

View file

@ -38,7 +38,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.target.TargetPermanent;
@ -62,7 +61,7 @@ public class FishliverOil extends CardImpl {
// Enchanted creature has islandwalk.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAttachedEffect(new IslandwalkAbility(), AttachmentType.AURA, Duration.WhileOnBattlefield)));
new GainAbilityAttachedEffect(new IslandwalkAbility(), AttachmentType.AURA)));
}
public FishliverOil(final FishliverOil card) {

View file

@ -29,22 +29,20 @@ package mage.cards.g;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.Layer;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -59,12 +57,19 @@ public class GoblinWarPaint extends CardImpl {
this.subtype.add("Aura");
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GoblinWarPaintEffect()));
// Enchanted creature gets +2/+2 and has haste.
Effect effect = new GainAbilityAttachedEffect(HasteAbility.getInstance(), AttachmentType.AURA);
effect.setText("and has haste");
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, 2));
ability.addEffect(effect);
this.addAbility(ability);
}
public GoblinWarPaint(final GoblinWarPaint card) {
@ -76,56 +81,3 @@ public class GoblinWarPaint extends CardImpl {
return new GoblinWarPaint(this);
}
}
class GoblinWarPaintEffect extends ContinuousEffectImpl {
public GoblinWarPaintEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "Enchanted creature gets +2/+2 and has haste";
}
public GoblinWarPaintEffect(final GoblinWarPaintEffect effect) {
super(effect);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
switch (layer) {
case PTChangingEffects_7:
if (sublayer == SubLayer.ModifyPT_7c) {
creature.addPower(2);
creature.addToughness(2);
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
creature.addAbility(HasteAbility.getInstance(), game);
}
break;
}
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == layer.PTChangingEffects_7;
}
@Override
public GoblinWarPaintEffect copy() {
return new GoblinWarPaintEffect(this);
}
}

View file

@ -39,9 +39,6 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.AbilityAddingRemovingEffects_6;
import static mage.constants.Layer.ColorChangingEffects_5;
import static mage.constants.Layer.TypeChangingEffects_4;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;

View file

@ -30,20 +30,18 @@ package mage.cards.v;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.MountainwalkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -62,9 +60,14 @@ public class VolcanicStrength extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
// Enchanted creature gets +2/+2 and has mountainwalk.
this.addAbility(ability);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VolcanicStrengthEffect()));
// Enchanted creature gets +2/+2 and has mountainwalk.
Effect effect = new GainAbilityAttachedEffect(new MountainwalkAbility(), AttachmentType.AURA);
effect.setText("and has mountainwalk");
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, 2));
ability.addEffect(effect);
this.addAbility(ability);
}
public VolcanicStrength(final VolcanicStrength card) {
@ -76,56 +79,3 @@ public class VolcanicStrength extends CardImpl {
return new VolcanicStrength(this);
}
}
class VolcanicStrengthEffect extends ContinuousEffectImpl {
public VolcanicStrengthEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature);
staticText = "Enchanted creature gets +2/+2 and has mountainwalk";
}
public VolcanicStrengthEffect(final VolcanicStrengthEffect effect) {
super(effect);
}
@Override
public VolcanicStrengthEffect copy() {
return new VolcanicStrengthEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
switch (layer) {
case PTChangingEffects_7:
if (sublayer == SubLayer.ModifyPT_7c) {
creature.addPower(2);
creature.addToughness(2);
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
creature.addAbility(new MountainwalkAbility(), game);
}
break;
}
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.PTChangingEffects_7;
}
}