From 690c0f41a9c769726baab50e2fae6f24a83e9ba2 Mon Sep 17 00:00:00 2001 From: Samuel Sandeen Date: Sat, 23 Jul 2016 17:40:01 -0400 Subject: [PATCH 1/5] Implement Tribal Unity --- .../src/mage/sets/onslaught/TribalUnity.java | 53 ++++++++ .../src/mage/sets/planechase/TribalUnity.java | 121 ++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/onslaught/TribalUnity.java create mode 100644 Mage.Sets/src/mage/sets/planechase/TribalUnity.java diff --git a/Mage.Sets/src/mage/sets/onslaught/TribalUnity.java b/Mage.Sets/src/mage/sets/onslaught/TribalUnity.java new file mode 100644 index 00000000000..2fa03f6ada0 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/TribalUnity.java @@ -0,0 +1,53 @@ +/* + * 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.onslaught; + +import java.util.UUID; + +/** + * + * @author anonymous + */ +public class TribalUnity extends mage.sets.planechase.TribalUnity { + + public TribalUnity(UUID ownerId) { + super(ownerId); + this.cardNumber = 294; + this.expansionSetCode = "ONS"; + } + + public TribalUnity(final TribalUnity card) { + super(card); + } + + @Override + public TribalUnity copy() { + return new TribalUnity(this); + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/planechase/TribalUnity.java b/Mage.Sets/src/mage/sets/planechase/TribalUnity.java new file mode 100644 index 00000000000..3c63ce7f04c --- /dev/null +++ b/Mage.Sets/src/mage/sets/planechase/TribalUnity.java @@ -0,0 +1,121 @@ +/* + * 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.planechase; + +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect; +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.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author anonymous + */ +public class TribalUnity extends CardImpl { + + public TribalUnity(UUID ownerId) { + super(ownerId, 80, "Tribal Unity", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{X}{2}{G}"); + this.expansionSetCode = "HOP"; + + // Creatures of the creature type of your choice get +X/+X until end of turn. + this.getSpellAbility().addEffect(new TribalUnityEffect(new ManacostVariableValue())); + } + + public TribalUnity(final TribalUnity card) { + super(card); + } + + @Override + public TribalUnity copy() { + return new TribalUnity(this); + } +} + + + +class TribalUnityEffect extends OneShotEffect { + protected DynamicValue amount; + + public TribalUnityEffect(DynamicValue amount) { + super(Outcome.UnboostCreature); + staticText = "Creatures of the creature type of your choice get +X/+X until end of turn."; + this.amount = amount; + } + + public TribalUnityEffect(final TribalUnityEffect effect) { + super(effect); + this.amount = effect.amount; + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + int boost = amount.calculate(game, source, this); + if (player != null) { + Choice typeChoice = new ChoiceImpl(true); + typeChoice.setMessage("Choose a creature type:"); + typeChoice.setChoices(CardRepository.instance.getCreatureTypes()); + while (!player.choose(outcome, typeChoice, game)) { + if (!player.canRespond()) { + return false; + } + } + if (typeChoice.getChoice() != null) { + game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); + } + FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); + filterCreaturePermanent.add(new SubtypePredicate(typeChoice.getChoice())); + game.addEffect(new BoostAllOfChosenSubtypeEffect( + boost, boost, Duration.EndOfTurn, filterCreaturePermanent, false), source); + return true; + } + return false; + } + + @Override + public TribalUnityEffect copy() { + return new TribalUnityEffect(this); + } +} \ No newline at end of file From 32a814fa6ea47e7ffb0f7aab1c4438184e595ce1 Mon Sep 17 00:00:00 2001 From: Samuel Sandeen Date: Sat, 23 Jul 2016 17:40:12 -0400 Subject: [PATCH 2/5] Implement Simic Guildmage --- .../mage/sets/dissension/SimicGuildmage.java | 236 ++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java diff --git a/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java b/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java new file mode 100644 index 00000000000..48fd120a3a0 --- /dev/null +++ b/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java @@ -0,0 +1,236 @@ +/* + * 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.dissension; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.common.FilterEnchantmentPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.filter.predicate.permanent.PermanentIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author anonymous + */ +public class SimicGuildmage extends CardImpl { + + private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("Aura"); + + static { + filter.add(new SubtypePredicate("Aura")); + } + + public SimicGuildmage(UUID ownerId) { + super(ownerId, 148, "Simic Guildmage", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{G/U}{G/U}"); + this.expansionSetCode = "DIS"; + this.subtype.add("Elf"); + this.subtype.add("Wizard"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // {1}{G}: Move a +1/+1 counter from target creature onto another target creature with the same controller. + Ability countersAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveCounterFromTargetToTargetEffect(), new ManaCostsImpl("{1}{G}")); + countersAbility.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (you take counters from)"))); + countersAbility.addTarget(new SimicGuildmageSecondTargetCreaturePermanent()); + this.addAbility(countersAbility); + // {1}{U}: Attach target Aura enchanting a permanent to another permanent with the same controller. + Ability auraAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveAuraEffect(), new ManaCostsImpl("{1}{U}")); + auraAbility.addTarget(new TargetPermanent(filter)); + this.addAbility(auraAbility); + + + } + + public SimicGuildmage(final SimicGuildmage card) { + super(card); + } + + @Override + public SimicGuildmage copy() { + return new SimicGuildmage(this); + } +} + +class MoveCounterFromTargetToTargetEffect extends OneShotEffect { + + public MoveCounterFromTargetToTargetEffect() { + super(Outcome.Detriment); + this.staticText = "Move a +1/+1 counter from target creature onto another target creature with the same controller"; + } + + public MoveCounterFromTargetToTargetEffect(final MoveCounterFromTargetToTargetEffect effect) { + super(effect); + } + + @Override + public MoveCounterFromTargetToTargetEffect copy() { + return new MoveCounterFromTargetToTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + Permanent toPermanent = null; + if (source.getTargets().size() > 1) { + toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); + } + if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) { + return false; + } + fromPermanent.removeCounters(CounterType.P1P1.createInstance(1), game); + toPermanent.addCounters(CounterType.P1P1.createInstance(1), game); + return true; + } + return false; + + } +} + +class SimicGuildmageSecondTargetCreaturePermanent extends TargetCreaturePermanent { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another target creature with the same controller (counters go to)"); + + SimicGuildmageSecondTargetCreaturePermanent() { + super(filter); + } + + SimicGuildmageSecondTargetCreaturePermanent(final SimicGuildmageSecondTargetCreaturePermanent target) { + super(target); + } + + @Override + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { + Permanent firstPermanent = game.getPermanent(source.getTargets().getFirstTarget()); + Permanent secondPermanent = game.getPermanent(id); + if (firstPermanent != null && secondPermanent != null) { + if (!firstPermanent.getId().equals(id) && firstPermanent.getControllerId().equals(secondPermanent.getControllerId())) { + return super.canTarget(controllerId, id, source, game); + } + } + return false; + } + + @Override + public SimicGuildmageSecondTargetCreaturePermanent copy() { + return new SimicGuildmageSecondTargetCreaturePermanent(this); + } +} + +class MoveAuraEffect extends OneShotEffect { + + public MoveAuraEffect() { + super(Outcome.AIDontUseIt); + staticText = "Attach target Aura enchanting a permanent to another permanent with the same controller."; + } + + public MoveAuraEffect(final MoveAuraEffect effect) { + super(effect); + } + + @Override + public MoveAuraEffect copy() { + return new MoveAuraEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + /* + 5/1/2006 + For the second ability, only the Aura is targeted. + When the ability resolves, you choose a permanent to move the Aura onto. + It can’t be the permanent the Aura is already attached to, it must be controlled by the player who controls the permanent the Aura is attached to, and it must be able to be enchanted by the Aura. + (It doesn’t matter who controls the Aura or who controls Simic Guildmage.) + If no such permanent exists, the Aura doesn’t move. + */ + UUID auraId = getTargetPointer().getFirst(game, source); + Permanent aura = game.getPermanent(auraId); + Permanent fromPermanent = game.getPermanent(aura.getAttachedTo()); + Player controller = game.getPlayer(source.getControllerId()); + if (fromPermanent != null && controller != null) { + Boolean passed = true; + FilterPermanent filterChoice = new FilterPermanent("a different permanent with the same controller as the target to attach the enchantments to"); + filterChoice.add(new ControllerIdPredicate(fromPermanent.getControllerId())); + filterChoice.add(Predicates.not(new PermanentIdPredicate(fromPermanent.getId()))); + + Target chosenPermanentToAttachAuras = new TargetPermanent(filterChoice); + chosenPermanentToAttachAuras.setNotTarget(true); + + if (chosenPermanentToAttachAuras.canChoose(source.getSourceId(), source.getControllerId(), game) + && controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) { + Permanent permanentToAttachAuras = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget()); + if (permanentToAttachAuras != null) { + if (aura != null && passed) { + // Check the target filter + Target target = aura.getSpellAbility().getTargets().get(0); + if (target instanceof TargetPermanent) { + if (!target.getFilter().match(permanentToAttachAuras, game)) { + passed = false; + } + } + // Check for protection + MageObject auraObject = game.getObject(auraId); + if (permanentToAttachAuras.cantBeEnchantedBy(auraObject, game)) { + passed = false; + } + } + if (passed) { + fromPermanent.removeAttachment(aura.getId(), game); + permanentToAttachAuras.addAttachment(aura.getId(), game); + return true; + } + } + } + return true; + } + + return false; + } +} \ No newline at end of file From 5e26638ab560f8510fb095f32f95988cc00777e3 Mon Sep 17 00:00:00 2001 From: Samuel Sandeen Date: Sun, 24 Jul 2016 18:02:22 -0400 Subject: [PATCH 3/5] Fix a bug in Tribal Unity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BoostAllOfChosenSubtypeEffect was too specific and didn’t apply to this situation. It has been replaced with it’s superclass BoostAllEffect --- .../src/mage/sets/planechase/TribalUnity.java | 5 ++-- .../test/cards/continuous/BoostAllTest.java | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/planechase/TribalUnity.java b/Mage.Sets/src/mage/sets/planechase/TribalUnity.java index 3c63ce7f04c..6843ff80378 100644 --- a/Mage.Sets/src/mage/sets/planechase/TribalUnity.java +++ b/Mage.Sets/src/mage/sets/planechase/TribalUnity.java @@ -33,7 +33,7 @@ import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect; +import mage.abilities.effects.common.continuous.BoostAllEffect; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; import mage.choices.Choice; @@ -45,7 +45,6 @@ import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -107,7 +106,7 @@ class TribalUnityEffect extends OneShotEffect { } FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent(); filterCreaturePermanent.add(new SubtypePredicate(typeChoice.getChoice())); - game.addEffect(new BoostAllOfChosenSubtypeEffect( + game.addEffect(new BoostAllEffect( boost, boost, Duration.EndOfTurn, filterCreaturePermanent, false), source); return true; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BoostAllTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BoostAllTest.java index a973dd2449d..2086c722e93 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BoostAllTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BoostAllTest.java @@ -59,4 +59,27 @@ public class BoostAllTest extends CardTestPlayerBase { } + @Test + public void testTribalUnity() { + // Creatures of the chosen type get +X/+X + addCard(Zone.HAND, playerA, "Tribal Unity", 1); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); + addCard(Zone.BATTLEFIELD, playerA, "Akki Blizzard-Herder", 1); // 1/1 + addCard(Zone.BATTLEFIELD, playerA, "Bloom Tender", 1); // 1/1 + addCard(Zone.BATTLEFIELD, playerB, "Akki Blizzard-Herder", 1); // 1/1 + addCard(Zone.BATTLEFIELD, playerB, "Bloom Tender", 1); // 1/1 + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Tribal Unity"); + setChoice(playerA, "X=2"); + setChoice(playerA, "Elf"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + + assertPowerToughness(playerA, "Akki Blizzard-Herder", 1, 1); + assertPowerToughness(playerA, "Bloom Tender", 3, 3); + assertPowerToughness(playerB, "Akki Blizzard-Herder", 1, 1); + assertPowerToughness(playerB, "Bloom Tender", 3, 3); + } } From d812ce8fb476453840894dc5bda6c0ee73888cc2 Mon Sep 17 00:00:00 2001 From: Samuel Sandeen Date: Sun, 24 Jul 2016 18:02:37 -0400 Subject: [PATCH 4/5] Fix Spelling --- .../org/mage/test/cards/continuous/ElvishArchdruidTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java index 49579ef49e3..2658ad4ac87 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java @@ -42,7 +42,7 @@ public class ElvishArchdruidTest extends CardTestPlayerBase { /** * Elvish Archdruid gives +1/+1 to Nettle Sentinel * If Archdruid dies and Nettle Sentinel has got 2 damage - * Nettle Sentile must go to graveyard immedeately + * Nettle Sentinel must go to graveyard immediately */ @Test public void testBoostWithUndying() { From 68e84d9c23fa73fb234c440278be4c872baaa063 Mon Sep 17 00:00:00 2001 From: Samuel Sandeen Date: Sun, 24 Jul 2016 22:07:04 -0400 Subject: [PATCH 5/5] Modify the way some second targets are chosen If implemented the wrong way when you try to choose second targets the game can get into an impossible state this fixes three such cards. --- .../mage/sets/darkascension/BloodFeud.java | 40 ++++--------- .../mage/sets/dissension/SimicGuildmage.java | 56 +++++++++++------- .../src/mage/sets/gatecrash/Bioshift.java | 58 ++++++++++++------- 3 files changed, 82 insertions(+), 72 deletions(-) diff --git a/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java b/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java index 038e1262a81..ce9e8d2015e 100644 --- a/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java +++ b/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java @@ -33,6 +33,8 @@ import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.common.FightTargetsEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.target.common.TargetCreaturePermanent; @@ -46,11 +48,18 @@ public class BloodFeud extends CardImpl { super(ownerId, 83, "Blood Feud", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{4}{R}{R}"); this.expansionSetCode = "DKA"; - // Target creature fights another target creature. this.getSpellAbility().addEffect(new FightTargetsEffect()); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); - this.getSpellAbility().addTarget(new TargetOtherCreaturePermanent()); + + TargetCreaturePermanent target = new TargetCreaturePermanent(); + target.setTargetTag(1); + this.getSpellAbility().addTarget(target); + + FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature to fight"); + filter.add(new AnotherTargetPredicate(2)); + TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter); + target2.setTargetTag(2); + this.getSpellAbility().addTarget(target2); } public BloodFeud(final BloodFeud card) { @@ -62,28 +71,3 @@ public class BloodFeud extends CardImpl { return new BloodFeud(this); } } - -class TargetOtherCreaturePermanent extends TargetCreaturePermanent { - - public TargetOtherCreaturePermanent() { - super(); - } - - public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) { - super(target); - } - - @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - if (source.getTargets().get(0).getTargets().contains(id)) { - return false; - } - return super.canTarget(controllerId, id, source, game); - } - - @Override - public TargetOtherCreaturePermanent copy() { - return new TargetOtherCreaturePermanent(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java b/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java index 48fd120a3a0..9cdc034680d 100644 --- a/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java +++ b/Mage.Sets/src/mage/sets/dissension/SimicGuildmage.java @@ -29,6 +29,7 @@ package mage.sets.dissension; import java.util.UUID; import mage.MageInt; +import mage.MageItem; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -43,12 +44,16 @@ import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterEnchantmentPermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.filter.predicate.permanent.PermanentIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; import mage.players.Player; import mage.target.Target; import mage.target.TargetPermanent; @@ -76,8 +81,18 @@ public class SimicGuildmage extends CardImpl { // {1}{G}: Move a +1/+1 counter from target creature onto another target creature with the same controller. Ability countersAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveCounterFromTargetToTargetEffect(), new ManaCostsImpl("{1}{G}")); - countersAbility.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (you take counters from)"))); - countersAbility.addTarget(new SimicGuildmageSecondTargetCreaturePermanent()); + TargetCreaturePermanent target = new TargetCreaturePermanent( + new FilterCreaturePermanent("creature (you take counter from)")); + target.setTargetTag(1); + countersAbility.addTarget(target); + + FilterCreaturePermanent filter = new FilterCreaturePermanent( + "another target creature with the same controller (counter goes to)"); + filter.add(new AnotherTargetPredicate(2)); + filter.add(new SameControllerPredicate()); + TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter); + target2.setTargetTag(2); + countersAbility.addTarget(target2); this.addAbility(countersAbility); // {1}{U}: Attach target Aura enchanting a permanent to another permanent with the same controller. Ability auraAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveAuraEffect(), new ManaCostsImpl("{1}{U}")); @@ -134,34 +149,31 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { } } -class SimicGuildmageSecondTargetCreaturePermanent extends TargetCreaturePermanent { - - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another target creature with the same controller (counters go to)"); - - SimicGuildmageSecondTargetCreaturePermanent() { - super(filter); - } - - SimicGuildmageSecondTargetCreaturePermanent(final SimicGuildmageSecondTargetCreaturePermanent target) { - super(target); - } +class SameControllerPredicate implements ObjectSourcePlayerPredicate> { @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - Permanent firstPermanent = game.getPermanent(source.getTargets().getFirstTarget()); - Permanent secondPermanent = game.getPermanent(id); - if (firstPermanent != null && secondPermanent != null) { - if (!firstPermanent.getId().equals(id) && firstPermanent.getControllerId().equals(secondPermanent.getControllerId())) { - return super.canTarget(controllerId, id, source, game); + public boolean apply(ObjectSourcePlayer input, Game game) { + StackObject source = game.getStack().getStackObject(input.getSourceId()); + if (source != null) { + if (source.getStackAbility().getTargets().isEmpty() + || source.getStackAbility().getTargets().get(0).getTargets().isEmpty()) { + return true; + } + Permanent firstTarget = game.getPermanent( + source.getStackAbility().getTargets().get(0).getTargets().get(0)); + Permanent inputPermanent = game.getPermanent(input.getObject().getId()); + if (firstTarget != null && inputPermanent != null) { + return firstTarget.getControllerId().equals(inputPermanent.getControllerId()); } } - return false; + return true; } @Override - public SimicGuildmageSecondTargetCreaturePermanent copy() { - return new SimicGuildmageSecondTargetCreaturePermanent(this); + public String toString() { + return "Target with the same controller"; } + } class MoveAuraEffect extends OneShotEffect { diff --git a/Mage.Sets/src/mage/sets/gatecrash/Bioshift.java b/Mage.Sets/src/mage/sets/gatecrash/Bioshift.java index 961692cad43..bb89a69a921 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/Bioshift.java +++ b/Mage.Sets/src/mage/sets/gatecrash/Bioshift.java @@ -28,6 +28,7 @@ package mage.sets.gatecrash; import java.util.UUID; +import mage.MageItem; import mage.constants.CardType; import mage.constants.Rarity; @@ -37,9 +38,14 @@ import mage.cards.CardImpl; import mage.constants.Outcome; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; import mage.players.Player; +import mage.target.Target; import mage.target.common.TargetCreaturePermanent; /** @@ -54,8 +60,19 @@ public class Bioshift extends CardImpl { // Move any number of +1/+1 counters from target creature onto another target creature with the same controller. getSpellAbility().addEffect(new MoveCounterFromTargetToTargetEffect()); - getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (you take counters from)"))); - getSpellAbility().addTarget(new BioshiftSecondTargetCreaturePermanent()); + + TargetCreaturePermanent target = new TargetCreaturePermanent( + new FilterCreaturePermanent("creature (you take counters from)")); + target.setTargetTag(1); + this.getSpellAbility().addTarget(target); + + FilterCreaturePermanent filter = new FilterCreaturePermanent( + "another target creature with the same controller (counters go to)"); + filter.add(new AnotherTargetPredicate(2)); + filter.add(new SameControllerPredicate()); + TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter); + target2.setTargetTag(2); + this.getSpellAbility().addTarget(target2); } @@ -112,32 +129,29 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { } } -class BioshiftSecondTargetCreaturePermanent extends TargetCreaturePermanent { - - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another target creature with the same controller (counters go to)"); - - BioshiftSecondTargetCreaturePermanent() { - super(filter); - } - - BioshiftSecondTargetCreaturePermanent(final BioshiftSecondTargetCreaturePermanent target) { - super(target); - } +class SameControllerPredicate implements ObjectSourcePlayerPredicate> { @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - Permanent firstPermanent = game.getPermanent(source.getTargets().getFirstTarget()); - Permanent secondPermanent = game.getPermanent(id); - if (firstPermanent != null && secondPermanent != null) { - if (!firstPermanent.getId().equals(id) && firstPermanent.getControllerId().equals(secondPermanent.getControllerId())) { - return super.canTarget(controllerId, id, source, game); + public boolean apply(ObjectSourcePlayer input, Game game) { + StackObject source = game.getStack().getStackObject(input.getSourceId()); + if (source != null) { + if (source.getStackAbility().getTargets().isEmpty() + || source.getStackAbility().getTargets().get(0).getTargets().isEmpty()) { + return true; + } + Permanent firstTarget = game.getPermanent( + source.getStackAbility().getTargets().get(0).getTargets().get(0)); + Permanent inputPermanent = game.getPermanent(input.getObject().getId()); + if (firstTarget != null && inputPermanent != null) { + return firstTarget.getControllerId().equals(inputPermanent.getControllerId()); } } - return false; + return true; } @Override - public BioshiftSecondTargetCreaturePermanent copy() { - return new BioshiftSecondTargetCreaturePermanent(this); + public String toString() { + return "Target with the same controller"; } + }