From a64741ff499a36e2f438488fb069904ae443109e Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Mon, 7 Feb 2022 16:49:56 -0600 Subject: [PATCH] [NEO] Implemented Lethal Exploit --- Mage.Sets/src/mage/cards/l/LethalExploit.java | 81 +++++++++++++++++++ .../src/mage/sets/KamigawaNeonDynasty.java | 1 + ...dModifiedCreatureAsSpellCastCondition.java | 2 +- ...ledModifiedCreatureAsSpellCastWatcher.java | 11 ++- 4 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/l/LethalExploit.java diff --git a/Mage.Sets/src/mage/cards/l/LethalExploit.java b/Mage.Sets/src/mage/cards/l/LethalExploit.java new file mode 100644 index 00000000000..634113aa0e4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LethalExploit.java @@ -0,0 +1,81 @@ +package mage.cards.l; + +import java.util.UUID; + +import mage.MageObject; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCreaturePermanent; +import mage.watchers.common.ControlledModifiedCreatureAsSpellCastWatcher; + +/** + * + * @author weirddan455 + */ +public final class LethalExploit extends CardImpl { + + public LethalExploit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}"); + + // Target creature gets -2/-2 until end of turn. It gets an additional -1/-1 until end of turn for each modified creature you controlled as you cast this spell. + this.getSpellAbility().addEffect(new LethalExploitEffect()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addWatcher(new ControlledModifiedCreatureAsSpellCastWatcher()); + } + + private LethalExploit(final LethalExploit card) { + super(card); + } + + @Override + public LethalExploit copy() { + return new LethalExploit(this); + } +} + +class LethalExploitEffect extends ContinuousEffectImpl { + + private int boostValue = -2; + + public LethalExploitEffect() { + super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.UnboostCreature); + this.staticText = "Target creature gets -2/-2 until end of turn. It gets an additional -1/-1 until end of turn for each modified creature you controlled as you cast this spell"; + } + + private LethalExploitEffect(final LethalExploitEffect effect) { + super(effect); + this.boostValue = effect.boostValue; + } + + @Override + public LethalExploitEffect copy() { + return new LethalExploitEffect(this); + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); + ControlledModifiedCreatureAsSpellCastWatcher watcher = game.getState().getWatcher(ControlledModifiedCreatureAsSpellCastWatcher.class); + MageObject sourceObject = source.getSourceObject(game); + if (watcher != null && sourceObject != null) { + boostValue -= watcher.getModifiedCreatureCount(new MageObjectReference(sourceObject, game)); + } + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent target = game.getPermanent(source.getFirstTarget()); + if (target == null) { + return false; + } + target.addPower(boostValue); + target.addToughness(boostValue); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java index c1077b4c4ff..561dac155c5 100644 --- a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java +++ b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java @@ -161,6 +161,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet { cards.add(new SetCardInfo("Kura, the Boundless Sky", 200, Rarity.MYTHIC, mage.cards.k.KuraTheBoundlessSky.class)); cards.add(new SetCardInfo("Kyodai, Soul of Kamigawa", 23, Rarity.RARE, mage.cards.k.KyodaiSoulOfKamigawa.class)); cards.add(new SetCardInfo("Leech Gauntlet", 106, Rarity.UNCOMMON, mage.cards.l.LeechGauntlet.class)); + cards.add(new SetCardInfo("Lethal Exploit", 107, Rarity.COMMON, mage.cards.l.LethalExploit.class)); cards.add(new SetCardInfo("Life of Toshiro Umezawa", 108, Rarity.UNCOMMON, mage.cards.l.LifeOfToshiroUmezawa.class)); cards.add(new SetCardInfo("Light the Way", 24, Rarity.COMMON, mage.cards.l.LightTheWay.class)); cards.add(new SetCardInfo("Likeness of the Seeker", 172, Rarity.UNCOMMON, mage.cards.l.LikenessOfTheSeeker.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/ControlledModifiedCreatureAsSpellCastCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ControlledModifiedCreatureAsSpellCastCondition.java index 5000cbb92a9..4af273a385e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ControlledModifiedCreatureAsSpellCastCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ControlledModifiedCreatureAsSpellCastCondition.java @@ -21,7 +21,7 @@ public enum ControlledModifiedCreatureAsSpellCastCondition implements Condition if (sourceObject == null || watcher == null) { return false; } - return watcher.checkModifiedCondition(new MageObjectReference(sourceObject, game)); + return watcher.getModifiedCreatureCount(new MageObjectReference(sourceObject, game)) > 0; } @Override diff --git a/Mage/src/main/java/mage/watchers/common/ControlledModifiedCreatureAsSpellCastWatcher.java b/Mage/src/main/java/mage/watchers/common/ControlledModifiedCreatureAsSpellCastWatcher.java index 4ec8368da0f..e0d6112a228 100644 --- a/Mage/src/main/java/mage/watchers/common/ControlledModifiedCreatureAsSpellCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ControlledModifiedCreatureAsSpellCastWatcher.java @@ -27,7 +27,7 @@ public class ControlledModifiedCreatureAsSpellCastWatcher extends Watcher { super(WatcherScope.GAME); } - private final HashMap spellsCastCondition = new HashMap<>(); + private final HashMap modifiedCreaturesWhenCast = new HashMap<>(); @Override public void watch(GameEvent event, Game game) { @@ -35,8 +35,7 @@ public class ControlledModifiedCreatureAsSpellCastWatcher extends Watcher { Spell spell = game.getSpell(event.getTargetId()); if (spell != null) { MageObjectReference mor = new MageObjectReference(spell, game); - Boolean condition = !game.getBattlefield().getAllActivePermanents(filter, spell.getControllerId(), game).isEmpty(); - spellsCastCondition.put(mor, condition); + modifiedCreaturesWhenCast.put(mor, game.getBattlefield().countAll(filter, spell.getControllerId(), game)); } } } @@ -44,10 +43,10 @@ public class ControlledModifiedCreatureAsSpellCastWatcher extends Watcher { @Override public void reset() { super.reset(); - spellsCastCondition.clear(); + modifiedCreaturesWhenCast.clear(); } - public boolean checkModifiedCondition(MageObjectReference mor) { - return spellsCastCondition.getOrDefault(mor, false); + public int getModifiedCreatureCount(MageObjectReference mor) { + return modifiedCreaturesWhenCast.getOrDefault(mor, 0); } }