From 3811a6eb0078aa66314beabaf321acbbefdc6ae2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 23 Jun 2019 17:18:35 -0400 Subject: [PATCH] Implemented Leyline of Combustion --- .../src/mage/cards/l/LeylineOfCombustion.java | 100 ++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2020.java | 1 + 2 files changed, 101 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/l/LeylineOfCombustion.java diff --git a/Mage.Sets/src/mage/cards/l/LeylineOfCombustion.java b/Mage.Sets/src/mage/cards/l/LeylineOfCombustion.java new file mode 100644 index 00000000000..88bd186317d --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LeylineOfCombustion.java @@ -0,0 +1,100 @@ +package mage.cards.l; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.keyword.LeylineAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class LeylineOfCombustion extends CardImpl { + + public LeylineOfCombustion(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}"); + + // If Leyline of Combustion is in your opening hand, you may begin the game with it on the battlefield. + this.addAbility(LeylineAbility.getInstance()); + + // Whenever you and/or at least one permanent you control becomes the target of a spell or ability an opponent controls, Leyline of Combustion deals 2 damage to that player. + this.addAbility(new LeylineOfCombustionTriggeredAbility()); + } + + private LeylineOfCombustion(final LeylineOfCombustion card) { + super(card); + } + + @Override + public LeylineOfCombustion copy() { + return new LeylineOfCombustion(this); + } +} + +class LeylineOfCombustionTriggeredAbility extends TriggeredAbilityImpl { + + LeylineOfCombustionTriggeredAbility() { + super(Zone.BATTLEFIELD, null); + } + + private LeylineOfCombustionTriggeredAbility(final LeylineOfCombustionTriggeredAbility ability) { + super(ability); + } + + @Override + public LeylineOfCombustionTriggeredAbility copy() { + return new LeylineOfCombustionTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.TARGETED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); + if (sourceObject == null) { + return false; + } + if (sourceObject + .getStackAbility() + .getTargets() + .stream() + .noneMatch(target -> target + .getTargets() + .stream() + .anyMatch(targetId -> { + if (this.controllerId.equals(targetId)) { + return true; + } + Permanent permanent = game.getPermanent(targetId); + return permanent != null && permanent.getControllerId().equals(this.controllerId); + }) + )) { + return false; + } + this.getEffects().clear(); + Effect effect = new DamageTargetEffect(2); + effect.setTargetPointer(new FixedTarget(sourceObject.getControllerId(), game)); + this.addEffect(effect); + return true; + } + + @Override + public String getRule() { + return "Whenever you and/or at least one permanent you control " + + "becomes the target of a spell or ability an opponent controls, " + + "{this} deals 2 damage to that player."; + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index ac9202cab83..7bd14eda74b 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -122,6 +122,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Legion's End", 106, Rarity.RARE, mage.cards.l.LegionsEnd.class)); cards.add(new SetCardInfo("Leyline of Abundance", 179, Rarity.RARE, mage.cards.l.LeylineOfAbundance.class)); cards.add(new SetCardInfo("Leyline of Anticipation", 64, Rarity.RARE, mage.cards.l.LeylineOfAnticipation.class)); + cards.add(new SetCardInfo("Leyline of Combustion", 148, Rarity.RARE, mage.cards.l.LeylineOfCombustion.class)); cards.add(new SetCardInfo("Leyline of Sanctity", 26, Rarity.RARE, mage.cards.l.LeylineOfSanctity.class)); cards.add(new SetCardInfo("Leyline of the Void", 107, Rarity.RARE, mage.cards.l.LeylineOfTheVoid.class)); cards.add(new SetCardInfo("Loaming Shaman", 180, Rarity.UNCOMMON, mage.cards.l.LoamingShaman.class));