diff --git a/Mage.Sets/src/mage/cards/c/CharmbreakerDevils.java b/Mage.Sets/src/mage/cards/c/CharmbreakerDevils.java index f281aacd2d..aece380a16 100644 --- a/Mage.Sets/src/mage/cards/c/CharmbreakerDevils.java +++ b/Mage.Sets/src/mage/cards/c/CharmbreakerDevils.java @@ -77,7 +77,7 @@ class CharmbreakerDevilsEffect extends OneShotEffect { TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY); target.setRandom(true); target.setNotTarget(true); - player.choose(outcome, target, source.getSourceId(), game); + player.chooseTarget(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); return card != null && player.moveCards(card, Zone.HAND, source, game); } diff --git a/Mage.Sets/src/mage/cards/c/CinderheartGiant.java b/Mage.Sets/src/mage/cards/c/CinderheartGiant.java index b9c8710b74..262149ea57 100644 --- a/Mage.Sets/src/mage/cards/c/CinderheartGiant.java +++ b/Mage.Sets/src/mage/cards/c/CinderheartGiant.java @@ -3,16 +3,19 @@ package mage.cards.c; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesSourceTriggeredAbility; -import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.TargetController; -import mage.filter.common.FilterCreaturePermanent; -import mage.target.Target; -import mage.target.common.TargetCreaturePermanent; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetOpponentsCreaturePermanent; import java.util.UUID; @@ -21,12 +24,6 @@ import java.util.UUID; */ public final class CinderheartGiant extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); - - static { - filter.add(TargetController.OPPONENT.getControllerPredicate()); - } - public CinderheartGiant(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{R}"); @@ -39,13 +36,7 @@ public final class CinderheartGiant extends CardImpl { this.addAbility(TrampleAbility.getInstance()); // When Cinderheart Giant dies, it deals 7 damage to a creature an opponent controls chosen at random. - Ability ability = new DiesSourceTriggeredAbility( - new DamageTargetEffect(7).setText("it deals 7 damage to a creature an opponent controls chosen at random")); - Target target = new TargetCreaturePermanent(1, 1, filter, true); - target.setRandom(true); - ability.addTarget(target); - - this.addAbility(ability); + this.addAbility(new DiesSourceTriggeredAbility(new CinderheartGiantEffect())); } private CinderheartGiant(final CinderheartGiant card) { @@ -57,3 +48,37 @@ public final class CinderheartGiant extends CardImpl { return new CinderheartGiant(this); } } + +class CinderheartGiantEffect extends OneShotEffect { + + CinderheartGiantEffect() { + super(Outcome.Benefit); + staticText = "it deals 7 damage to a creature an opponent controls chosen at random"; + } + + private CinderheartGiantEffect(final CinderheartGiantEffect effect) { + super(effect); + } + + @Override + public CinderheartGiantEffect copy() { + return new CinderheartGiantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || game.getBattlefield().count( + StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, + source.getSourceId(), source.getControllerId(), game + ) < 1) { + return false; + } + TargetPermanent target = new TargetOpponentsCreaturePermanent(); + target.setNotTarget(true); + target.setRandom(true); + player.chooseTarget(outcome, target, source, game); + Permanent permanent = game.getPermanent(target.getFirstTarget()); + return permanent != null && permanent.damage(7, source.getSourceId(), source, game) > 0; + } +} diff --git a/Mage.Sets/src/mage/cards/g/Ghoulraiser.java b/Mage.Sets/src/mage/cards/g/Ghoulraiser.java index 17612e53c9..b70c6b27b9 100644 --- a/Mage.Sets/src/mage/cards/g/Ghoulraiser.java +++ b/Mage.Sets/src/mage/cards/g/Ghoulraiser.java @@ -75,7 +75,7 @@ class GhoulraiserEffect extends OneShotEffect { TargetCard target = new TargetCardInYourGraveyard(filter); target.setNotTarget(true); target.setRandom(true); - player.choose(outcome, target, source.getSourceId(), game); + player.chooseTarget(outcome, target, source, game); return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/h/HauntedFengraf.java b/Mage.Sets/src/mage/cards/h/HauntedFengraf.java index bd39fd3c99..9ab1ed054a 100644 --- a/Mage.Sets/src/mage/cards/h/HauntedFengraf.java +++ b/Mage.Sets/src/mage/cards/h/HauntedFengraf.java @@ -73,7 +73,7 @@ class HauntedFengrafEffect extends OneShotEffect { TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE); target.setNotTarget(true); target.setRandom(true); - player.choose(outcome, target, source.getSourceId(), game); + player.chooseTarget(outcome, target, source, game); return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/m/MakeAWish.java b/Mage.Sets/src/mage/cards/m/MakeAWish.java index 1ecf1095d9..6ccc5a56dd 100644 --- a/Mage.Sets/src/mage/cards/m/MakeAWish.java +++ b/Mage.Sets/src/mage/cards/m/MakeAWish.java @@ -63,7 +63,7 @@ class MakeAWishEffect extends OneShotEffect { TargetCard target = new TargetCardInYourGraveyard(Math.min(player.getGraveyard().size(), 2), StaticFilters.FILTER_CARD); target.setNotTarget(true); target.setRandom(true); - player.choose(outcome, target, source.getSourceId(), game); + player.chooseTarget(outcome, target, source, game); return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); } } diff --git a/Mage.Sets/src/mage/cards/s/ScabClanGiant.java b/Mage.Sets/src/mage/cards/s/ScabClanGiant.java index 73b5b2ef80..457a02c4a1 100644 --- a/Mage.Sets/src/mage/cards/s/ScabClanGiant.java +++ b/Mage.Sets/src/mage/cards/s/ScabClanGiant.java @@ -1,36 +1,34 @@ package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.FightTargetSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; import mage.constants.TargetController; import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.Target; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class ScabClanGiant extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); + static { filter.add(TargetController.OPPONENT.getControllerPredicate()); } public ScabClanGiant(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{G}"); this.subtype.add(SubType.GIANT); this.subtype.add(SubType.WARRIOR); @@ -38,7 +36,8 @@ public final class ScabClanGiant extends CardImpl { this.toughness = new MageInt(5); // When Scab-Clan Giant enters the battlefield, it fights target creature an opponent controls chosen at random. - Ability ability = new EntersBattlefieldTriggeredAbility(new ScabClanGiantEffect()); + Ability ability = new EntersBattlefieldTriggeredAbility(new FightTargetSourceEffect() + .setText("it fights target creature an opponent controls chosen at random")); Target target = new TargetCreaturePermanent(filter); target.setRandom(true); ability.addTarget(target); @@ -54,33 +53,3 @@ public final class ScabClanGiant extends CardImpl { return new ScabClanGiant(this); } } - -class ScabClanGiantEffect extends OneShotEffect { - - public ScabClanGiantEffect() { - super(Outcome.Damage); - this.staticText = "{this} fights target creature an opponent controls chosen at random"; - } - - public ScabClanGiantEffect(final ScabClanGiantEffect effect) { - super(effect); - } - - @Override - public ScabClanGiantEffect copy() { - return new ScabClanGiantEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent creature1 = game.getPermanent(source.getSourceId()); - Permanent creature2 = game.getPermanent(source.getFirstTarget()); - // 20110930 - 701.10 - if (creature1 != null && creature2 != null) { - if (creature1.isCreature() && creature2.isCreature()) { - return creature1.fight(creature2, source, game); - } - } - return false; - } -} \ No newline at end of file