From 8f7294eda71e95536585e2352bbc05b0991d8c7c Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 7 Oct 2013 15:59:41 -0500 Subject: [PATCH] - Added Banefire for LevelX2. Added Blood Tyrant, Dragonsoul Knight, Paleoloth, and Yoke of the Damned. One card left in Conflux if anyone is interested. --- Mage.Sets/src/mage/sets/conflux/Banefire.java | 183 ++++++++++++++++++ .../src/mage/sets/conflux/BloodTyrant.java | 153 +++++++++++++++ .../mage/sets/conflux/DragonsoulKnight.java | 143 ++++++++++++++ .../src/mage/sets/conflux/Paleoloth.java | 85 ++++++++ .../mage/sets/conflux/YokeOfTheDamned.java | 115 +++++++++++ 5 files changed, 679 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/conflux/Banefire.java create mode 100644 Mage.Sets/src/mage/sets/conflux/BloodTyrant.java create mode 100644 Mage.Sets/src/mage/sets/conflux/DragonsoulKnight.java create mode 100644 Mage.Sets/src/mage/sets/conflux/Paleoloth.java create mode 100644 Mage.Sets/src/mage/sets/conflux/YokeOfTheDamned.java diff --git a/Mage.Sets/src/mage/sets/conflux/Banefire.java b/Mage.Sets/src/mage/sets/conflux/Banefire.java new file mode 100644 index 0000000000..ad223e7154 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/Banefire.java @@ -0,0 +1,183 @@ +/* + * 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.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.target.common.TargetCreatureOrPlayer; + +/** + * + * @author LevelX2 + */ +public class Banefire extends CardImpl { + + public Banefire(UUID ownerId) { + super(ownerId, 58, "Banefire", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{R}"); + this.expansionSetCode = "CON"; + + this.color.setRed(true); + + // Banefire deals X damage to target creature or player. + this.getSpellAbility().addEffect(new BaneFireEffect()); + this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); + // If X is 5 or more, Banefire can't be countered by spells or abilities and the damage can't be prevented. + this.addAbility(new SimpleStaticAbility(Zone.STACK, new BanefireCantCounterEffect())); + + } + + public Banefire(final Banefire card) { + super(card); + } + + @Override + public Banefire copy() { + return new Banefire(this); + } +} + +class testCondition implements Condition { + + private DynamicValue xValue; + private int limit; + + public testCondition(DynamicValue xValue, int limit) { + this.xValue = xValue; + this.limit = limit; + } + + @Override + public boolean apply(Game game, Ability source) { + Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId()); + if (spell != null) { + return (xValue.calculate(game, spell.getSpellAbility()) >= limit); + } + return false; + + } +} + +class BaneFireEffect extends OneShotEffect { + + public BaneFireEffect() { + super(Outcome.Damage); + staticText = "{this} deals X damage to target creature or player"; + } + + public BaneFireEffect(final BaneFireEffect effect) { + super(effect); + } + + @Override + public BaneFireEffect copy() { + return new BaneFireEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player targetPlayer = game.getPlayer(source.getFirstTarget()); + Permanent targetCreature = game.getPermanent(source.getFirstTarget()); + int damage = source.getManaCostsToPay().getX(); + boolean preventable = damage >= 5; + if (targetPlayer != null) { + targetPlayer.damage(damage, source.getSourceId(), game, false, preventable); + return true; + } + if (targetCreature != null) { + targetCreature.damage(damage, source.getSourceId(), game, false, preventable); + return true; + } + return false; + } +} + +class BanefireCantCounterEffect extends ReplacementEffectImpl { + + Condition condition = new testCondition(new ManacostVariableValue(), 5); + + public BanefireCantCounterEffect() { + super(Duration.WhileOnStack, Outcome.Benefit); + staticText = "If X is 5 or more, {this} can't be countered by spells or abilities and the damage can't be prevented"; + } + + public BanefireCantCounterEffect(final BanefireCantCounterEffect effect) { + super(effect); + this.condition = effect.condition; + } + + @Override + public BanefireCantCounterEffect copy() { + return new BanefireCantCounterEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == EventType.COUNTER) { + Card card = game.getCard(source.getSourceId()); + if (card != null) { + UUID spellId = card.getSpellAbility().getId(); + if (event.getTargetId().equals(spellId)) { + if (condition.apply(game, source)) { + return true; + } + } + } + } + return false; + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java b/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java new file mode 100644 index 0000000000..5a196df929 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java @@ -0,0 +1,153 @@ +/* + * 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.TriggeredAbilityImpl; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlyingAbility; +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.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author jeffwadsworth + */ +public class BloodTyrant extends CardImpl { + + public BloodTyrant(UUID ownerId) { + super(ownerId, 99, "Blood Tyrant", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{U}{B}{R}"); + this.expansionSetCode = "CON"; + this.subtype.add("Vampire"); + + this.color.setRed(true); + this.color.setBlue(true); + this.color.setBlack(true); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // At the beginning of your upkeep, each player loses 1 life. Put a +1/+1 counter on Blood Tyrant for each 1 life lost this way. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new BloodTyrantEffect(), TargetController.YOU, false)); + + // Whenever a player loses the game, put five +1/+1 counters on Blood Tyrant. + this.addAbility(new PlayerLosesTheGameTriggeredAbility()); + + } + + public BloodTyrant(final BloodTyrant card) { + super(card); + } + + @Override + public BloodTyrant copy() { + return new BloodTyrant(this); + } +} + +class PlayerLosesTheGameTriggeredAbility extends TriggeredAbilityImpl { + + public PlayerLosesTheGameTriggeredAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance(5)), false); + } + + public PlayerLosesTheGameTriggeredAbility(final PlayerLosesTheGameTriggeredAbility ability) { + super(ability); + } + + @Override + public PlayerLosesTheGameTriggeredAbility copy() { + return new PlayerLosesTheGameTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.LOSES) { + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever a player loses the game, put five +1/+1 counters on {this}."; + } +} + +class BloodTyrantEffect extends OneShotEffect { + + public BloodTyrantEffect() { + super(Outcome.Benefit); + staticText = "each player loses 1 life. Put a +1/+1 counter on {this} for each 1 life lost this way"; + } + + public BloodTyrantEffect(final BloodTyrantEffect effect) { + super(effect); + } + + @Override + public BloodTyrantEffect copy() { + return new BloodTyrantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int counters = 0; + for (Player player : game.getPlayers().values()) { + if (player != null) { + player.loseLife(1, game); + counters++; + } + } + Permanent bloodTyrant = game.getPermanent(source.getSourceId()); + if (bloodTyrant != null && counters != 0) { + bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), game); + } + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/conflux/DragonsoulKnight.java b/Mage.Sets/src/mage/sets/conflux/DragonsoulKnight.java new file mode 100644 index 0000000000..3fdebd0d71 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/DragonsoulKnight.java @@ -0,0 +1,143 @@ +/* + * 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.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continious.BoostSourceEffect; +import mage.abilities.effects.common.continious.GainAbilitySourceEffect; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.TrampleAbility; +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 DragonsoulKnight extends CardImpl { + + public DragonsoulKnight(UUID ownerId) { + super(ownerId, 62, "Dragonsoul Knight", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{R}"); + this.expansionSetCode = "CON"; + this.subtype.add("Human"); + this.subtype.add("Knight"); + + this.color.setRed(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // First strike + this.addAbility(FirstStrikeAbility.getInstance()); + + // {W}{U}{B}{R}{G}: Until end of turn, Dragonsoul Knight becomes a Dragon, gets +5/+3, and gains flying and trample. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DragonsoulKnightEffect(), new ManaCostsImpl("{W}{U}{B}{R}{G}")); + Effect effect = new BoostSourceEffect(5, 3, Duration.EndOfTurn); + effect.setText("gets +5/+3"); + ability.addEffect(effect); + effect = new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn); + effect.setText("and gains flying"); + ability.addEffect(effect); + effect = new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); + effect.setText("and trample"); + ability.addEffect(effect); + this.addAbility(ability); + + } + + public DragonsoulKnight(final DragonsoulKnight card) { + super(card); + } + + @Override + public DragonsoulKnight copy() { + return new DragonsoulKnight(this); + } + + private class DragonsoulKnightEffect extends ContinuousEffectImpl { + + public DragonsoulKnightEffect() { + super(Duration.EndOfTurn, Outcome.BecomeCreature); + setText(); + } + + public DragonsoulKnightEffect(final DragonsoulKnightEffect effect) { + super(effect); + } + + @Override + public DragonsoulKnightEffect copy() { + return new DragonsoulKnightEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null) { + return false; + } + switch (layer) { + case TypeChangingEffects_4: + if (sublayer == SubLayer.NA) { + permanent.getSubtype().clear(); + permanent.getSubtype().add("Dragon"); + } + break; + } + return true; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + private void setText() { + staticText = "Until end of turn, {this} becomes a Dragon, "; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.TypeChangingEffects_4; + } + } +} diff --git a/Mage.Sets/src/mage/sets/conflux/Paleoloth.java b/Mage.Sets/src/mage/sets/conflux/Paleoloth.java new file mode 100644 index 0000000000..37ba10be0e --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/Paleoloth.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.sets.conflux; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.Filter; +import mage.filter.common.FilterCreatureCard; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.PowerPredicate; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author jeffwadsworth + */ +public class Paleoloth extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature with power 5 or greater"); + + static { + filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 4)); + filter.add(new AnotherPredicate()); + } + + private static final String rule = "Whenever another creature with power 5 or greater enters the battlefield under your control, you may return target creature card from your graveyard to your hand."; + + public Paleoloth(UUID ownerId) { + super(ownerId, 88, "Paleoloth", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{G}{G}"); + this.expansionSetCode = "CON"; + this.subtype.add("Beast"); + + this.color.setGreen(true); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Whenever another creature with power 5 or greater enters the battlefield under your control, you may return target creature card from your graveyard to your hand. + Ability ability = new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new ReturnFromGraveyardToHandTargetEffect(), filter, true, rule); + ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard())); + this.addAbility(ability); + + } + + public Paleoloth(final Paleoloth card) { + super(card); + } + + @Override + public Paleoloth copy() { + return new Paleoloth(this); + } +} diff --git a/Mage.Sets/src/mage/sets/conflux/YokeOfTheDamned.java b/Mage.Sets/src/mage/sets/conflux/YokeOfTheDamned.java new file mode 100644 index 0000000000..741e226907 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/YokeOfTheDamned.java @@ -0,0 +1,115 @@ +/* + * 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.Ability; +import mage.abilities.common.DiesCreatureTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author jeffwadsworth + */ +public class YokeOfTheDamned extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature"); + + public YokeOfTheDamned(UUID ownerId) { + super(ownerId, 57, "Yoke of the Damned", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}"); + this.expansionSetCode = "CON"; + this.subtype.add("Aura"); + + this.color.setBlack(true); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // When a creature dies, destroy enchanted creature. + this.addAbility(new DiesCreatureTriggeredAbility(new DestroyEnchantedEffect(), false, filter)); + + } + + public YokeOfTheDamned(final YokeOfTheDamned card) { + super(card); + } + + @Override + public YokeOfTheDamned copy() { + return new YokeOfTheDamned(this); + } +} + +class DestroyEnchantedEffect extends OneShotEffect { + + public DestroyEnchantedEffect() { + super(Outcome.Detriment); + staticText = "destroy enchanted creature"; + } + + public DestroyEnchantedEffect(final DestroyEnchantedEffect effect) { + super(effect); + } + + @Override + public DestroyEnchantedEffect copy() { + return new DestroyEnchantedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent enchantment = game.getPermanent(source.getSourceId()); + if (enchantment != null && enchantment.getAttachedTo() != null) { + UUID uuid = getTargetPointer().getFirst(game, source); + Permanent creature = game.getPermanent(uuid); + if (creature == null) { + creature = game.getPermanent(enchantment.getAttachedTo()); + } + if (creature != null) { + return creature.destroy(source.getId(), game, false); + } + } + return false; + } + +}