From ea693769431cf0bb27d92ea192b58dfbcd2981ee Mon Sep 17 00:00:00 2001 From: User Date: Fri, 20 Feb 2015 16:24:00 -0500 Subject: [PATCH 1/2] Add Scuttlemutt and BecomesColorOrColorsTargetEffect --- .../src/mage/sets/shadowmoor/Scuttlemutt.java | 143 ++++++++++++++++++ .../BecomesColorOrColorsTargetEffect.java | 126 +++++++++++++++ 2 files changed, 269 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java create mode 100644 Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java diff --git a/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java b/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java new file mode 100644 index 00000000000..a758f51fc1e --- /dev/null +++ b/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java @@ -0,0 +1,143 @@ +/* + * 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.sets.shadowmoor; + +import java.util.ArrayList; +import java.util.List; +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.BecomesColorOrColorsTargetEffect; +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.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author philvt101 + */ +public class Scuttlemutt extends CardImpl { + + public Scuttlemutt(UUID ownerId) { + super(ownerId, 263, "Scuttlemutt", Rarity.COMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}"); + this.expansionSetCode = "SHM"; + this.subtype.add("Scarecrow"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // {tap}: 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()); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public Scuttlemutt(final Scuttlemutt card) { + super(card); + } + + @Override + public Scuttlemutt copy() { + 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()); + 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); + } + } + + + ContinuousEffect effect = new BecomesColorOrColorsTargetEffect(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 00000000000..acc8e67ed68 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java @@ -0,0 +1,126 @@ +/* + * + * 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 java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; +import mage.players.Player; +import java.util.List; +import mage.ObjectColor; + +/** + * + * @author philvt101 + */ + +public class BecomesColorOrColorsTargetEffect extends ContinuousEffectImpl { + + private final List colors; + + /** + * Set the color or colors of a spell or permanent + * + * @param duration + * @param colors + */ + + public BecomesColorOrColorsTargetEffect(List colors, Duration duration) { + super(duration, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit); + this.colors=colors; + } + + @Override + public boolean apply(Game game, Ability source){ + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + boolean result = false; + + for (UUID targetId :targetPointer.getTargets(game, source)) { + MageObject o = game.getObject(targetId); + if(o != null){ + if(o instanceof Permanent || o instanceof StackObject);{ + if(!colors.isEmpty()){ + /**As target may become a single color other than its original color, + * all colors must be initialized to false before applying chosen color/colors + */ + o.getColor().setWhite(false); + o.getColor().setBlue(false); + o.getColor().setBlack(false); + o.getColor().setRed(false); + o.getColor().setGreen(false); + + for (ObjectColor color : colors) { + if (color.isWhite()) { + o.getColor().setWhite(true); + } else if (color.isBlue()) { + o.getColor().setBlue(true); + } else if (color.isBlack()) { + o.getColor().setBlack(true); + } else if (color.isRed()) { + o.getColor().setRed(true); + } else if (color.isGreen()) { + o.getColor().setGreen(true); + } + } + } + } + } + } + + if (!result) { + if (this.getDuration().equals(Duration.Custom)) { + this.discard(); + } + } + return result; + } + + public BecomesColorOrColorsTargetEffect(final BecomesColorOrColorsTargetEffect effect) { + super(effect); + this.colors = effect.colors; + } + + @Override + public BecomesColorOrColorsTargetEffect copy() { + return new BecomesColorOrColorsTargetEffect(this); + } + +} From 81b2124302b76e759b290fb4ef06bfda2a4e75c6 Mon Sep 17 00:00:00 2001 From: User Date: Fri, 20 Feb 2015 20:53:31 -0500 Subject: [PATCH 2/2] Improved Scuttlemutt and deleted now unnecessary BecomeColorOrColorsTargetEffect --- .../src/mage/sets/shadowmoor/Scuttlemutt.java | 20 +-- .../BecomesColorOrColorsTargetEffect.java | 126 ------------------ 2 files changed, 10 insertions(+), 136 deletions(-) delete mode 100644 Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java diff --git a/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java b/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java index a758f51fc1e..9f5b1cfb788 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/Scuttlemutt.java @@ -27,8 +27,6 @@ */ package mage.sets.shadowmoor; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import mage.MageInt; import mage.ObjectColor; @@ -42,7 +40,7 @@ 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.BecomesColorOrColorsTargetEffect; +import mage.abilities.effects.common.continious.BecomesColorTargetEffect; import mage.choices.ChoiceColor; import mage.constants.Duration; import mage.constants.Outcome; @@ -94,7 +92,7 @@ class ChangeColorsTargetEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); Permanent target = game.getPermanent(source.getFirstTarget()); - List chosenColors = new ArrayList<>(); + StringBuilder sb = new StringBuilder(); if (you != null && target != null) { for (int i = 0; i < 5; i++) { @@ -108,20 +106,22 @@ class ChangeColorsTargetEffect extends OneShotEffect { } game.informPlayers(target.getName() + ": " + you.getName() + " has chosen " + choiceColor.getChoice()); if (choiceColor.getColor().isBlack()) { - chosenColors.add(ObjectColor.BLACK); + sb.append("B"); } else if (choiceColor.getColor().isBlue()) { - chosenColors.add(ObjectColor.BLUE); + sb.append("U"); } else if (choiceColor.getColor().isRed()) { - chosenColors.add(ObjectColor.RED); + sb.append("R"); } else if (choiceColor.getColor().isGreen()) { - chosenColors.add(ObjectColor.GREEN); + sb.append("G"); } else if (choiceColor.getColor().isWhite()) { - chosenColors.add(ObjectColor.WHITE); + sb.append("W"); } } + String colors = new String(sb); + ObjectColor chosenColors = new ObjectColor(colors); - ContinuousEffect effect = new BecomesColorOrColorsTargetEffect(chosenColors, Duration.EndOfTurn); + ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); game.addEffect(effect, source); diff --git a/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java deleted file mode 100644 index acc8e67ed68..00000000000 --- a/Mage/src/mage/abilities/effects/common/continious/BecomesColorOrColorsTargetEffect.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * 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 java.util.UUID; -import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffectImpl; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.game.stack.StackObject; -import mage.players.Player; -import java.util.List; -import mage.ObjectColor; - -/** - * - * @author philvt101 - */ - -public class BecomesColorOrColorsTargetEffect extends ContinuousEffectImpl { - - private final List colors; - - /** - * Set the color or colors of a spell or permanent - * - * @param duration - * @param colors - */ - - public BecomesColorOrColorsTargetEffect(List colors, Duration duration) { - super(duration, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit); - this.colors=colors; - } - - @Override - public boolean apply(Game game, Ability source){ - Player controller = game.getPlayer(source.getControllerId()); - if (controller == null) { - return false; - } - boolean result = false; - - for (UUID targetId :targetPointer.getTargets(game, source)) { - MageObject o = game.getObject(targetId); - if(o != null){ - if(o instanceof Permanent || o instanceof StackObject);{ - if(!colors.isEmpty()){ - /**As target may become a single color other than its original color, - * all colors must be initialized to false before applying chosen color/colors - */ - o.getColor().setWhite(false); - o.getColor().setBlue(false); - o.getColor().setBlack(false); - o.getColor().setRed(false); - o.getColor().setGreen(false); - - for (ObjectColor color : colors) { - if (color.isWhite()) { - o.getColor().setWhite(true); - } else if (color.isBlue()) { - o.getColor().setBlue(true); - } else if (color.isBlack()) { - o.getColor().setBlack(true); - } else if (color.isRed()) { - o.getColor().setRed(true); - } else if (color.isGreen()) { - o.getColor().setGreen(true); - } - } - } - } - } - } - - if (!result) { - if (this.getDuration().equals(Duration.Custom)) { - this.discard(); - } - } - return result; - } - - public BecomesColorOrColorsTargetEffect(final BecomesColorOrColorsTargetEffect effect) { - super(effect); - this.colors = effect.colors; - } - - @Override - public BecomesColorOrColorsTargetEffect copy() { - return new BecomesColorOrColorsTargetEffect(this); - } - -}