[CLB] Implement Endless Evil (#9298)

This commit is contained in:
PurpleCrowbar 2022-07-23 04:07:13 +01:00 committed by GitHub
parent de9fcfc7ee
commit 9843f38c40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 137 additions and 0 deletions

View file

@ -0,0 +1,135 @@
package mage.cards.e;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.*;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.game.events.GameEvent;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.game.events.ZoneChangeEvent;
import java.util.UUID;
/**
*
* @author PurpleCrowbar
*/
public final class EndlessEvil extends CardImpl {
public EndlessEvil(UUID ownerID, CardSetInfo setInfo) {
super(ownerID, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
this.subtype.add(SubType.AURA);
// Enchant creature you control
TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// At the beginning of your upkeep, create a token thats a copy of enchanted creature, except the token is 1/1.
TriggeredAbility CloneAbility = new BeginningOfUpkeepTriggeredAbility(
new EndlessEvilCloneEffect(),
TargetController.YOU,
false
);
this.addAbility(CloneAbility);
// When enchanted creature dies, if that creature was a Horror, return Endless Evil to its owners hand.
this.addAbility(new EndlessEvilBounceAbility());
}
private EndlessEvil(final EndlessEvil card) {
super(card);
}
@Override
public EndlessEvil copy() {
return new EndlessEvil(this);
}
}
class EndlessEvilCloneEffect extends OneShotEffect {
public EndlessEvilCloneEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "create a token that's a copy of enchanted creature, except the token is 1/1";
}
public EndlessEvilCloneEffect(final EndlessEvilCloneEffect effect) {
super(effect);
}
@Override
public EndlessEvilCloneEffect copy() {
return new EndlessEvilCloneEffect(this);
}
@Override
public boolean apply (Game game, Ability source) {
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// In the case that Endless Evil is blinked
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment != null) {
Permanent target = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
if (target != null) {
Effect effect = new CreateTokenCopyTargetEffect(null, null, false, 1, false,
false, null, 1, 1, false);
effect.setTargetPointer(new FixedTarget(enchantment.getAttachedTo(), game));
return effect.apply(game, source);
}
}
return false;
}
}
class EndlessEvilBounceAbility extends TriggeredAbilityImpl {
public EndlessEvilBounceAbility() {
super(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(false, true));
}
public EndlessEvilBounceAbility(final EndlessEvilBounceAbility effect) {
super(effect);
}
@Override
public EndlessEvilBounceAbility copy() {
return new EndlessEvilBounceAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((ZoneChangeEvent) event).isDiesEvent()) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
return permanent.getAttachments().contains(this.getSourceId()) && permanent.hasSubtype(SubType.HORROR, game);
}
return false;
}
@Override
public String getRule() {
return "When enchanted creature dies, if that creature was a Horror, return {this} to its owner's hand.";
}
}

View file

@ -211,6 +211,8 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
cards.add(new SetCardInfo("Elturel Survivors", 172, Rarity.RARE, mage.cards.e.ElturelSurvivors.class));
cards.add(new SetCardInfo("Embereth Shieldbreaker", 792, Rarity.UNCOMMON, mage.cards.e.EmberethShieldbreaker.class));
cards.add(new SetCardInfo("Emerald Dragon", 229, Rarity.UNCOMMON, mage.cards.e.EmeraldDragon.class));
cards.add(new SetCardInfo("Endless Evil", 665, Rarity.RARE, mage.cards.e.EndlessEvil.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Endless Evil", 615, Rarity.RARE, mage.cards.e.EndlessEvil.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("End-Raze Forerunners", 822, Rarity.RARE, mage.cards.e.EndRazeForerunners.class));
cards.add(new SetCardInfo("Erinis, Gloom Stalker", 230, Rarity.UNCOMMON, mage.cards.e.ErinisGloomStalker.class));
cards.add(new SetCardInfo("Escape to the Wilds", 843, Rarity.RARE, mage.cards.e.EscapeToTheWilds.class));