From 956724b5fa48e1bb3c83fb5be417eb1dd272e8da Mon Sep 17 00:00:00 2001 From: Plopman <> Date: Fri, 5 Aug 2016 13:43:23 +0200 Subject: [PATCH] [TMP] Added 5 cards --- .../src/mage/sets/tempest/ColdStorage.java | 111 ++++++++++++ .../src/mage/sets/tempest/ElvenWarhounds.java | 66 ++++++++ .../src/mage/sets/tempest/Excavator.java | 158 ++++++++++++++++++ .../mage/sets/tempest/PhyrexianGrimoire.java | 141 ++++++++++++++++ Mage.Sets/src/mage/sets/tempest/Watchdog.java | 114 +++++++++++++ 5 files changed, 590 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/tempest/ColdStorage.java create mode 100644 Mage.Sets/src/mage/sets/tempest/ElvenWarhounds.java create mode 100644 Mage.Sets/src/mage/sets/tempest/Excavator.java create mode 100644 Mage.Sets/src/mage/sets/tempest/PhyrexianGrimoire.java create mode 100644 Mage.Sets/src/mage/sets/tempest/Watchdog.java diff --git a/Mage.Sets/src/mage/sets/tempest/ColdStorage.java b/Mage.Sets/src/mage/sets/tempest/ColdStorage.java new file mode 100644 index 0000000000..dc9a34e29d --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/ColdStorage.java @@ -0,0 +1,111 @@ +/* + * 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.tempest; + +import java.util.UUID; +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.OneShotEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterCreatureCard; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author Plopman + */ +public class ColdStorage extends CardImpl { + + public ColdStorage(UUID ownerId) { + super(ownerId, 270, "Cold Storage", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}"); + this.expansionSetCode = "TMP"; + + // {3}: Exile target creature you control. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(this.getId(), this.getIdName()), new ManaCostsImpl("{3}")); + ability.addTarget(new TargetControlledCreaturePermanent()); + this.addAbility(ability); + // Sacrifice Cold Storage: Return each creature card exiled with Cold Storage to the battlefield under your control. + ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnFromExileEffect(this.getId()), new SacrificeSourceCost()); + this.addAbility(ability); + } + + public ColdStorage(final ColdStorage card) { + super(card); + } + + @Override + public ColdStorage copy() { + return new ColdStorage(this); + } +} + + +class ReturnFromExileEffect extends OneShotEffect { + + private UUID exileId; + + public ReturnFromExileEffect(UUID exileId) { + super(Outcome.PutCardInPlay); + this.exileId = exileId; + this.setText("Return each creature card exiled with {this} to the battlefield under your control"); + } + + + public ReturnFromExileEffect(final ReturnFromExileEffect effect) { + super(effect); + this.exileId = effect.exileId; + } + + @Override + public ReturnFromExileEffect copy() { + return new ReturnFromExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + ExileZone exile = game.getExile().getExileZone(exileId); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null && exile != null) { + controller.moveCards(exile.getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game, false, false, true, null); + return true; + } + return false; + } + + +} diff --git a/Mage.Sets/src/mage/sets/tempest/ElvenWarhounds.java b/Mage.Sets/src/mage/sets/tempest/ElvenWarhounds.java new file mode 100644 index 0000000000..4e085d5db4 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/ElvenWarhounds.java @@ -0,0 +1,66 @@ +/* + * 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.tempest; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PutOnLibraryTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; + +/** + * + * @author Plopman + */ +public class ElvenWarhounds extends CardImpl { + + public ElvenWarhounds(UUID ownerId) { + super(ownerId, 119, "Elven Warhounds", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{G}"); + this.expansionSetCode = "TMP"; + this.subtype.add("Hound"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever Elven Warhounds becomes blocked by a creature, put that creature on top of its owner's library. + Effect effect = new PutOnLibraryTargetEffect(true); + effect.setText("put that creature on top of its owner's library"); + this.addAbility(new BecomesBlockedByCreatureTriggeredAbility(effect, false)); + } + + public ElvenWarhounds(final ElvenWarhounds card) { + super(card); + } + + @Override + public ElvenWarhounds copy() { + return new ElvenWarhounds(this); + } +} diff --git a/Mage.Sets/src/mage/sets/tempest/Excavator.java b/Mage.Sets/src/mage/sets/tempest/Excavator.java new file mode 100644 index 0000000000..9b9918a9fb --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/Excavator.java @@ -0,0 +1,158 @@ +/* + * 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.tempest; + +import java.util.UUID; +import mage.abilities.Abilities; +import mage.abilities.AbilitiesImpl; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continuous.SourceEffect; +import mage.abilities.keyword.ForestwalkAbility; +import mage.abilities.keyword.IslandwalkAbility; +import mage.abilities.keyword.MountainwalkAbility; +import mage.abilities.keyword.PlainswalkAbility; +import mage.abilities.keyword.SwampwalkAbility; +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.filter.common.FilterControlledLandPermanent; +import mage.filter.predicate.mageobject.SupertypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetControlledPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author Plopman + */ +public class Excavator extends CardImpl { + + private static final FilterControlledLandPermanent filter = new FilterControlledLandPermanent("basic land"); + static + { + filter.add(new SupertypePredicate("Basic")); + } + + public Excavator(UUID ownerId) { + super(ownerId, 277, "Excavator", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); + this.expansionSetCode = "TMP"; + + // {tap}, Sacrifice a basic land: Target creature gains landwalk of each of the land types of the sacrificed land until end of turn. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExcavatorEffect(), new TapSourceCost()); + ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public Excavator(final Excavator card) { + super(card); + } + + @Override + public Excavator copy() { + return new Excavator(this); + } +} + +class ExcavatorEffect extends ContinuousEffectImpl implements SourceEffect { + + private Abilities abilities = new AbilitiesImpl();; + + public ExcavatorEffect() { + super(Duration.EndOfTurn, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + setText("Target creature gains landwalk of each of the land types of the sacrificed land until end of turn"); + } + + public ExcavatorEffect(final ExcavatorEffect effect) { + super(effect); + this.abilities = abilities.copy(); + } + + @Override + public ExcavatorEffect copy() { + return new ExcavatorEffect(this); + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); + for(Cost cost : source.getCosts()) { + if(cost instanceof SacrificeTargetCost) { + SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; + for(Permanent permanent : sacrificeCost.getPermanents()) { + if(permanent.hasSubtype("Forest")) + { + abilities.add(new ForestwalkAbility()); + } + if(permanent.hasSubtype("Plains")) + { + abilities.add(new PlainswalkAbility()); + } + if(permanent.hasSubtype("Island")) + { + abilities.add(new IslandwalkAbility()); + } + if(permanent.hasSubtype("Mountain")) + { + abilities.add(new MountainwalkAbility()); + } + if(permanent.hasSubtype("Swamp")) + { + abilities.add(new SwampwalkAbility()); + } + } + + } + } + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID permanentId : targetPointer.getTargets(game, source)) { + Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId); + if (permanent != null) { + for(Ability ability : abilities) + { + permanent.addAbility(ability, source.getSourceId(), game, false); + } + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/tempest/PhyrexianGrimoire.java b/Mage.Sets/src/mage/sets/tempest/PhyrexianGrimoire.java new file mode 100644 index 0000000000..76baaee712 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/PhyrexianGrimoire.java @@ -0,0 +1,141 @@ +/* + * 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.tempest; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetOpponent; + +/** + * 10/4/2004 : If there is only one card in your graveyard, it is exiled by the first part of the effect and you do not get to put any cards into your hand since the second part fails. + * 10/15/2006: It does not target the cards, but it targets the opponent. If you can't target an opponent, you can't activate this ability. + * + * @author Plopman + */ +public class PhyrexianGrimoire extends CardImpl { + + public PhyrexianGrimoire(UUID ownerId) { + super(ownerId, 291, "Phyrexian Grimoire", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}"); + this.expansionSetCode = "TMP"; + + // {4}, {tap}: Target opponent chooses one of the top two cards of your graveyard. Exile that card and put the other one into your hand. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PhyrexianGrimoireEffect(), new ManaCostsImpl("{4}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + } + + public PhyrexianGrimoire(final PhyrexianGrimoire card) { + super(card); + } + + @Override + public PhyrexianGrimoire copy() { + return new PhyrexianGrimoire(this); + } +} + +class PhyrexianGrimoireEffect extends OneShotEffect { + + public PhyrexianGrimoireEffect() { + super(Outcome.ReturnToHand); + this.staticText = "Target opponent chooses one of the top two cards of your graveyard. Exile that card and put the other one into your hand"; + } + + public PhyrexianGrimoireEffect(final PhyrexianGrimoireEffect effect) { + super(effect); + } + + @Override + public PhyrexianGrimoireEffect copy() { + return new PhyrexianGrimoireEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player opponent = game.getPlayer(source.getFirstTarget()); + if (controller != null && opponent != null) { + if(controller.getGraveyard().size() > 0) + { + Cards cards = new CardsImpl(); + + UUID card1 = null; + UUID card2 = null; + for (UUID cardId : controller.getGraveyard()) { + card2 = card1; + card1 = cardId; + } + if(card1 != null){ + cards.add(card1); + } + if(card2 != null){ + cards.add(card2); + } + + TargetCard target = new TargetCard(Zone.GRAVEYARD, new FilterCard()); + target.setRequired(true); + if(opponent.choose(Outcome.Exile, cards, target, game)) + { + Card card = game.getCard(target.getFirstTarget()); + cards.remove(target.getFirstTarget()); + if (card != null) { + controller.moveCards(card, Zone.EXILED, source, game); + } + + if(!cards.isEmpty()) + { + card = game.getCard(cards.iterator().next()); + if (card != null) { + controller.moveCards(card, Zone.HAND, source, game); + } + } + + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/tempest/Watchdog.java b/Mage.Sets/src/mage/sets/tempest/Watchdog.java new file mode 100644 index 0000000000..e322bd5b17 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/Watchdog.java @@ -0,0 +1,114 @@ +/* + * 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.tempest; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.InvertCondition; +import mage.abilities.condition.common.SourceTappedCondition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.combat.BlocksIfAbleSourceEffect; +import mage.abilities.effects.common.continuous.BoostAllEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterAttackingCreature; +import mage.game.Game; +import mage.game.combat.CombatGroup; +import mage.game.permanent.Permanent; + +/** + * + * @author Plopman + */ +public class Watchdog extends CardImpl { + + public Watchdog(UUID ownerId) { + super(ownerId, 304, "Watchdog", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}"); + this.expansionSetCode = "TMP"; + this.subtype.add("Hound"); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // Watchdog blocks each turn if able. + this.getAbilities().add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BlocksIfAbleSourceEffect(Duration.WhileOnBattlefield))); + // As long as Watchdog is untapped, all creatures attacking you get -1/-0. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect( + new BoostAllEffect(-1, 0, Duration.WhileOnBattlefield, new WatchdogFilter(), false), new InvertCondition(new SourceTappedCondition()),"As long as {this} is untapped, all creatures attacking you get -1/-0"))); + } + + public Watchdog(final Watchdog card) { + super(card); + } + + @Override + public Watchdog copy() { + return new Watchdog(this); + } +} + + +class WatchdogFilter extends FilterAttackingCreature { + + public WatchdogFilter() { + super("creatures attacking you"); + } + + + public WatchdogFilter(final WatchdogFilter filter) { + super(filter); + } + + @Override + public WatchdogFilter copy() { + return new WatchdogFilter(this); + } + + @Override + public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { + if(!super.match(permanent, sourceId, playerId, game)) { + return false; + } + + for(CombatGroup group : game.getCombat().getGroups()) { + for(UUID attacker : group.getAttackers()) { + if(attacker.equals(permanent.getId())) { + UUID defenderId = group.getDefenderId(); + if(defenderId.equals(playerId)) { + return true; + } + } + } + } + + return false; + } +}