From 34d604fe4b8485b7bb8dbc1732d99bb937d2881e Mon Sep 17 00:00:00 2001 From: LoneFox Date: Wed, 9 Sep 2015 12:14:54 +0300 Subject: [PATCH] Rename BecomesChosenNonWallCreatureTypeTargetEffect -> BecomesChosenCreatureTypeTargetEffect and make the non-Wall part a parameter. Clean up the cards that use it. Fix Standardize, which was using wrong effect. --- .../sets/apocalypse/UnnaturalSelection.java | 18 +--- .../src/mage/sets/onslaught/Imagecrafter.java | 20 +---- .../mage/sets/onslaught/MistformMutant.java | 18 +--- .../src/mage/sets/onslaught/Standardize.java | 42 +++++---- ...BecomesChosenCreatureTypeTargetEffect.java | 85 +++++++++++++++++++ ...ChosenNonWallCreatureTypeTargetEffect.java | 66 -------------- 6 files changed, 115 insertions(+), 134 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java delete mode 100644 Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java diff --git a/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java b/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java index 57e913f07b4..0106d3ca2fc 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java +++ b/Mage.Sets/src/mage/sets/apocalypse/UnnaturalSelection.java @@ -33,25 +33,13 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; 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.abilities.effects.common.continuous.BecomesChosenCreatureTypeTargetEffect; 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.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -64,7 +52,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 BecomesChosenNonWallCreatureTypeTargetEffect(), new GenericManaCost(1)); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesChosenCreatureTypeTargetEffect(true), new GenericManaCost(1)); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -77,4 +65,4 @@ public class UnnaturalSelection extends CardImpl { public UnnaturalSelection copy() { return new UnnaturalSelection(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 cb3db6bc1dd..543086215f0 100644 --- a/Mage.Sets/src/mage/sets/onslaught/Imagecrafter.java +++ b/Mage.Sets/src/mage/sets/onslaught/Imagecrafter.java @@ -34,25 +34,13 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; 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.abilities.effects.common.continuous.BecomesChosenCreatureTypeTargetEffect; 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.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -69,7 +57,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 BecomesChosenNonWallCreatureTypeTargetEffect(), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesChosenCreatureTypeTargetEffect(true), new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -82,5 +70,5 @@ public class Imagecrafter extends CardImpl { public Imagecrafter copy() { return new Imagecrafter(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 1573178e3aa..c9ce8287761 100644 --- a/Mage.Sets/src/mage/sets/onslaught/MistformMutant.java +++ b/Mage.Sets/src/mage/sets/onslaught/MistformMutant.java @@ -34,25 +34,13 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; 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.abilities.effects.common.continuous.BecomesChosenCreatureTypeTargetEffect; 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.constants.Zone; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -69,7 +57,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 BecomesChosenNonWallCreatureTypeTargetEffect(), new ManaCostsImpl<>("{1}{U}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesChosenCreatureTypeTargetEffect(true), new ManaCostsImpl<>("{1}{U}")); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -82,4 +70,4 @@ public class MistformMutant extends CardImpl { public MistformMutant copy() { return new MistformMutant(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 760ae76aead..c2c6f8624d0 100644 --- a/Mage.Sets/src/mage/sets/onslaught/Standardize.java +++ b/Mage.Sets/src/mage/sets/onslaught/Standardize.java @@ -34,7 +34,6 @@ 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.BecomesChosenNonWallCreatureTypeTargetEffect; import mage.abilities.effects.common.continuous.BecomesSubtypeAllEffect; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; @@ -59,8 +58,8 @@ public class Standardize extends CardImpl { this.expansionSetCode = "ONS"; // Choose a creature type other than Wall. Each creature becomes that type until end of turn. - - this.getSpellAbility().addEffect(new BecomesChosenNonWallCreatureTypeTargetEffect()); + + this.getSpellAbility().addEffect(new StandardizeEffect()); } public Standardize(final Standardize card) { @@ -77,19 +76,19 @@ public class Standardize extends CardImpl { class StandardizeEffect extends OneShotEffect { - public StandardizeEffect() { - super(Outcome.BoostCreature); - staticText = "choose a creature type other than wall, each creature's type becomes that type until end of turn"; - - } - - public StandardizeEffect(final StandardizeEffect effect) { - super(effect); - } + public StandardizeEffect() { + super(Outcome.BoostCreature); + staticText = "choose a creature type other than wall, each creature's type becomes that type until end of turn"; - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + } + + 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) { @@ -111,14 +110,13 @@ class StandardizeEffect extends OneShotEffect { game.addEffect(effect, source); return true; } - + } return false; - } - - @Override - public Effect copy() { - return new StandardizeEffect(this); - } + } + @Override + public Effect copy() { + return new StandardizeEffect(this); + } } diff --git a/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java b/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java new file mode 100644 index 00000000000..67c07ee1c0e --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenCreatureTypeTargetEffect.java @@ -0,0 +1,85 @@ +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.Card; +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.players.Player; +import mage.target.targetpointer.FixedTarget; + +public class BecomesChosenCreatureTypeTargetEffect extends OneShotEffect { + + private final boolean nonWall; + + public BecomesChosenCreatureTypeTargetEffect() { + this(false); + } + + public BecomesChosenCreatureTypeTargetEffect(boolean nonWall) { + super(Outcome.BoostCreature); + this.nonWall = nonWall; + if(nonWall) { + staticText = "choose a creature type other than wall, target creature's type becomes that type until end of turn"; + } + else { + staticText = "target creature becomes the creature type of your choice until end of turn"; + } + + } + + public BecomesChosenCreatureTypeTargetEffect(final BecomesChosenCreatureTypeTargetEffect effect) { + super(effect); + this.nonWall = effect.nonWall; + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Card card = game.getCard(source.getSourceId()); + String chosenType = ""; + if (player != null && card != null) { + Choice typeChoice = new ChoiceImpl(true); + String msg = "Choose a creature type"; + if(nonWall) { + msg += " other than Wall"; + } + typeChoice.setMessage(msg); + Set types = CardRepository.instance.getCreatureTypes(); + if(nonWall) { + types.remove("Wall"); + } + typeChoice.setChoices(types); + while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { + if (!player.canRespond()) { + return false; + } + } + game.informPlayers(card.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 BecomesChosenCreatureTypeTargetEffect(this); + } + +} diff --git a/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java b/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java deleted file mode 100644 index 316ef45e413..00000000000 --- a/Mage/src/mage/abilities/effects/common/continuous/BecomesChosenNonWallCreatureTypeTargetEffect.java +++ /dev/null @@ -1,66 +0,0 @@ -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.canRespond()) { - 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); - } - -}