Implemented Lure of Prey

This commit is contained in:
Evan Kranzler 2018-06-21 12:29:36 -04:00
parent 0d6015bbb9
commit 487503afcd
2 changed files with 94 additions and 0 deletions

View file

@ -0,0 +1,93 @@
package mage.cards.l;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.common.CastSpellLastTurnWatcher;
/**
*
* @author TheElk801
*/
public final class LureOfPrey extends CardImpl {
private static final FilterCreatureCard filter = new FilterCreatureCard("a green creature card");
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
public LureOfPrey(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}{G}");
// Cast Lure of Prey only if an opponent cast a creature spell this turn.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new LureOfPreyRestrictionEffect()));
// You may put a green creature card from your hand onto the battlefield.
this.getSpellAbility().addEffect(new PutCardFromHandOntoBattlefieldEffect(filter));
}
public LureOfPrey(final LureOfPrey card) {
super(card);
}
@Override
public LureOfPrey copy() {
return new LureOfPrey(this);
}
}
class LureOfPreyRestrictionEffect extends ContinuousRuleModifyingEffectImpl {
public LureOfPreyRestrictionEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast this spell only if an opponent cast a creature spell this turn";
}
public LureOfPreyRestrictionEffect(final LureOfPreyRestrictionEffect effect) {
super(effect);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getSourceId().equals(source.getSourceId())) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
if (watcher != null) {
for (UUID playerId : game.getOpponents(source.getControllerId())) {
if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(playerId) != 0) {
return false;
}
}
}
}
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public LureOfPreyRestrictionEffect copy() {
return new LureOfPreyRestrictionEffect(this);
}
}

View file

@ -177,6 +177,7 @@ public final class Mirage extends ExpansionSet {
cards.add(new SetCardInfo("Lightning Reflexes", 186, Rarity.COMMON, mage.cards.l.LightningReflexes.class));
cards.add(new SetCardInfo("Lion's Eye Diamond", 307, Rarity.RARE, mage.cards.l.LionsEyeDiamond.class));
cards.add(new SetCardInfo("Locust Swarm", 226, Rarity.UNCOMMON, mage.cards.l.LocustSwarm.class));
cards.add(new SetCardInfo("Lure of Prey", 125, Rarity.RARE, mage.cards.l.LureOfPrey.class));
cards.add(new SetCardInfo("Mana Prism", 308, Rarity.UNCOMMON, mage.cards.m.ManaPrism.class));
cards.add(new SetCardInfo("Mangara's Tome", 309, Rarity.RARE, mage.cards.m.MangarasTome.class));
cards.add(new SetCardInfo("Marble Diamond", 310, Rarity.UNCOMMON, mage.cards.m.MarbleDiamond.class));