Add Essence Leak

This commit is contained in:
Noah Gleason 2018-06-18 12:56:15 -04:00
parent 9a9c1a8694
commit 42ac32c5ef
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40
2 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,100 @@
package mage.cards.e;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.OrCondition;
import mage.abilities.condition.common.EnchantedCreatureColorCondition;
import mage.abilities.costs.Cost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author noahg
*/
public final class EssenceLeak extends CardImpl {
public EssenceLeak(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}");
this.subtype.add(SubType.AURA);
// Enchant permanent
TargetPermanent auraTarget = new TargetPermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// As long as enchanted permanent is red or green, it has "At the beginning of your upkeep, sacrifice this permanent unless you pay its mana cost."
Ability sacAbility =new BeginningOfUpkeepTriggeredAbility(new EssenceLeakEffect(), TargetController.YOU, false);
ContinuousEffect isRedOrGreenAbility = new GainAbilityAttachedEffect(sacAbility, AttachmentType.AURA);
SimpleStaticAbility ifRedOrGreenAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(isRedOrGreenAbility,
new OrCondition(new EnchantedCreatureColorCondition(ObjectColor.RED), new EnchantedCreatureColorCondition(ObjectColor.GREEN)),
"As long as enchanted permanent is red or green, it has \"At the beginning of your upkeep, sacrifice this permanent unless you pay its mana cost.\""));
this.addAbility(ifRedOrGreenAbility);
}
public EssenceLeak(final EssenceLeak card) {
super(card);
}
@Override
public EssenceLeak copy() {
return new EssenceLeak(this);
}
}
class EssenceLeakEffect extends OneShotEffect {
public EssenceLeakEffect() {
super(Outcome.Sacrifice);
staticText = "sacrifice this permanent unless you pay its mana cost";
}
public EssenceLeakEffect(final EssenceLeakEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && permanent != null) {
String message = CardUtil.replaceSourceName("Pay {this}'s mana cost?", permanent.getLogName());
Cost cost = permanent.getManaCost().copy();
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
}
}
permanent.sacrifice(source.getSourceId(), game);
return true;
}
return false;
}
@Override
public EssenceLeakEffect copy() {
return new EssenceLeakEffect(this);
}
}

View file

@ -106,6 +106,7 @@ public final class Invasion extends ExpansionSet {
cards.add(new SetCardInfo("Elfhame Sanctuary", 185, Rarity.UNCOMMON, mage.cards.e.ElfhameSanctuary.class));
cards.add(new SetCardInfo("Elvish Champion", 186, Rarity.RARE, mage.cards.e.ElvishChampion.class));
cards.add(new SetCardInfo("Empress Galina", 54, Rarity.RARE, mage.cards.e.EmpressGalina.class));
cards.add(new SetCardInfo("Essence Leak", 55, Rarity.UNCOMMON, mage.cards.e.EssenceLeak.class));
cards.add(new SetCardInfo("Exclude", 56, Rarity.COMMON, mage.cards.e.Exclude.class));
cards.add(new SetCardInfo("Exotic Curse", 105, Rarity.COMMON, mage.cards.e.ExoticCurse.class));
cards.add(new SetCardInfo("Explosive Growth", 187, Rarity.COMMON, mage.cards.e.ExplosiveGrowth.class));