mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[NEO] Implemented Lethal Exploit
This commit is contained in:
parent
ffe753fa91
commit
a64741ff49
4 changed files with 88 additions and 7 deletions
81
Mage.Sets/src/mage/cards/l/LethalExploit.java
Normal file
81
Mage.Sets/src/mage/cards/l/LethalExploit.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ControlledModifiedCreatureAsSpellCastWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
private final HashMap<MageObjectReference, Boolean> spellsCastCondition = new HashMap<>();
|
||||
private final HashMap<MageObjectReference, Integer> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue