From c96d63c734a0ca78f04e8cd6c061e1f54c63d738 Mon Sep 17 00:00:00 2001 From: Thomas Contis Date: Tue, 24 Apr 2018 19:48:20 -0400 Subject: [PATCH 1/3] Implemented Cephalid Snitch (Torment) --- .../src/mage/cards/c/CephalidSnitch.java | 73 +++++++++++++++++++ Mage.Sets/src/mage/sets/Torment.java | 1 + 2 files changed, 74 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CephalidSnitch.java diff --git a/Mage.Sets/src/mage/cards/c/CephalidSnitch.java b/Mage.Sets/src/mage/cards/c/CephalidSnitch.java new file mode 100644 index 00000000000..fc328edb8bc --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CephalidSnitch.java @@ -0,0 +1,73 @@ +/* + * 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.c; + +import java.util.UUID; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.ProtectionAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author tcontis + */ +public class CephalidSnitch extends CardImpl { + + public CephalidSnitch(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + this.subtype.add(SubType.CEPHALID); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Sacrifice Cephalid Snitch: Target creature loses protection from black until end of turn. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseAbilityTargetEffect( + ProtectionAbility.from(ObjectColor.BLACK), Duration.EndOfTurn), new SacrificeSourceCost()); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public CephalidSnitch(final CephalidSnitch card) { + super(card); + } + + @Override + public CephalidSnitch copy() { + return new CephalidSnitch(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Torment.java b/Mage.Sets/src/mage/sets/Torment.java index 8bb64ddaf9f..6d69b7240b0 100644 --- a/Mage.Sets/src/mage/sets/Torment.java +++ b/Mage.Sets/src/mage/sets/Torment.java @@ -77,6 +77,7 @@ public class Torment extends ExpansionSet { cards.add(new SetCardInfo("Cephalid Aristocrat", 27, Rarity.COMMON, mage.cards.c.CephalidAristocrat.class)); cards.add(new SetCardInfo("Cephalid Illusionist", 28, Rarity.UNCOMMON, mage.cards.c.CephalidIllusionist.class)); cards.add(new SetCardInfo("Cephalid Sage", 29, Rarity.UNCOMMON, mage.cards.c.CephalidSage.class)); + cards.add(new SetCardInfo("Cephalid Snitch", 30, Rarity.COMMON, mage.cards.c.CephalidSnitch.class)); cards.add(new SetCardInfo("Cephalid Vandal", 31, Rarity.RARE, mage.cards.c.CephalidVandal.class)); cards.add(new SetCardInfo("Chainer, Dementia Master", 56, Rarity.RARE, mage.cards.c.ChainerDementiaMaster.class)); cards.add(new SetCardInfo("Chainer's Edict", 57, Rarity.UNCOMMON, mage.cards.c.ChainersEdict.class)); From a0adf23765299708ccef92ea98638d4ce1e8f925 Mon Sep 17 00:00:00 2001 From: Thomas Contis Date: Tue, 24 Apr 2018 19:48:20 -0400 Subject: [PATCH 2/3] Implemented Cephalid Snitch (Torment) --- .../src/mage/cards/c/CephalidSnitch.java | 73 +++++++++++++++++++ Mage.Sets/src/mage/sets/Torment.java | 1 + 2 files changed, 74 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CephalidSnitch.java diff --git a/Mage.Sets/src/mage/cards/c/CephalidSnitch.java b/Mage.Sets/src/mage/cards/c/CephalidSnitch.java new file mode 100644 index 00000000000..fc328edb8bc --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CephalidSnitch.java @@ -0,0 +1,73 @@ +/* + * 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.c; + +import java.util.UUID; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.ProtectionAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author tcontis + */ +public class CephalidSnitch extends CardImpl { + + public CephalidSnitch(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + this.subtype.add(SubType.CEPHALID); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Sacrifice Cephalid Snitch: Target creature loses protection from black until end of turn. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseAbilityTargetEffect( + ProtectionAbility.from(ObjectColor.BLACK), Duration.EndOfTurn), new SacrificeSourceCost()); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public CephalidSnitch(final CephalidSnitch card) { + super(card); + } + + @Override + public CephalidSnitch copy() { + return new CephalidSnitch(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Torment.java b/Mage.Sets/src/mage/sets/Torment.java index 8bb64ddaf9f..6d69b7240b0 100644 --- a/Mage.Sets/src/mage/sets/Torment.java +++ b/Mage.Sets/src/mage/sets/Torment.java @@ -77,6 +77,7 @@ public class Torment extends ExpansionSet { cards.add(new SetCardInfo("Cephalid Aristocrat", 27, Rarity.COMMON, mage.cards.c.CephalidAristocrat.class)); cards.add(new SetCardInfo("Cephalid Illusionist", 28, Rarity.UNCOMMON, mage.cards.c.CephalidIllusionist.class)); cards.add(new SetCardInfo("Cephalid Sage", 29, Rarity.UNCOMMON, mage.cards.c.CephalidSage.class)); + cards.add(new SetCardInfo("Cephalid Snitch", 30, Rarity.COMMON, mage.cards.c.CephalidSnitch.class)); cards.add(new SetCardInfo("Cephalid Vandal", 31, Rarity.RARE, mage.cards.c.CephalidVandal.class)); cards.add(new SetCardInfo("Chainer, Dementia Master", 56, Rarity.RARE, mage.cards.c.ChainerDementiaMaster.class)); cards.add(new SetCardInfo("Chainer's Edict", 57, Rarity.UNCOMMON, mage.cards.c.ChainersEdict.class)); From 4ec5563bc6881bc138d119b16edd82ff06f8c4ac Mon Sep 17 00:00:00 2001 From: Thomas Contis Date: Sat, 28 Apr 2018 22:13:59 -0400 Subject: [PATCH 3/3] Beginning of proper implementation of Cephalid Snitch Methods --- .../src/mage/cards/c/CephalidSnitch.java | 96 ++++++++++++++++++- .../abilities/keyword/ProtectionAbility.java | 8 ++ 2 files changed, 101 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CephalidSnitch.java b/Mage.Sets/src/mage/cards/c/CephalidSnitch.java index fc328edb8bc..b588ca8f387 100644 --- a/Mage.Sets/src/mage/cards/c/CephalidSnitch.java +++ b/Mage.Sets/src/mage/cards/c/CephalidSnitch.java @@ -27,19 +27,35 @@ */ package mage.cards.c; -import java.util.UUID; +import java.awt.*; +import java.util.*; +import java.util.List; + import mage.MageInt; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.ProtectionAbility; +import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; +import mage.filter.Filter; +import mage.filter.FilterCard; +import mage.filter.FilterObject; +import mage.filter.predicate.Predicate; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.common.TargetCreaturePermanent; /** @@ -56,8 +72,7 @@ public class CephalidSnitch extends CardImpl { this.toughness = new MageInt(1); // Sacrifice Cephalid Snitch: Target creature loses protection from black until end of turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseAbilityTargetEffect( - ProtectionAbility.from(ObjectColor.BLACK), Duration.EndOfTurn), new SacrificeSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CephalidSnitchEffect(), new SacrificeSourceCost()); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } @@ -71,3 +86,78 @@ public class CephalidSnitch extends CardImpl { return new CephalidSnitch(this); } } +class CephalidSnitchEffect extends LoseAbilityTargetEffect{ + + public CephalidSnitchEffect() { + super(ProtectionAbility.from(ObjectColor.BLACK), Duration.EndOfTurn); + staticText = "Target creature loses protection from black until end of turn."; + } + + public CephalidSnitchEffect(final CephalidSnitchEffect effect) { + super(effect); + } + + @Override + public CephalidSnitchEffect copy() { + return new CephalidSnitchEffect(this); + } + + public String filterNameAssembler(List unsortedColors) { + //Order colors properly by WUBRG (skipping black of course) and construct string to be displayed for ability. + List colors = new ArrayList<>(); + if(unsortedColors.contains(ObjectColor.WHITE)){ + colors.add(ObjectColor.WHITE); + } + if(unsortedColors.contains(ObjectColor.BLUE)){ + colors.add(ObjectColor.BLUE); + } + if(unsortedColors.contains(ObjectColor.RED)){ + colors.add(ObjectColor.RED); + } + if(unsortedColors.contains(ObjectColor.GREEN)){ + colors.add(ObjectColor.GREEN); + } + if (colors.size() == 1) { + return colors.get(0).getDescription(); + } else if (colors.size() == 2) { + return colors.get(0).getDescription() + " and from " + colors.get(1).getDescription(); + } else if (colors.size() == 3) { + return colors.get(0).getDescription() + ", from " + colors.get(1).getDescription() + " and from " + colors.get(2).getDescription(); + } else if (colors.size() == 4) { + return colors.get(0).getDescription() + ", from " + colors.get(1).getDescription() + ", from " + colors.get(2).getDescription() + " and from " + colors.get(3).getDescription(); + } + return ""; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source)); + if (targetCreature != null) { + + //Go through protection abilities and sort out any containing black, then record the colors other than black + for(ProtectionAbility a: targetCreature.getAbilities().getProtectionAbilities()) { + List objectColors = new ArrayList<>(); + if(a.getColors().contains(ObjectColor.BLACK)) + for (ObjectColor o : a.getColors()) { + if (!objectColors.contains(o) && !o.isBlack()) + objectColors.add(o); + } + //Construct a card filter excluding black + if(objectColors.size() > 0) { + FilterCard filter = new FilterCard(filterNameAssembler(objectColors)); + if (objectColors.size() == 1) + filter.add(new ColorPredicate(objectColors.get(0))); + else if (objectColors.size() == 2) + filter.add(Predicates.or(new ColorPredicate(objectColors.get(0)), new ColorPredicate(objectColors.get(1)))); + else if (objectColors.size() == 3) + filter.add(Predicates.or(new ColorPredicate(objectColors.get(0)), new ColorPredicate(objectColors.get(1)), new ColorPredicate(objectColors.get(2)))); + else if (objectColors.size() == 4) + filter.add(Predicates.or(new ColorPredicate(objectColors.get(0)), new ColorPredicate(objectColors.get(1)), new ColorPredicate(objectColors.get(2)), new ColorPredicate(objectColors.get(3)))); + a.setFilter(filter); + } + } + return true; + } + return false; + } +} \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java b/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java index 46471af292f..06161120043 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java @@ -27,6 +27,8 @@ */ package mage.abilities.keyword; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import mage.MageObject; import mage.ObjectColor; @@ -53,6 +55,7 @@ public class ProtectionAbility extends StaticAbility { protected Filter filter; protected boolean removeAuras; + protected static List objectColors = new ArrayList<>(); protected UUID auraIdNotToBeRemoved; // defines an Aura objectId that will not be removed from this protection ability public ProtectionAbility(Filter filter) { @@ -72,12 +75,15 @@ public class ProtectionAbility extends StaticAbility { public static ProtectionAbility from(ObjectColor color) { FilterObject filter = new FilterObject(color.getDescription()); filter.add(new ColorPredicate(color)); + objectColors.add(color); return new ProtectionAbility(filter); } public static ProtectionAbility from(ObjectColor color1, ObjectColor color2) { FilterObject filter = new FilterObject(color1.getDescription() + " and from " + color2.getDescription()); filter.add(Predicates.or(new ColorPredicate(color1), new ColorPredicate(color2))); + objectColors.add(color1); + objectColors.add(color2); return new ProtectionAbility(filter); } @@ -140,6 +146,8 @@ public class ProtectionAbility extends StaticAbility { return removeAuras; } + public List getColors() { return objectColors; } + public UUID getAuraIdNotToBeRemoved() { return auraIdNotToBeRemoved; }