From 45862acaee8e8f1907009e1f8a8901afbec77dee Mon Sep 17 00:00:00 2001 From: LoneFox Date: Wed, 9 Sep 2015 12:16:56 +0300 Subject: [PATCH] Implement the Charm cycle from Onslaught --- .../src/mage/sets/onslaught/FeverCharm.java | 83 +++++++++++++++++ .../src/mage/sets/onslaught/MiseryCharm.java | 86 ++++++++++++++++++ .../src/mage/sets/onslaught/PietyCharm.java | 89 ++++++++++++++++++ .../mage/sets/onslaught/TrickeryCharm.java | 74 +++++++++++++++ .../mage/sets/onslaught/VitalityCharm.java | 91 +++++++++++++++++++ .../permanent/AttachedToPredicate.java | 59 ++++++++++++ 6 files changed, 482 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/onslaught/FeverCharm.java create mode 100644 Mage.Sets/src/mage/sets/onslaught/MiseryCharm.java create mode 100644 Mage.Sets/src/mage/sets/onslaught/PietyCharm.java create mode 100644 Mage.Sets/src/mage/sets/onslaught/TrickeryCharm.java create mode 100644 Mage.Sets/src/mage/sets/onslaught/VitalityCharm.java create mode 100644 Mage/src/mage/filter/predicate/permanent/AttachedToPredicate.java diff --git a/Mage.Sets/src/mage/sets/onslaught/FeverCharm.java b/Mage.Sets/src/mage/sets/onslaught/FeverCharm.java new file mode 100644 index 0000000000..6973791146 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/FeverCharm.java @@ -0,0 +1,83 @@ +/* + * 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; +import mage.abilities.Mode; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LoneFox + */ +public class FeverCharm extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Wizard creature"); + + static { + filter.add(new SubtypePredicate("Wizard")); + } + + public FeverCharm(UUID ownerId) { + super(ownerId, 202, "Fever Charm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{R}"); + this.expansionSetCode = "ONS"; + + // Choose one - Target creature gains haste until end of turn + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + // or target creature gets +2/+0 until end of turn + Mode mode = new Mode(); + mode.getEffects().add(new BoostTargetEffect(2, 0, Duration.EndOfTurn)); + mode.getTargets().add(new TargetCreaturePermanent()); + this.getSpellAbility().addMode(mode); + // or Fever Charm deals 3 damage to target Wizard creature. + mode = new Mode(); + mode.getEffects().add(new DamageTargetEffect(3)); + mode.getTargets().add(new TargetCreaturePermanent(filter)); + this.getSpellAbility().addMode(mode); + } + + public FeverCharm(final FeverCharm card) { + super(card); + } + + @Override + public FeverCharm copy() { + return new FeverCharm(this); + } +} diff --git a/Mage.Sets/src/mage/sets/onslaught/MiseryCharm.java b/Mage.Sets/src/mage/sets/onslaught/MiseryCharm.java new file mode 100644 index 0000000000..d3cbf5e1a7 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/MiseryCharm.java @@ -0,0 +1,86 @@ +/* + * 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; +import mage.abilities.Mode; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.target.TargetPermanent; +import mage.target.TargetPlayer; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author LoneFox + */ +public class MiseryCharm extends CardImpl { + + private static final FilterPermanent filter1 = new FilterPermanent("Cleric"); + private static final FilterCard filter2 = new FilterCard("Cleric card from your graveyard"); + + static { + filter1.add(new SubtypePredicate("Cleric")); + filter2.add(new SubtypePredicate("Cleric")); + } + + public MiseryCharm(UUID ownerId) { + super(ownerId, 158, "Misery Charm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{B}"); + this.expansionSetCode = "ONS"; + + // Choose one - Destroy target Cleric + this.getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter1)); + // or return target Cleric card from your graveyard to your hand + Mode mode = new Mode(); + mode.getEffects().add(new ReturnToHandTargetEffect()); + mode.getTargets().add(new TargetCardInYourGraveyard(filter2)); + this.getSpellAbility().addMode(mode); + // or target player loses 2 life. + mode = new Mode(); + mode.getEffects().add(new LoseLifeTargetEffect(2)); + mode.getTargets().add(new TargetPlayer()); + this.getSpellAbility().addMode(mode); + } + + public MiseryCharm(final MiseryCharm card) { + super(card); + } + + @Override + public MiseryCharm copy() { + return new MiseryCharm(this); + } +} diff --git a/Mage.Sets/src/mage/sets/onslaught/PietyCharm.java b/Mage.Sets/src/mage/sets/onslaught/PietyCharm.java new file mode 100644 index 0000000000..6a0ab78137 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/PietyCharm.java @@ -0,0 +1,89 @@ +/* + * 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; +import mage.abilities.Mode; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityAllEffect; +import mage.abilities.keyword.VigilanceAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.AttachedToPredicate; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LoneFox + */ +public class PietyCharm extends CardImpl { + + private static final FilterPermanent filter1 = new FilterPermanent("Aura attached to a creature"); + private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("Soldier creature"); + + static { + filter1.add(new SubtypePredicate("Aura")); + filter1.add(new AttachedToPredicate(new FilterCreaturePermanent())); + filter2.add(new SubtypePredicate("Soldier")); + } + + public PietyCharm(UUID ownerId) { + super(ownerId, 49, "Piety Charm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}"); + this.expansionSetCode = "ONS"; + + // Choose one - Destroy target Aura attached to a creature + this.getSpellAbility().addEffect(new DestroyTargetEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter1)); + // or target Soldier creature gets +2/+2 until end of turn + Mode mode = new Mode(); + mode.getEffects().add(new BoostTargetEffect(2, 2, Duration.EndOfTurn)); + mode.getTargets().add(new TargetCreaturePermanent(filter2)); + this.getSpellAbility().addMode(mode); + // or creatures you control gain vigilance until end of turn. + mode = new Mode(); + mode.getEffects().add(new GainAbilityAllEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn, new FilterControlledCreaturePermanent("creatures you control"))); + this.getSpellAbility().addMode(mode); + } + + public PietyCharm(final PietyCharm card) { + super(card); + } + + @Override + public PietyCharm copy() { + return new PietyCharm(this); + } +} diff --git a/Mage.Sets/src/mage/sets/onslaught/TrickeryCharm.java b/Mage.Sets/src/mage/sets/onslaught/TrickeryCharm.java new file mode 100644 index 0000000000..5e2251ae6f --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/TrickeryCharm.java @@ -0,0 +1,74 @@ +/* + * 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; +import mage.abilities.Mode; +import mage.abilities.effects.common.LookLibraryControllerEffect; +import mage.abilities.effects.common.continuous.BecomesChosenCreatureTypeTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LoneFox + */ +public class TrickeryCharm extends CardImpl { + + public TrickeryCharm(UUID ownerId) { + super(ownerId, 119, "Trickery Charm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{U}"); + this.expansionSetCode = "ONS"; + + // Choose one - Target creature gains flying until end of turn + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + // or target creature becomes the creature type of your choice until end of turn + Mode mode = new Mode(); + mode.getEffects().add(new BecomesChosenCreatureTypeTargetEffect()); + mode.getTargets().add(new TargetCreaturePermanent()); + this.getSpellAbility().addMode(mode); + // or look at the top four cards of your library, then put them back in any order. + mode = new Mode(); + mode.getEffects().add(new LookLibraryControllerEffect(4)); + this.getSpellAbility().addMode(mode); + } + + public TrickeryCharm(final TrickeryCharm card) { + super(card); + } + + @Override + public TrickeryCharm copy() { + return new TrickeryCharm(this); + } +} diff --git a/Mage.Sets/src/mage/sets/onslaught/VitalityCharm.java b/Mage.Sets/src/mage/sets/onslaught/VitalityCharm.java new file mode 100644 index 0000000000..eee200ea12 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/VitalityCharm.java @@ -0,0 +1,91 @@ +/* + * 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; +import mage.abilities.Mode; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.RegenerateTargetEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.filter.FilterPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.permanent.token.InsectToken; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LoneFox + */ +public class VitalityCharm extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("Beast"); + + static { + filter.add(new SubtypePredicate("Beast")); + } + + public VitalityCharm(UUID ownerId) { + super(ownerId, 296, "Vitality Charm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{G}"); + this.expansionSetCode = "ONS"; + + // Choose one - Put a 1/1 green Insect creature token onto the battlefield + this.getSpellAbility().addEffect(new CreateTokenEffect(new InsectToken())); + // or target creature gets +1/+1 and gains trample until end of turn + Mode mode = new Mode(); + Effect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn); + effect.setText("target creature gets +1/+1"); + mode.getEffects().add(effect); + effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); + effect.setText("and gains trample until end of turn"); + mode.getEffects().add(effect); + mode.getTargets().add(new TargetCreaturePermanent()); + this.getSpellAbility().addMode(mode); + // or regenerate target Beast. + mode = new Mode(); + mode.getEffects().add(new RegenerateTargetEffect()); + mode.getTargets().add(new TargetPermanent(filter)); + this.getSpellAbility().addMode(mode); + } + + public VitalityCharm(final VitalityCharm card) { + super(card); + } + + @Override + public VitalityCharm copy() { + return new VitalityCharm(this); + } +} diff --git a/Mage/src/mage/filter/predicate/permanent/AttachedToPredicate.java b/Mage/src/mage/filter/predicate/permanent/AttachedToPredicate.java new file mode 100644 index 0000000000..7d155ffa14 --- /dev/null +++ b/Mage/src/mage/filter/predicate/permanent/AttachedToPredicate.java @@ -0,0 +1,59 @@ +/* + * 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.predicate.permanent; + +import java.util.UUID; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LoneFox + */ +public class AttachedToPredicate implements Predicate { + + private FilterPermanent filter; + + public AttachedToPredicate(FilterPermanent filter) { + this.filter = filter; + } + + @Override + public boolean apply(Permanent input, Game game) { + UUID attachedTo = input.getAttachedTo(); + return attachedTo != null && filter.match(game.getPermanent(attachedTo), game); + } + + @Override + public String toString() { + return "attached to " + filter.getMessage(); + } + +}