From df07c7fa0c0f6a6d4809f83b0453bb594ea9873e Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 12 Aug 2017 20:54:53 -0400 Subject: [PATCH 1/3] Created Kindred Dominance --- .../src/mage/cards/k/KindredDominance.java | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/k/KindredDominance.java diff --git a/Mage.Sets/src/mage/cards/k/KindredDominance.java b/Mage.Sets/src/mage/cards/k/KindredDominance.java new file mode 100644 index 0000000000..ffe3feb76b --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KindredDominance.java @@ -0,0 +1,112 @@ +/* + * 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.cards.k; + +import java.util.UUID; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.Choice; +import mage.choices.ChoiceCreatureType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author caldover + */ +public class KindredDominance extends CardImpl { + + public KindredDominance(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{B}{B}"); + + // Choose a creature type. Destroy all creatures that are not the chosen type. + this.getSpellAbility().addEffect(new KindredDominanceEffect()); + } + + public KindredDominance(final KindredDominance card) { + super(card); + } + + @Override + public KindredDominance copy() { + return new KindredDominance(this); + } +} + +class KindredDominanceEffect extends OneShotEffect { + + public KindredDominanceEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "Choose a creature type. Destroy all creatures that are not the chosen type."; + } + + public KindredDominanceEffect(final KindredDominanceEffect effect) { + super(effect); + } + + @Override + public KindredDominanceEffect copy() { + return new KindredDominanceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null) { + Choice typeChoice = new ChoiceCreatureType(); + while (!controller.choose(outcome, typeChoice, game)) { + if (!controller.canRespond()) { + return false; + } + } + if (typeChoice.getChoice() != null) { + game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); + } + + FilterPermanent filter = new FilterCreaturePermanent("creatures"); + + filter.add(Predicates.not(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())))); + + return new DestroyAllEffect(filter).apply(game, source); + } + return false; + } +} \ No newline at end of file From 4838ad7e7a075e8b2237037a793c6def6a648b1a Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 14 Aug 2017 15:22:01 -0400 Subject: [PATCH 2/3] Added Kindred Dominance to Commander 2017 Set --- Mage.Sets/src/mage/sets/Commander2017.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage.Sets/src/mage/sets/Commander2017.java b/Mage.Sets/src/mage/sets/Commander2017.java index 5ec6660fc6..a4ccf09a4a 100644 --- a/Mage.Sets/src/mage/sets/Commander2017.java +++ b/Mage.Sets/src/mage/sets/Commander2017.java @@ -59,6 +59,7 @@ public class Commander2017 extends ExpansionSet { cards.add(new SetCardInfo("Teferi's Protection", 8, Rarity.RARE, mage.cards.t.TeferisProtection.class)); cards.add(new SetCardInfo("Traverse the Outlands", 34, Rarity.RARE, mage.cards.t.TraverseTheOutlands.class)); cards.add(new SetCardInfo("Wasitora, Nekoru Queen", 49, Rarity.MYTHIC, mage.cards.w.WasitoraNekoruQueen.class)); + cards.add(new SetCardInfo("Kindred Dominance", 18, Rarity.RARE, mage.cards.k.KindredDominance.class)); } } From 75712661de32710dad0254987f6ba55217ca5315 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 14 Aug 2017 16:08:35 -0400 Subject: [PATCH 3/3] Updated Kindred Dominance with better code reuse --- .../src/mage/cards/k/KindredDominance.java | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Mage.Sets/src/mage/cards/k/KindredDominance.java b/Mage.Sets/src/mage/cards/k/KindredDominance.java index ffe3feb76b..0ef55d288c 100644 --- a/Mage.Sets/src/mage/cards/k/KindredDominance.java +++ b/Mage.Sets/src/mage/cards/k/KindredDominance.java @@ -32,11 +32,10 @@ import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.abilities.effects.common.DestroyAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.choices.Choice; -import mage.choices.ChoiceCreatureType; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; @@ -57,6 +56,7 @@ public class KindredDominance extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{B}{B}"); // Choose a creature type. Destroy all creatures that are not the chosen type. + this.getSpellAbility().addEffect(new ChooseCreatureTypeEffect(Outcome.DestroyPermanent)); this.getSpellAbility().addEffect(new KindredDominanceEffect()); } @@ -74,7 +74,7 @@ class KindredDominanceEffect extends OneShotEffect { public KindredDominanceEffect() { super(Outcome.DestroyPermanent); - this.staticText = "Choose a creature type. Destroy all creatures that are not the chosen type."; + this.staticText = " Destroy all creatures that are not the chosen type."; } public KindredDominanceEffect(final KindredDominanceEffect effect) { @@ -89,22 +89,11 @@ class KindredDominanceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null) { - Choice typeChoice = new ChoiceCreatureType(); - while (!controller.choose(outcome, typeChoice, game)) { - if (!controller.canRespond()) { - return false; - } - } - if (typeChoice.getChoice() != null) { - game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice()); - } - + MageObject mageObject = game.getObject(source.getSourceId()); + if (controller != null & mageObject != null) { + String creatureType = game.getState().getValue(mageObject.getId() + "_type").toString(); FilterPermanent filter = new FilterCreaturePermanent("creatures"); - - filter.add(Predicates.not(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())))); - + filter.add(Predicates.not(new SubtypePredicate(SubType.byDescription(creatureType)))); return new DestroyAllEffect(filter).apply(game, source); } return false;