diff --git a/Mage.Sets/src/mage/cards/c/CommonCause.java b/Mage.Sets/src/mage/cards/c/CommonCause.java new file mode 100644 index 0000000000..ed85ca4dd5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CommonCause.java @@ -0,0 +1,92 @@ +/* + * 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.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.continuous.BoostAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author TheElk801 + */ +public class CommonCause extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Nonartifact creatures"); + + static { + filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT))); + } + + public CommonCause(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); + + // Nonartifact creatures get +2/+2 as long as they all share a color. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BoostAllEffect(2, 2, Duration.WhileOnBattlefield, filter, false), + new AllColorCondition(), + "nonartifact creatures get +2/+2 as long as they all share a color."))); + } + + public CommonCause(final CommonCause card) { + super(card); + } + + @Override + public CommonCause copy() { + return new CommonCause(this); + } +} + +class AllColorCondition implements Condition { + + @Override + public boolean apply(Game game, Ability source) { + FilterCreaturePermanent filter = new FilterCreaturePermanent("Nonartifact creatures"); + filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT))); +// Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); + ObjectColor allColor = new ObjectColor("WUBRG"); + for (Permanent thing : game.getBattlefield().getAllActivePermanents(filter, game)) { + allColor = allColor.intersection(thing.getColor(game)); + } + return !allColor.isColorless(); + } +} diff --git a/Mage.Sets/src/mage/cards/s/SecondSight.java b/Mage.Sets/src/mage/cards/s/SecondSight.java index 7072618f1b..4605a50952 100644 --- a/Mage.Sets/src/mage/cards/s/SecondSight.java +++ b/Mage.Sets/src/mage/cards/s/SecondSight.java @@ -119,7 +119,7 @@ class SecondSightEffect extends OneShotEffect { } } - you.lookAtCards("Portent", cards, game); + you.lookAtCards("Second Sight", cards, game); TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on the top of target player's library")); while (player.canRespond() && cards.size() > 1) { diff --git a/Mage.Sets/src/mage/sets/MercadianMasques.java b/Mage.Sets/src/mage/sets/MercadianMasques.java index bca03b6c04..d1f83f78c8 100644 --- a/Mage.Sets/src/mage/sets/MercadianMasques.java +++ b/Mage.Sets/src/mage/sets/MercadianMasques.java @@ -97,6 +97,7 @@ public class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("Cloud Sprite", 67, Rarity.COMMON, mage.cards.c.CloudSprite.class)); cards.add(new SetCardInfo("Coastal Piracy", 68, Rarity.UNCOMMON, mage.cards.c.CoastalPiracy.class)); cards.add(new SetCardInfo("Collective Unconscious", 236, Rarity.RARE, mage.cards.c.CollectiveUnconscious.class)); + cards.add(new SetCardInfo("Common Cause", 13, Rarity.RARE, mage.cards.c.CommonCause.class)); cards.add(new SetCardInfo("Conspiracy", 127, Rarity.RARE, mage.cards.c.Conspiracy.class)); cards.add(new SetCardInfo("Corrupt Official", 128, Rarity.RARE, mage.cards.c.CorruptOfficial.class)); cards.add(new SetCardInfo("Counterspell", 69, Rarity.COMMON, mage.cards.c.Counterspell.class)); diff --git a/Mage/src/main/java/mage/ObjectColor.java b/Mage/src/main/java/mage/ObjectColor.java index c0f019be4a..594a5977c7 100644 --- a/Mage/src/main/java/mage/ObjectColor.java +++ b/Mage/src/main/java/mage/ObjectColor.java @@ -99,6 +99,23 @@ public class ObjectColor implements Serializable, Copyable, Compara return newColor; } + /** + * Returns a new color which contains the intersection of the colors of this + * ObjectColor and the other ObjectColor. + * + * @param other The other ObjectColor to intersect with + * @return A new color which is the intersection of this and other + */ + public ObjectColor intersection(ObjectColor other) { + ObjectColor newColor = new ObjectColor(); + newColor.white = white && other.white; + newColor.blue = blue && other.blue; + newColor.black = black && other.black; + newColor.red = red && other.red; + newColor.green = green && other.green; + return newColor; + } + public int getColorCount() { int count = 0; if (white) {