diff --git a/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java b/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java index c439ca1d412..57e913f07b4 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java +++ b/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java @@ -36,6 +36,7 @@ import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BecomesChosenNonWallCreatureTypeTargetEffect; import mage.abilities.effects.common.continuous.BecomesSubtypeTargetEffect; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; @@ -63,7 +64,7 @@ public class UnnaturalSelection extends CardImpl { this.expansionSetCode = "APC"; // {1}: Choose a creature type other than Wall. Target creature becomes that type until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new UnnaturalSelectionEffect(), new GenericManaCost(1)); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesChosenNonWallCreatureTypeTargetEffect(), new GenericManaCost(1)); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -76,54 +77,4 @@ public class UnnaturalSelection extends CardImpl { public UnnaturalSelection copy() { return new UnnaturalSelection(this); } -} - -class UnnaturalSelectionEffect extends OneShotEffect { - - public UnnaturalSelectionEffect() { - super(Outcome.BoostCreature); - staticText = "choose a creature type other than wall, target creature's type becomes that type until end of turn"; - } - - public UnnaturalSelectionEffect(final UnnaturalSelectionEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - String chosenType = ""; - if (player != null && permanent != null) { - Choice typeChoice = new ChoiceImpl(true); - typeChoice.setMessage("Choose creature type other than Wall"); - Set types = CardRepository.instance.getCreatureTypes(); - types.remove("Wall"); - typeChoice.setChoices(types); - while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { - if (!player.isInGame()) { - return false; - } - } - game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); - chosenType = typeChoice.getChoice(); - if (chosenType != null && !chosenType.isEmpty()) { - // ADD TYPE TO TARGET - ContinuousEffect effect = new BecomesSubtypeTargetEffect(Duration.EndOfTurn, chosenType); - effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); - game.addEffect(effect, source); - return true; - } - - } - return false; - } - - @Override - public Effect copy() { - return new UnnaturalSelectionEffect(this); - } - - - } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/onslaught/Imagecrafter.java b/Mage.Sets/src/mage/sets/onslaught/Imagecrafter.java index f21449b8b42..cb3db6bc1dd 100644 --- a/Mage.Sets/src/mage/sets/onslaught/Imagecrafter.java +++ b/Mage.Sets/src/mage/sets/onslaught/Imagecrafter.java @@ -37,6 +37,7 @@ import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BecomesChosenNonWallCreatureTypeTargetEffect; import mage.abilities.effects.common.continuous.BecomesSubtypeTargetEffect; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; @@ -68,7 +69,7 @@ public class Imagecrafter extends CardImpl { this.toughness = new MageInt(1); // {tap}: Choose a creature type other than Wall. Target creature becomes that type until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ImagecrafterEffect(), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesChosenNonWallCreatureTypeTargetEffect(), new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -82,52 +83,4 @@ public class Imagecrafter extends CardImpl { return new Imagecrafter(this); } -} - -class ImagecrafterEffect extends OneShotEffect { - - public ImagecrafterEffect() { - super(Outcome.BoostCreature); - staticText = "choose a creature type other than wall, target creature's type becomes that type until end of turn"; - } - - public ImagecrafterEffect(final ImagecrafterEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - String chosenType = ""; - if (player != null && permanent != null) { - Choice typeChoice = new ChoiceImpl(true); - typeChoice.setMessage("Choose creature type other than Wall"); - Set types = CardRepository.instance.getCreatureTypes(); - types.remove("Wall"); - typeChoice.setChoices(types); - while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { - if (!player.isInGame()) { - return false; - } - } - game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); - chosenType = typeChoice.getChoice(); - if (chosenType != null && !chosenType.isEmpty()) { - // ADD TYPE TO TARGET - ContinuousEffect effect = new BecomesSubtypeTargetEffect(Duration.EndOfTurn, chosenType); - effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); - game.addEffect(effect, source); - return true; - } - - } - return false; - } - - @Override - public Effect copy() { - return new ImagecrafterEffect(this); - } - -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/onslaught/MistformMutant.java b/Mage.Sets/src/mage/sets/onslaught/MistformMutant.java index b79b7d2bf30..1573178e3aa 100644 --- a/Mage.Sets/src/mage/sets/onslaught/MistformMutant.java +++ b/Mage.Sets/src/mage/sets/onslaught/MistformMutant.java @@ -37,6 +37,7 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BecomesChosenNonWallCreatureTypeTargetEffect; import mage.abilities.effects.common.continuous.BecomesSubtypeTargetEffect; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; @@ -68,7 +69,7 @@ public class MistformMutant extends CardImpl { this.toughness = new MageInt(4); // {1}{U}: Choose a creature type other than Wall. Target creature becomes that type until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MistformMutantEffect(), new ManaCostsImpl<>("{1}{U}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesChosenNonWallCreatureTypeTargetEffect(), new ManaCostsImpl<>("{1}{U}")); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -81,54 +82,4 @@ public class MistformMutant extends CardImpl { public MistformMutant copy() { return new MistformMutant(this); } -} - -class MistformMutantEffect extends OneShotEffect { - - public MistformMutantEffect() { - super(Outcome.BoostCreature); - staticText = "choose a creature type other than wall, target creature's type becomes that type until end of turn"; - } - - public MistformMutantEffect(final MistformMutantEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - String chosenType = ""; - if (player != null && permanent != null) { - Choice typeChoice = new ChoiceImpl(true); - typeChoice.setMessage("Choose creature type other than Wall"); - Set types = CardRepository.instance.getCreatureTypes(); - types.remove("Wall"); - typeChoice.setChoices(types); - while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { - if (!player.isInGame()) { - return false; - } - } - game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); - chosenType = typeChoice.getChoice(); - if (chosenType != null && !chosenType.isEmpty()) { - // ADD TYPE TO TARGET - ContinuousEffect effect = new BecomesSubtypeTargetEffect(Duration.EndOfTurn, chosenType); - effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); - game.addEffect(effect, source); - return true; - } - - } - return false; - } - - @Override - public Effect copy() { - return new MistformMutantEffect(this); - } - - - -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/onslaught/Standardize.java b/Mage.Sets/src/mage/sets/onslaught/Standardize.java index 9a793e7340f..0d819a67629 100644 --- a/Mage.Sets/src/mage/sets/onslaught/Standardize.java +++ b/Mage.Sets/src/mage/sets/onslaught/Standardize.java @@ -27,27 +27,13 @@ */ package mage.sets.onslaught; -import java.util.Set; import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continuous.BecomesSubtypeTargetEffect; +import mage.abilities.effects.common.continuous.BecomesChosenNonWallCreatureTypeTargetEffect; import mage.cards.CardImpl; -import mage.cards.repository.CardRepository; -import mage.choices.Choice; -import mage.choices.ChoiceImpl; import mage.constants.CardType; -import mage.constants.Duration; -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.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -61,7 +47,7 @@ public class Standardize extends CardImpl { // Choose a creature type other than Wall. Each creature becomes that type until end of turn. this.getSpellAbility().addTarget(new TargetCreaturePermanent()); - this.getSpellAbility().addEffect(new StandardizeEffect()); + this.getSpellAbility().addEffect(new BecomesChosenNonWallCreatureTypeTargetEffect()); } public Standardize(final Standardize card) { @@ -72,54 +58,4 @@ public class Standardize extends CardImpl { public Standardize copy() { return new Standardize(this); } -} - -class StandardizeEffect extends OneShotEffect { - - public StandardizeEffect() { - super(Outcome.BoostCreature); - staticText = "choose a creature type other than wall, target creature's type becomes that type until end of turn"; - } - - public StandardizeEffect(final StandardizeEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - String chosenType = ""; - if (player != null && permanent != null) { - Choice typeChoice = new ChoiceImpl(true); - typeChoice.setMessage("Choose creature type other than Wall"); - Set types = CardRepository.instance.getCreatureTypes(); - types.remove("Wall"); - typeChoice.setChoices(types); - while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { - if (!player.isInGame()) { - return false; - } - } - game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); - chosenType = typeChoice.getChoice(); - if (chosenType != null && !chosenType.isEmpty()) { - // ADD TYPE TO TARGET - ContinuousEffect effect = new BecomesSubtypeTargetEffect(Duration.EndOfTurn, chosenType); - effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); - game.addEffect(effect, source); - return true; - } - - } - return false; - } - - @Override - public Effect copy() { - return new StandardizeEffect(this); - } - - - } \ No newline at end of file diff --git a/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java b/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java new file mode 100644 index 00000000000..3055295f8fd --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java @@ -0,0 +1,66 @@ +package mage.abilities.effects.common.continuous; + +import java.util.Set; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.cards.repository.CardRepository; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +public class BecomesChosenNonWallCreatureTypeTargetEffect extends OneShotEffect { + + public BecomesChosenNonWallCreatureTypeTargetEffect() { + super(Outcome.BoostCreature); + staticText = "choose a creature type other than wall, target creature's type becomes that type until end of turn"; + + } + + public BecomesChosenNonWallCreatureTypeTargetEffect(final BecomesChosenNonWallCreatureTypeTargetEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(source.getSourceId()); + String chosenType = ""; + if (player != null && permanent != null) { + Choice typeChoice = new ChoiceImpl(true); + typeChoice.setMessage("Choose creature type other than Wall"); + Set types = CardRepository.instance.getCreatureTypes(); + types.remove("Wall"); + typeChoice.setChoices(types); + while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { + if (!player.isInGame()) { + return false; + } + } + game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); + chosenType = typeChoice.getChoice(); + if (chosenType != null && !chosenType.isEmpty()) { + // ADD TYPE TO TARGET + ContinuousEffect effect = new BecomesSubtypeTargetEffect(Duration.EndOfTurn, chosenType); + effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); + game.addEffect(effect, source); + return true; + } + + } + return false; + } + + @Override + public Effect copy() { + return new BecomesChosenNonWallCreatureTypeTargetEffect(this); + } + +}