diff --git a/Mage.Sets/src/mage/sets/alarareborn/Brainbite.java b/Mage.Sets/src/mage/sets/alarareborn/Brainbite.java index 045b9d5b52..44f9179972 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/Brainbite.java +++ b/Mage.Sets/src/mage/sets/alarareborn/Brainbite.java @@ -28,20 +28,11 @@ package mage.sets.alarareborn; import java.util.UUID; - +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetOpponentEffect; +import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.DrawCardControllerEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; -import mage.target.TargetCard; import mage.target.common.TargetOpponent; /** @@ -58,7 +49,7 @@ public class Brainbite extends CardImpl { this.color.setBlack(true); // Target opponent reveals his or her hand. You choose a card from it. That player discards that card. - this.getSpellAbility().addEffect(new BrainbiteEffect()); + this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetOpponentEffect()); // Draw a card. this.getSpellAbility().addEffect(new DrawCardControllerEffect(1)); this.getSpellAbility().addTarget(new TargetOpponent()); @@ -73,41 +64,3 @@ public class Brainbite extends CardImpl { return new Brainbite(this); } } - -class BrainbiteEffect extends OneShotEffect { - - public BrainbiteEffect() { - super(Outcome.Discard); - staticText = "Target opponent reveals his or her hand. You choose a card from it. That player discards that card"; - } - - public BrainbiteEffect(final BrainbiteEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - player.revealCards("Brainbite", player.getHand(), game); - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { - TargetCard target = new TargetCard(Zone.PICK, new FilterCard()); - target.setRequired(true); - if (you.choose(Outcome.Benefit, player.getHand(), target, game)) { - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - return player.discard(card, source, game); - } - } - } - } - return false; - } - - @Override - public BrainbiteEffect copy() { - return new BrainbiteEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/magic2010/Duress.java b/Mage.Sets/src/mage/sets/magic2010/Duress.java index 8a9f76a241..97ad353a8f 100644 --- a/Mage.Sets/src/mage/sets/magic2010/Duress.java +++ b/Mage.Sets/src/mage/sets/magic2010/Duress.java @@ -29,20 +29,13 @@ package mage.sets.magic2010; 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.cards.Card; +import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetOpponentEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; -import mage.game.Game; -import mage.players.Player; -import mage.target.TargetCard; import mage.target.common.TargetOpponent; /** @@ -51,12 +44,20 @@ import mage.target.common.TargetOpponent; */ public class Duress extends CardImpl { + private static final FilterCard filter = new FilterCard("a noncreature, nonland card"); + static { + filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); + filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); + } + public Duress(UUID ownerId){ super(ownerId, 96, "Duress", Rarity.COMMON, new CardType[]{CardType.SORCERY},"{B}"); this.expansionSetCode = "M10"; this.color.setBlack(true); + + // Target opponent reveals his or her hand. You choose a noncreature, nonland card from it. That player discards that card. this.getSpellAbility().addTarget(new TargetOpponent()); - this.getSpellAbility().addEffect(new DuressEffect()); + this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetOpponentEffect(filter)); } public Duress(final Duress card) { @@ -68,48 +69,3 @@ public class Duress extends CardImpl { return new Duress(this); } } - -class DuressEffect extends OneShotEffect { - - private static final FilterCard filter = new FilterCard("noncreature, nonland card"); - - static { - filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); - filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); - } - - public DuressEffect() { - super(Outcome.Discard); - staticText = "Target opponent reveals his or her hand. You choose a noncreature, nonland card from it. That player discards that card"; - } - - public DuressEffect(final DuressEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - player.revealCards("Duress", player.getHand(), game); - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { - TargetCard target = new TargetCard(Zone.PICK, filter); - target.setRequired(true); - if (you.choose(Outcome.Benefit, player.getHand(), target, game)) { - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - return player.discard(card, source, game); - } - } - } - } - return false; - } - - @Override - public DuressEffect copy() { - return new DuressEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/newphyrexia/Despise.java b/Mage.Sets/src/mage/sets/newphyrexia/Despise.java index 7f1eac1369..a52a255f0f 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/Despise.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/Despise.java @@ -33,6 +33,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetOpponentEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.Outcome; @@ -51,6 +52,13 @@ import mage.target.common.TargetOpponent; */ public class Despise extends CardImpl { + private static final FilterCard filter = new FilterCard("a creature or planeswalker card"); + static { + filter.add(Predicates.or( + new CardTypePredicate(CardType.CREATURE), + new CardTypePredicate(CardType.PLANESWALKER))); + } + public Despise(UUID ownerId) { super(ownerId, 56, "Despise", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{B}"); this.expansionSetCode = "NPH"; @@ -59,7 +67,7 @@ public class Despise extends CardImpl { // Target opponent reveals his or her hand. You choose a creature or planeswalker card from it. That player discards that card. this.getSpellAbility().addTarget(new TargetOpponent()); - this.getSpellAbility().addEffect(new DespiseEffect()); + this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetOpponentEffect(filter)); } public Despise(final Despise card) { @@ -71,49 +79,3 @@ public class Despise extends CardImpl { return new Despise(this); } } - -class DespiseEffect extends OneShotEffect { - - private static final FilterCard filter = new FilterCard("creature or planeswalker card"); - - static { - filter.add(Predicates.or( - new CardTypePredicate(CardType.CREATURE), - new CardTypePredicate(CardType.PLANESWALKER))); - } - - public DespiseEffect() { - super(Outcome.Discard); - staticText = "Target opponent reveals his or her hand. You choose a creature or planeswalker card from it. That player discards that card"; - } - - public DespiseEffect(final DespiseEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - player.revealCards("Despise", player.getHand(), game); - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { - TargetCard target = new TargetCard(Zone.PICK, filter); - target.setRequired(true); - if (you.choose(Outcome.Benefit, player.getHand(), target, game)) { - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - return player.discard(card, source, game); - } - } - } - } - return false; - } - - @Override - public DespiseEffect copy() { - return new DespiseEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/Ostracize.java b/Mage.Sets/src/mage/sets/urzaslegacy/Ostracize.java index 490e39f662..e69d051360 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/Ostracize.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/Ostracize.java @@ -28,18 +28,11 @@ package mage.sets.urzaslegacy; 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.cards.Card; +import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetOpponentEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterCreatureCard; -import mage.game.Game; -import mage.players.Player; -import mage.target.TargetCard; import mage.target.common.TargetOpponent; /** @@ -56,7 +49,7 @@ public class Ostracize extends CardImpl { // Target opponent reveals his or her hand. You choose a creature card from it. That player discards that card. this.getSpellAbility().addTarget(new TargetOpponent()); - this.getSpellAbility().addEffect(new OstracizeEffect()); + this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetOpponentEffect(new FilterCreatureCard("a creature card"))); } public Ostracize(final Ostracize card) { @@ -68,39 +61,3 @@ public class Ostracize extends CardImpl { return new Ostracize(this); } } - -class OstracizeEffect extends OneShotEffect { - - public OstracizeEffect() { - super(Outcome.Discard); - staticText = "Target opponent reveals his or her hand. You choose a creature card from it. That player discards that card"; - } - - public OstracizeEffect(final OstracizeEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - player.revealCards("Ostracize", player.getHand(), game); - - Player you = game.getPlayer(source.getControllerId()); - TargetCard target = new TargetCard(Zone.PICK, new FilterCreatureCard()); - target.setRequired(true); - if (you != null && you.choose(Outcome.Benefit, player.getHand(), target, game)) { - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - return player.discard(card, source, game); - } - } - } - return false; - } - - @Override - public OstracizeEffect copy() { - return new OstracizeEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/visions/Coercion.java b/Mage.Sets/src/mage/sets/visions/Coercion.java index 4045327711..12763d89f1 100644 --- a/Mage.Sets/src/mage/sets/visions/Coercion.java +++ b/Mage.Sets/src/mage/sets/visions/Coercion.java @@ -28,18 +28,10 @@ package mage.sets.visions; 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.cards.Card; +import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetOpponentEffect; import mage.cards.CardImpl; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; -import mage.target.TargetCard; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.target.common.TargetOpponent; /** @@ -56,7 +48,7 @@ public class Coercion extends CardImpl { // Target opponent reveals his or her hand. You choose a card from it. That player discards that card. this.getSpellAbility().addTarget(new TargetOpponent()); - this.getSpellAbility().addEffect(new CoercionEffect()); + this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetOpponentEffect()); } public Coercion(final Coercion card) { @@ -68,42 +60,3 @@ public class Coercion extends CardImpl { return new Coercion(this); } } - -class CoercionEffect extends OneShotEffect { - - - public CoercionEffect() { - super(Outcome.Discard); - staticText = "Target opponent reveals his or her hand. You choose a card from it. That player discards that card"; - } - - public CoercionEffect(final CoercionEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - player.revealCards("Coercion", player.getHand(), game); - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { - TargetCard target = new TargetCard(Zone.PICK, new FilterCard()); - target.setRequired(true); - if (you.choose(Outcome.Benefit, player.getHand(), target, game)) { - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - return player.discard(card, source, game); - } - } - } - } - return false; - } - - @Override - public CoercionEffect copy() { - return new CoercionEffect(this); - } - -} \ No newline at end of file diff --git a/Mage/src/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetOpponentEffect.java b/Mage/src/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetOpponentEffect.java index 46666ab4bc..9e4c1bbd06 100644 --- a/Mage/src/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetOpponentEffect.java +++ b/Mage/src/mage/abilities/effects/common/discard/DiscardCardYouChooseTargetOpponentEffect.java @@ -43,13 +43,22 @@ import mage.target.TargetCard; */ public class DiscardCardYouChooseTargetOpponentEffect extends OneShotEffect { + private FilterCard filter; + public DiscardCardYouChooseTargetOpponentEffect() { + this(new FilterCard("a card")); + } + + public DiscardCardYouChooseTargetOpponentEffect(FilterCard filter) { super(Outcome.Discard); - staticText = "Target opponent reveals his or her hand. You choose a card from it. That player discards that card"; + staticText = new StringBuilder("Target opponent reveals his or her hand. You choose ") + .append(filter.getMessage()).append(" from it. That player discards that card").toString(); + this.filter = filter; } public DiscardCardYouChooseTargetOpponentEffect(final DiscardCardYouChooseTargetOpponentEffect effect) { super(effect); + this.filter = effect.filter; } @Override @@ -59,7 +68,7 @@ public class DiscardCardYouChooseTargetOpponentEffect extends OneShotEffect