mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
[DMU] Implemented Ivy, Gleeful Spellthief
This commit is contained in:
parent
9806d6e092
commit
231bd86e23
2 changed files with 144 additions and 0 deletions
143
Mage.Sets/src/mage/cards/i/IvyGleefulSpellthief.java
Normal file
143
Mage.Sets/src/mage/cards/i/IvyGleefulSpellthief.java
Normal file
|
@ -0,0 +1,143 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SpellCastAllTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.Target;
|
||||
import mage.util.TargetAddress;
|
||||
import mage.util.functions.StackObjectCopyApplier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class IvyGleefulSpellthief extends CardImpl {
|
||||
|
||||
private static final FilterSpell filter
|
||||
= new FilterSpell("a spell that targets only a single creature other than {this}");
|
||||
|
||||
static {
|
||||
filter.add(IvyGleefulSpellthiefPredicate.instance);
|
||||
}
|
||||
|
||||
public IvyGleefulSpellthief(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{U}");
|
||||
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.FAERIE);
|
||||
this.subtype.add(SubType.ROGUE);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// Whenever a player casts a spell that targets only a single creature other than Ivy, Gleeful Spellthief, you may copy that spell. The copy targets Ivy.
|
||||
this.addAbility(new SpellCastAllTriggeredAbility(new IvyGleefulSpellthiefEffect(), filter, true));
|
||||
}
|
||||
|
||||
private IvyGleefulSpellthief(final IvyGleefulSpellthief card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IvyGleefulSpellthief copy() {
|
||||
return new IvyGleefulSpellthief(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum IvyGleefulSpellthiefPredicate implements ObjectSourcePlayerPredicate<Spell> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Spell> input, Game game) {
|
||||
Spell spell = input.getObject();
|
||||
if (spell == null) {
|
||||
return false;
|
||||
}
|
||||
UUID singleTarget = null;
|
||||
for (TargetAddress addr : TargetAddress.walk(spell)) {
|
||||
Target targetInstance = addr.getTarget(spell);
|
||||
for (UUID targetId : targetInstance.getTargets()) {
|
||||
if (singleTarget == null) {
|
||||
singleTarget = targetId;
|
||||
} else if (!singleTarget.equals(targetId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (singleTarget == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(singleTarget);
|
||||
return permanent != null
|
||||
&& permanent.isCreature(game)
|
||||
&& !permanent.getId().equals(input.getSourceId());
|
||||
}
|
||||
}
|
||||
|
||||
class IvyGleefulSpellthiefEffect extends OneShotEffect {
|
||||
|
||||
private static final class IvyGleefulSpellthiefApplier implements StackObjectCopyApplier {
|
||||
|
||||
private final MageObjectReferencePredicate morPredicate;
|
||||
|
||||
IvyGleefulSpellthiefApplier(Permanent permanent, Game game) {
|
||||
this.morPredicate = new MageObjectReferencePredicate(permanent, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifySpell(StackObject stackObject, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageObjectReferencePredicate getNextNewTargetType(int copyNumber) {
|
||||
return copyNumber == 0 ? morPredicate : null;
|
||||
}
|
||||
}
|
||||
|
||||
IvyGleefulSpellthiefEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "copy that spell. The copy targets {this}";
|
||||
}
|
||||
|
||||
private IvyGleefulSpellthiefEffect(final IvyGleefulSpellthiefEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IvyGleefulSpellthiefEffect copy() {
|
||||
return new IvyGleefulSpellthiefEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Spell spell = (Spell) getValue("spellCast");
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (spell == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
spell.createCopyOnStack(
|
||||
game, source, source.getControllerId(), false,
|
||||
1, new IvyGleefulSpellthiefApplier(permanent, game)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -132,6 +132,7 @@ public final class DominariaUnited extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("In Thrall to the Pit", 132, Rarity.COMMON, mage.cards.i.InThrallToThePit.class));
|
||||
cards.add(new SetCardInfo("Inscribed Tablet", 232, Rarity.UNCOMMON, mage.cards.i.InscribedTablet.class));
|
||||
cards.add(new SetCardInfo("Island", 265, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Ivy, Gleeful Spellthief", 201, Rarity.RARE, mage.cards.i.IvyGleefulSpellthief.class));
|
||||
cards.add(new SetCardInfo("Jaya's Firenado", 134, Rarity.COMMON, mage.cards.j.JayasFirenado.class));
|
||||
cards.add(new SetCardInfo("Jaya, Fiery Negotiator", 133, Rarity.MYTHIC, mage.cards.j.JayaFieryNegotiator.class));
|
||||
cards.add(new SetCardInfo("Jhoira, Ageless Innovator", 202, Rarity.RARE, mage.cards.j.JhoiraAgelessInnovator.class));
|
||||
|
|
Loading…
Reference in a new issue