diff --git a/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java b/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java index 56fe931f45..e392be4957 100644 --- a/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java +++ b/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java @@ -117,7 +117,7 @@ class WaveOfVitriolEffect extends OneShotEffect { } permanent.sacrifice(source.getSourceId(), game); } - if (count > 0 && player.chooseUse(Outcome.PutLandInPlay, "Search your libraray for up to " + count + " basic lands?", game)) { + if (count > 0 && player.chooseUse(Outcome.PutLandInPlay, "Search your library for up to " + count + " basic lands?", game)) { Target target = new TargetCardInLibrary(0,count, new FilterBasicLandCard()); player.chooseTarget(outcome, target, source, game); for(UUID targetId: target.getTargets()) { diff --git a/Mage.Sets/src/mage/sets/eventide/SwirlingSpriggan.java b/Mage.Sets/src/mage/sets/eventide/SwirlingSpriggan.java index f4ad0249f7..0e0f12d467 100644 --- a/Mage.Sets/src/mage/sets/eventide/SwirlingSpriggan.java +++ b/Mage.Sets/src/mage/sets/eventide/SwirlingSpriggan.java @@ -27,29 +27,18 @@ */ package mage.sets.eventide; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import mage.MageInt; -import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continious.BecomesColorTargetEffect; +import mage.abilities.effects.common.continious.BecomesColorOrColorsTargetEffect; import mage.cards.CardImpl; -import mage.choices.ChoiceColor; 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.TargetControlledCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -63,12 +52,11 @@ public class SwirlingSpriggan extends CardImpl { this.subtype.add("Goblin"); this.subtype.add("Shaman"); - this.color.setGreen(true); this.power = new MageInt(3); this.toughness = new MageInt(3); // {GU}{GU}: Target creature you control becomes the color or colors of your choice until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ChangeColorOrColorsTargetEffect(), new ManaCostsImpl("G/U}{G/U}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorOrColorsTargetEffect(Duration.EndOfTurn), new ManaCostsImpl("G/U}{G/U}")); ability.addTarget(new TargetControlledCreaturePermanent()); this.addAbility(ability); } @@ -82,58 +70,3 @@ public class SwirlingSpriggan extends CardImpl { return new SwirlingSpriggan(this); } } - -class ChangeColorOrColorsTargetEffect extends OneShotEffect { - - public ChangeColorOrColorsTargetEffect() { - super(Outcome.Neutral); - staticText = "target creature you control becomes the color or colors of your choice until end of turn"; - } - - public ChangeColorOrColorsTargetEffect(final ChangeColorOrColorsTargetEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player you = game.getPlayer(source.getControllerId()); - Permanent target = game.getPermanent(source.getFirstTarget()); - List chosenColors = new ArrayList<>(); - if (you != null && target != null) { - for (int i = 0; i < 5; i++) { - if (!you.chooseUse(Outcome.Neutral, "Do you wish to choose another color?", game)) { - break; - } - ChoiceColor choiceColor = new ChoiceColor(); - you.choose(Outcome.Benefit, choiceColor, game); - if (!you.isInGame()) { - return false; - } - game.informPlayers(target.getName() + ": " + you.getName() + " has chosen " + choiceColor.getChoice()); - if (choiceColor.getColor().isBlack()) { - chosenColors.add(ObjectColor.BLACK); - } else if (choiceColor.getColor().isBlue()) { - chosenColors.add(ObjectColor.BLUE); - } else if (choiceColor.getColor().isRed()) { - chosenColors.add(ObjectColor.RED); - } else if (choiceColor.getColor().isGreen()) { - chosenColors.add(ObjectColor.GREEN); - } else if (choiceColor.getColor().isWhite()) { - chosenColors.add(ObjectColor.WHITE); - } - } - for (ObjectColor color : chosenColors) { - ContinuousEffect effect = new BecomesColorTargetEffect(color, Duration.EndOfTurn, "is " + color); - effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); - game.addEffect(effect, source); - } - return true; - } - return false; - } - - @Override - public ChangeColorOrColorsTargetEffect copy() { - return new ChangeColorOrColorsTargetEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/planechase/ThirstForKnowledge.java b/Mage.Sets/src/mage/sets/planechase/ThirstForKnowledge.java index 4bf843a78f..c6e6c48344 100644 --- a/Mage.Sets/src/mage/sets/planechase/ThirstForKnowledge.java +++ b/Mage.Sets/src/mage/sets/planechase/ThirstForKnowledge.java @@ -103,7 +103,7 @@ class ThirstforKnowledgeEffect extends OneShotEffect { } } if (you != null) { - you.discard(2, source, game); + you.discard(2, false, source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/shadowmoor/PrismwakeMerrow.java b/Mage.Sets/src/mage/sets/shadowmoor/PrismwakeMerrow.java index 1764c5b92f..884ed14b6f 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/PrismwakeMerrow.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/PrismwakeMerrow.java @@ -27,28 +27,17 @@ */ package mage.sets.shadowmoor; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import mage.MageInt; -import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continious.BecomesColorTargetEffect; +import mage.abilities.effects.common.continious.BecomesColorOrColorsTargetEffect; import mage.abilities.keyword.FlashAbility; import mage.cards.CardImpl; -import mage.choices.ChoiceColor; 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.TargetPermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -62,7 +51,6 @@ public class PrismwakeMerrow extends CardImpl { this.subtype.add("Merfolk"); this.subtype.add("Wizard"); - this.color.setBlue(true); this.power = new MageInt(2); this.toughness = new MageInt(1); @@ -70,7 +58,7 @@ public class PrismwakeMerrow extends CardImpl { this.addAbility(FlashAbility.getInstance()); // When Prismwake Merrow enters the battlefield, target permanent becomes the color or colors of your choice until end of turn. - Ability ability = new EntersBattlefieldTriggeredAbility(new ChangeColorOrColorsTargetEffect(), false); + Ability ability = new EntersBattlefieldTriggeredAbility(new BecomesColorOrColorsTargetEffect(Duration.EndOfTurn), false); ability.addTarget(new TargetPermanent()); this.addAbility(ability); @@ -85,58 +73,3 @@ public class PrismwakeMerrow extends CardImpl { return new PrismwakeMerrow(this); } } - -class ChangeColorOrColorsTargetEffect extends OneShotEffect { - - public ChangeColorOrColorsTargetEffect() { - super(Outcome.Neutral); - staticText = "target permanent becomes the color or colors of your choice until end of turn"; - } - - public ChangeColorOrColorsTargetEffect(final ChangeColorOrColorsTargetEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player you = game.getPlayer(source.getControllerId()); - Permanent target = game.getPermanent(source.getFirstTarget()); - List chosenColors = new ArrayList<>(); - if (you != null && target != null) { - for (int i = 0; i < 5; i++) { - if (!you.chooseUse(Outcome.Neutral, "Do you wish to choose another color?", game)) { - break; - } - ChoiceColor choiceColor = new ChoiceColor(); - you.choose(Outcome.Benefit, choiceColor, game); - if (!you.isInGame()) { - return false; - } - game.informPlayers(target.getName() + ": " + you.getName() + " has chosen " + choiceColor.getChoice()); - if (choiceColor.getColor().isBlack()) { - chosenColors.add(ObjectColor.BLACK); - } else if (choiceColor.getColor().isBlue()) { - chosenColors.add(ObjectColor.BLUE); - } else if (choiceColor.getColor().isRed()) { - chosenColors.add(ObjectColor.RED); - } else if (choiceColor.getColor().isGreen()) { - chosenColors.add(ObjectColor.GREEN); - } else if (choiceColor.getColor().isWhite()) { - chosenColors.add(ObjectColor.WHITE); - } - } - for (ObjectColor color : chosenColors) { - ContinuousEffect effect = new BecomesColorTargetEffect(color, Duration.EndOfTurn, "is " + color); - effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); - game.addEffect(effect, source); - } - return true; - } - return false; - } - - @Override - public ChangeColorOrColorsTargetEffect copy() { - return new ChangeColorOrColorsTargetEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java b/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java index 9f5b1cfb78..389abe2191 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java @@ -29,26 +29,17 @@ package mage.sets.shadowmoor; import java.util.UUID; import mage.MageInt; -import mage.ObjectColor; -import mage.cards.CardImpl; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.abilities.mana.AnyColorManaAbility; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; -import mage.constants.Zone; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continious.BecomesColorTargetEffect; -import mage.choices.ChoiceColor; +import mage.abilities.effects.common.continious.BecomesColorOrColorsTargetEffect; +import mage.abilities.mana.AnyColorManaAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.Outcome; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -63,10 +54,11 @@ public class Scuttlemutt extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); - // {tap}: Add one mana of any color to your mana pool. + // {T}: Add one mana of any color to your mana pool. this.addAbility(new AnyColorManaAbility()); - // {tap}: Target creature becomes the color or colors of your choice until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ChangeColorsTargetEffect(), new TapSourceCost()); + + // {T}: Target creature becomes the color or colors of your choice until end of turn. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorOrColorsTargetEffect(Duration.EndOfTurn), new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -80,64 +72,3 @@ public class Scuttlemutt extends CardImpl { return new Scuttlemutt(this); } } - -class ChangeColorsTargetEffect extends OneShotEffect { - - public ChangeColorsTargetEffect() { - super(Outcome.Neutral); - staticText = "target creature becomes the color or colors of your choice until end of turn"; - } - - @Override - public boolean apply(Game game, Ability source) { - Player you = game.getPlayer(source.getControllerId()); - Permanent target = game.getPermanent(source.getFirstTarget()); - StringBuilder sb = new StringBuilder(); - - if (you != null && target != null) { - for (int i = 0; i < 5; i++) { - if (!you.chooseUse(Outcome.Neutral, "Do you wish to choose another color?", game)) { - break; - } - ChoiceColor choiceColor = new ChoiceColor(); - you.choose(Outcome.Benefit, choiceColor, game); - if (!you.isInGame()) { - return false; - } - game.informPlayers(target.getName() + ": " + you.getName() + " has chosen " + choiceColor.getChoice()); - if (choiceColor.getColor().isBlack()) { - sb.append("B"); - } else if (choiceColor.getColor().isBlue()) { - sb.append("U"); - } else if (choiceColor.getColor().isRed()) { - sb.append("R"); - } else if (choiceColor.getColor().isGreen()) { - sb.append("G"); - } else if (choiceColor.getColor().isWhite()) { - sb.append("W"); - } - } - String colors = new String(sb); - ObjectColor chosenColors = new ObjectColor(colors); - - - ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); - game.addEffect(effect, source); - - return true; - } - return false; - } - - public ChangeColorsTargetEffect(final ChangeColorsTargetEffect effect) { - super(effect); - } - - @Override - public ChangeColorsTargetEffect copy() { - return new ChangeColorsTargetEffect(this); - } -} - - diff --git a/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java new file mode 100644 index 0000000000..57fe6be0a2 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java @@ -0,0 +1,129 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.effects.common.continious; + +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.choices.ChoiceColor; +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; + +/** + * + * @author LevelX2 + */ + +public class BecomesColorOrColorsTargetEffect extends OneShotEffect { + + Duration duration; + /** + * This effect let the controller choose one or more colors the target will + * become to. + * Use effect.setText() if case you use a targetPointer, otherwise the rule text will be empty. + * + * @param duration + */ + public BecomesColorOrColorsTargetEffect(Duration duration) { + super(Outcome.Neutral); + this.duration = duration; + } + + public BecomesColorOrColorsTargetEffect(final BecomesColorOrColorsTargetEffect effect) { + super(effect); + this.duration = effect.duration; + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent target = game.getPermanent(source.getFirstTarget()); + StringBuilder sb = new StringBuilder(); + + if (controller != null && target != null) { + for (int i = 0; i < 5; i++) { + if (!controller.chooseUse(Outcome.Neutral, "Do you wish to choose another color?", game)) { + break; + } + ChoiceColor choiceColor = new ChoiceColor(); + controller.choose(Outcome.Benefit, choiceColor, game); + if (!controller.isInGame()) { + return false; + } + game.informPlayers(target.getName() + ": " + controller.getName() + " has chosen " + choiceColor.getChoice()); + if (choiceColor.getColor().isBlack()) { + sb.append("B"); + } else if (choiceColor.getColor().isBlue()) { + sb.append("U"); + } else if (choiceColor.getColor().isRed()) { + sb.append("R"); + } else if (choiceColor.getColor().isGreen()) { + sb.append("G"); + } else if (choiceColor.getColor().isWhite()) { + sb.append("W"); + } + } + String colors = new String(sb); + ObjectColor chosenColors = new ObjectColor(colors); + ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, duration); + effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); + game.addEffect(effect, source); + + return true; + } + return false; + } + + @Override + public BecomesColorOrColorsTargetEffect copy() { + return new BecomesColorOrColorsTargetEffect(this); + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + StringBuilder sb = new StringBuilder(); + if (mode.getTargets().size() > 0) { + sb.append("target "); + sb.append(mode.getTargets().get(0).getMessage()); + sb.append(" becomes the color or colors of your choice"); + if (duration.toString().length() > 0) { + sb.append(" ").append(duration.toString()); + } + } + return sb.toString(); + } +}