Kill a few DamageTargetControllerEffect implementations

This commit is contained in:
LoneFox 2015-10-12 22:19:13 +03:00
parent 05aba24b9a
commit 0d634ebf09
6 changed files with 47 additions and 256 deletions

View file

@ -28,24 +28,21 @@
package mage.sets.riseoftheeldrazi;
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.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
@ -70,10 +67,12 @@ public class GrotagSiegeRunner extends CardImpl {
this.toughness = new MageInt(1);
// {R}, Sacrifice Grotag Siege-Runner: Destroy target creature with defender. Grotag Siege-Runner deals 2 damage to that creature's controller.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{R}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{R}"));
ability.addCost(new SacrificeSourceCost());
Effect effect = new DamageTargetControllerEffect(2);
effect.setText("{this} deals 2 damage to that creature's controller");
ability.addEffect(effect);
ability.addTarget(new TargetCreaturePermanent(filter));
ability.addEffect(new GrotageSiegeRunnerEffect());
this.addAbility(ability);
}
@ -86,31 +85,3 @@ public class GrotagSiegeRunner extends CardImpl {
return new GrotagSiegeRunner(this);
}
}
class GrotageSiegeRunnerEffect extends OneShotEffect {
public GrotageSiegeRunnerEffect() {
super(Outcome.Damage);
this.staticText = "{this} deals 2 damage to that creature's controller";
}
public GrotageSiegeRunnerEffect(final GrotageSiegeRunnerEffect effect) {
super(effect);
}
@Override
public GrotageSiegeRunnerEffect copy() {
return new GrotageSiegeRunnerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
controller.damage(2, source.getSourceId(), game, false, true);
return true;
}
return false;
}
}

View file

@ -29,18 +29,12 @@
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.target.common.TargetLandPermanent;
/**
@ -53,8 +47,11 @@ public class MeltTerrain extends CardImpl {
super(ownerId, 97, "Melt Terrain", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{2}{R}{R}");
this.expansionSetCode = "SOM";
// Destroy target land. Melt Terrain deals 2 damage to that land's controller.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new MeltTerrainEffect());
Effect effect = new DamageTargetControllerEffect(2);
effect.setText("{this} deals 2 damage to that land's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetLandPermanent());
}
@ -66,37 +63,4 @@ public class MeltTerrain extends CardImpl {
public MeltTerrain copy() {
return new MeltTerrain(this);
}
}
class MeltTerrainEffect extends OneShotEffect {
MeltTerrainEffect() {
super(Outcome.Damage);
staticText = "{this} deals 2 damage to that land's controller";
}
MeltTerrainEffect(final MeltTerrainEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent p = game.getBattlefield().getPermanent(source.getFirstTarget());
if (p == null) {
p = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
if (p != null) {
Player player = game.getPlayer(p.getControllerId());
if (player != null) {
player.damage(2, source.getSourceId(), game, false, true);
}
}
return false;
}
@Override
public MeltTerrainEffect copy() {
return new MeltTerrainEffect(this);
}
}

View file

@ -28,15 +28,12 @@
package mage.sets.shadowmoor;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetLandPermanent;
/**
@ -50,7 +47,10 @@ public class PoisonTheWell extends CardImpl {
this.expansionSetCode = "SHM";
// Destroy target land. Poison the Well deals 2 damage to that land's controller.
this.getSpellAbility().addEffect(new PoisonTheWellEffect());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
Effect effect = new DamageTargetControllerEffect(2);
effect.setText("{this} deals 2 damage to that land's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetLandPermanent());
}
@ -63,34 +63,3 @@ public class PoisonTheWell extends CardImpl {
return new PoisonTheWell(this);
}
}
class PoisonTheWellEffect extends OneShotEffect {
public PoisonTheWellEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "Destroy target land. {this} deals 2 damage to that land's controller";
}
public PoisonTheWellEffect(final PoisonTheWellEffect effect) {
super(effect);
}
@Override
public PoisonTheWellEffect copy() {
return new PoisonTheWellEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent targetedLand = game.getPermanent(source.getFirstTarget());
if (targetedLand != null) {
targetedLand.destroy(source.getSourceId(), game, true);
Player controller = game.getPlayer(targetedLand.getControllerId());
if (controller != null) {
controller.damage(2, source.getSourceId(), game, false, true);
}
return true;
}
return false;
}
}

View file

@ -28,17 +28,12 @@
package mage.sets.shadowmoor;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.target.common.TargetArtifactPermanent;
/**
@ -52,9 +47,11 @@ public class SmashToSmithereens extends CardImpl {
this.expansionSetCode = "SHM";
// Destroy target artifact. Smash to Smithereens deals 3 damage to that artifact's controller.
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new SmashToSmithereensEffect());
Effect effect = new DamageTargetControllerEffect(3);
effect.setText("{this} deals 3 damage to that artifact's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
}
public SmashToSmithereens(final SmashToSmithereens card) {
@ -66,35 +63,3 @@ public class SmashToSmithereens extends CardImpl {
return new SmashToSmithereens(this);
}
}
class SmashToSmithereensEffect extends OneShotEffect {
SmashToSmithereensEffect() {
super(Outcome.Damage);
staticText = "{this} deals 3 damage to that artifact's controller";
}
SmashToSmithereensEffect(final SmashToSmithereensEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getFirstTarget());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
player.damage(3, source.getSourceId(), game, false, true);
}
}
return false;
}
@Override
public SmashToSmithereensEffect copy() {
return new SmashToSmithereensEffect(this);
}
}

View file

@ -28,23 +28,15 @@
package mage.sets.tenthedition;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetLandPermanent;
/**
@ -54,20 +46,20 @@ import mage.target.common.TargetLandPermanent;
public class Cryoclasm extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent("Plains or Island");
static {
filter.add(Predicates.or(
new SubtypePredicate("Plains"),
new SubtypePredicate("Island")));
filter.add(Predicates.or(new SubtypePredicate("Plains"), new SubtypePredicate("Island")));
}
public Cryoclasm(UUID ownerId) {
super(ownerId, 195, "Cryoclasm", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{R}");
this.expansionSetCode = "10E";
// Destroy target Plains or Island. Cryoclasm deals 3 damage to that land's controller.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new CryoclasmEffect());
Effect effect = new DamageTargetControllerEffect(3);
effect.setText("{this} deals 3 damage to that land's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetLandPermanent(filter));
}
@ -81,36 +73,3 @@ public class Cryoclasm extends CardImpl {
return new Cryoclasm(this);
}
}
class CryoclasmEffect extends OneShotEffect {
public CryoclasmEffect() {
super(Outcome.Damage);
this.staticText = "{this} deals 3 damage to that land's controller";
}
public CryoclasmEffect(final CryoclasmEffect effect) {
super(effect);
}
@Override
public CryoclasmEffect copy() {
return new CryoclasmEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
UUID targetId = getTargetPointer().getFirst(game, source);
if (targetId != null) {
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
if (controller != null) {
controller.damage(3, source.getSourceId(), game, false, false);
return true;
}
}
}
return false;
}
}

View file

@ -28,19 +28,14 @@
package mage.sets.theros;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetControllerEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetLandPermanent;
/**
@ -50,20 +45,21 @@ import mage.target.common.TargetLandPermanent;
public class PeakEruption extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent("Mountain");
static{
filter.add(new SubtypePredicate(("Mountain")));
}
public PeakEruption(UUID ownerId) {
super(ownerId, 132, "Peak Eruption", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{R}");
this.expansionSetCode = "THS";
// Destroy target Mountain. Peak Eruption deals 3 damage to that land's controller.
this.getSpellAbility().addTarget(new TargetLandPermanent(filter));
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new PeakEruptionEffect());
Effect effect = new DamageTargetControllerEffect(3);
effect.setText("{this} deals 3 damage to that land's controller");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetLandPermanent(filter));
}
public PeakEruption(final PeakEruption card) {
@ -75,36 +71,3 @@ public class PeakEruption extends CardImpl {
return new PeakEruption(this);
}
}
class PeakEruptionEffect extends OneShotEffect {
PeakEruptionEffect() {
super(Outcome.Damage);
staticText = "{this} deals 3 damage to that land's controller";
}
PeakEruptionEffect(final PeakEruptionEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getFirstTarget());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
player.damage(3, source.getSourceId(), game, false, true);
}
}
return false;
}
@Override
public PeakEruptionEffect copy() {
return new PeakEruptionEffect(this);
}
}