diff --git a/Mage.Sets/src/mage/sets/conflux/AvenTrailblazer.java b/Mage.Sets/src/mage/sets/conflux/AvenTrailblazer.java new file mode 100644 index 00000000000..a834ec365f7 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/AvenTrailblazer.java @@ -0,0 +1,109 @@ +/* + * 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.conflux; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.common.DomainValue; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.SubLayer; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author jeffwadsworth + */ +public class AvenTrailblazer extends CardImpl { + + public AvenTrailblazer(UUID ownerId) { + super(ownerId, 4, "Aven Trailblazer", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{W}"); + this.expansionSetCode = "CON"; + this.subtype.add("Bird"); + this.subtype.add("Soldier"); + + this.color.setWhite(true); + this.power = new MageInt(2); + this.toughness = new MageInt(0); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Domain - Aven Trailblazer's toughness is equal to the number of basic land types among lands you control. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AvenTrailblazerEffect())); + + } + + public AvenTrailblazer(final AvenTrailblazer card) { + super(card); + } + + @Override + public AvenTrailblazer copy() { + return new AvenTrailblazer(this); + } +} + +class AvenTrailblazerEffect extends ContinuousEffectImpl { + + public AvenTrailblazerEffect() { + super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature); + staticText = "{this}'s toughness is equal to the number of basic land types among lands you control"; + } + + public AvenTrailblazerEffect(final AvenTrailblazerEffect effect) { + super(effect); + } + + @Override + public AvenTrailblazerEffect copy() { + return new AvenTrailblazerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int value = (new DomainValue()).calculate(game, source); + Permanent avenTrailblazer = game.getPermanent(source.getSourceId()); + if (avenTrailblazer != null) { + avenTrailblazer.getToughness().setValue(value); + return true; + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/sets/conflux/MarkOfAsylum.java b/Mage.Sets/src/mage/sets/conflux/MarkOfAsylum.java new file mode 100644 index 00000000000..2a8480ddd84 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/MarkOfAsylum.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.sets.conflux; + +import java.util.UUID; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.PreventAllNonCombatDamageToEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.common.FilterControlledCreatureInPlay; +import mage.filter.predicate.permanent.ControllerPredicate; + +/** + * + * @author jeffwadsworth + */ +public class MarkOfAsylum extends CardImpl { + + private static final FilterControlledCreatureInPlay filter = new FilterControlledCreatureInPlay("creatures you control"); + + static { + filter.getCreatureFilter().add(new ControllerPredicate(TargetController.YOU)); + } + + public MarkOfAsylum(UUID ownerId) { + super(ownerId, 10, "Mark of Asylum", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.expansionSetCode = "CON"; + + this.color.setWhite(true); + + // Prevent all noncombat damage that would be dealt to creatures you control. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllNonCombatDamageToEffect(Duration.WhileOnBattlefield, filter))); + + } + + public MarkOfAsylum(final MarkOfAsylum card) { + super(card); + } + + @Override + public MarkOfAsylum copy() { + return new MarkOfAsylum(this); + } +} diff --git a/Mage.Sets/src/mage/sets/conflux/MirrorSigilSergeant.java b/Mage.Sets/src/mage/sets/conflux/MirrorSigilSergeant.java new file mode 100644 index 00000000000..437b65de933 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/MirrorSigilSergeant.java @@ -0,0 +1,134 @@ +/* + * 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.conflux; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.common.ControlsPermanentCondition; +import mage.abilities.decorator.ConditionalTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.sets.tokens.EmptyToken; +import mage.util.CardUtil; + +/** + * + * @author jeffwadsworth + */ +public class MirrorSigilSergeant extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("blue permanent"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLUE)); + } + + private static final String rule = "At the beginning of your upkeep, if you control a blue permanent, you may put a token that's a copy of Mirror-Sigil Sergeant onto the battlefield."; + + public MirrorSigilSergeant(UUID ownerId) { + super(ownerId, 12, "Mirror-Sigil Sergeant", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{5}{W}"); + this.expansionSetCode = "CON"; + this.subtype.add("Rhino"); + this.subtype.add("Soldier"); + + this.color.setWhite(true); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // At the beginning of your upkeep, if you control a blue permanent, you may put a token that's a copy of Mirror-Sigil Sergeant onto the battlefield. + TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new MirrorSigilSergeantEffect(), TargetController.YOU, true); + this.addAbility(new ConditionalTriggeredAbility(ability, new ControlsPermanentCondition(filter), rule)); + + } + + public MirrorSigilSergeant(final MirrorSigilSergeant card) { + super(card); + } + + @Override + public MirrorSigilSergeant copy() { + return new MirrorSigilSergeant(this); + } +} + +class MirrorSigilSergeantEffect extends OneShotEffect { + + public MirrorSigilSergeantEffect() { + super(Outcome.PutCreatureInPlay); + this.staticText = "put a token that's a copy of {this} onto the battlefield"; + } + + public MirrorSigilSergeantEffect(final MirrorSigilSergeantEffect effect) { + super(effect); + } + + @Override + public MirrorSigilSergeantEffect copy() { + return new MirrorSigilSergeantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + UUID targetId = source.getSourceId(); + if (targetId != null && player != null) { + MageObject target = game.getPermanent(targetId); + if (target == null) { + target = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); + } + if (target != null) { + if (target instanceof Permanent) { + EmptyToken token = new EmptyToken(); + CardUtil.copyTo(token).from((Permanent) target); + token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); + return true; + } + } + } + return false; + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/conditional/MirrorSigilSergeantTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/conditional/MirrorSigilSergeantTest.java new file mode 100644 index 00000000000..dd0b2c88245 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/conditional/MirrorSigilSergeantTest.java @@ -0,0 +1,51 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.conditional; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author jeffwadsworth + */ +public class MirrorSigilSergeantTest extends CardTestPlayerBase { + + @Test + public void testTokenEffect() { + + addCard(Zone.BATTLEFIELD, playerA, "Mirror-Sigil Sergeant"); + addCard(Zone.BATTLEFIELD, playerA, "Merfolk Spy"); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 10); + + addCard(Zone.LIBRARY, playerB, "Plains"); + addCard(Zone.BATTLEFIELD, playerB, "Memnite"); + + setStopAt(2, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Mirror-Sigil Sergeant", 2); + + } + + @Test + public void testTokenEffect2() { + + addCard(Zone.BATTLEFIELD, playerA, "Mirror-Sigil Sergeant"); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 10); + + addCard(Zone.LIBRARY, playerB, "Plains"); + addCard(Zone.BATTLEFIELD, playerB, "Memnite"); + + setStopAt(2, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Mirror-Sigil Sergeant", 1); + + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/AvenTrailblazerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/AvenTrailblazerTest.java new file mode 100644 index 00000000000..ebe379ebc0c --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/AvenTrailblazerTest.java @@ -0,0 +1,36 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.continuous; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author Jeff + */ +public class AvenTrailblazerTest extends CardTestPlayerBase { + + @Test + public void testAvenTrailblazerEffect() { + + addCard(Zone.HAND, playerA, "Aven Trailblazer"); + addCard(Zone.BATTLEFIELD, playerA, "City of Brass", 6); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); + + addCard(Zone.BATTLEFIELD, playerB, "Plains", 10); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Aven Trailblazer"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPowerToughness(playerA, "Aven Trailblazer", 2, 2); + + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/prevention/MarkOfAsylumTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/prevention/MarkOfAsylumTest.java new file mode 100644 index 00000000000..fba8cb1bc7b --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/prevention/MarkOfAsylumTest.java @@ -0,0 +1,38 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.prevention; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author jeffwadsworth + */ +public class MarkOfAsylumTest extends CardTestPlayerBase{ + + @Test + public void testMarkOfAsylumEffect() { + + addCard(Zone.BATTLEFIELD, playerA, "Mark of Asylum"); + addCard(Zone.BATTLEFIELD, playerA, "Memnite"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.HAND, playerA, "Lightning Bolt", 2); + + addCard(Zone.BATTLEFIELD, playerB, "Arbor Elf", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Memnite"); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Arbor Elf"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Memnite", 1); + assertPermanentCount(playerB, "Arbor Elf", 0); + + } +} diff --git a/Mage/src/mage/abilities/effects/PreventAllNonCombatDamageToEffect.java b/Mage/src/mage/abilities/effects/PreventAllNonCombatDamageToEffect.java new file mode 100644 index 00000000000..9baed23a2d9 --- /dev/null +++ b/Mage/src/mage/abilities/effects/PreventAllNonCombatDamageToEffect.java @@ -0,0 +1,99 @@ +/* + * 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; + +import mage.constants.Duration; +import mage.abilities.Ability; +import mage.abilities.effects.PreventionEffectImpl; +import mage.filter.FilterInPlay; +import mage.game.Game; +import mage.game.events.DamageEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author jeffwadsworth + */ +public class PreventAllNonCombatDamageToEffect extends PreventionEffectImpl { + + protected FilterInPlay filter; + + public PreventAllNonCombatDamageToEffect(Duration duration, FilterInPlay filter) { + super(duration); + this.filter = filter; + staticText = "Prevent all non combat damage that would be dealt to " + filter.getMessage() + " " + duration.toString(); + } + + public PreventAllNonCombatDamageToEffect(final PreventAllNonCombatDamageToEffect effect) { + super(effect); + this.filter = effect.filter.copy(); + } + + @Override + public PreventAllNonCombatDamageToEffect copy() { + return new PreventAllNonCombatDamageToEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), damage)); + } + return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (super.applies(event, source, game) + && !((DamageEvent) event).isCombatDamage()) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null) { + if (filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) + return true; + } + else { + Player player = game.getPlayer(event.getTargetId()); + if (player != null && filter.match(player, source.getSourceId(), source.getControllerId(), game)) + return true; + } + } + return false; + } + +} diff --git a/Mage/src/mage/filter/common/FilterControlledCreatureInPlay.java b/Mage/src/mage/filter/common/FilterControlledCreatureInPlay.java new file mode 100644 index 00000000000..8fe09c276f3 --- /dev/null +++ b/Mage/src/mage/filter/common/FilterControlledCreatureInPlay.java @@ -0,0 +1,85 @@ +/* +* 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.filter.common; + +import mage.filter.FilterImpl; +import mage.filter.FilterInPlay; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.UUID; + +/** + * + * @author jeffwadsworth + */ +public class FilterControlledCreatureInPlay extends FilterImpl implements FilterInPlay { + + protected FilterCreaturePermanent creatureFilter; + + public FilterControlledCreatureInPlay() { + this("creature"); + } + + public FilterControlledCreatureInPlay(String name) { + super(name); + creatureFilter = new FilterCreaturePermanent(); + } + + public FilterControlledCreatureInPlay(final FilterControlledCreatureInPlay filter) { + super(filter); + this.creatureFilter = filter.creatureFilter.copy(); + } + + @Override + public boolean match(Object o, Game game) { + if (o instanceof Permanent) { + return creatureFilter.match((Permanent)o, game); + } + return false; + } + + @Override + public boolean match(Object o, UUID sourceId, UUID playerId, Game game) { + if (o instanceof Permanent) { + return creatureFilter.match((Permanent)o, sourceId, playerId, game); + } + return false; + } + + public FilterCreaturePermanent getCreatureFilter() { + return this.creatureFilter; + } + + @Override + public FilterControlledCreatureInPlay copy() { + return new FilterControlledCreatureInPlay(this); + } + +}