Implemented Luminous Broodmoth

This commit is contained in:
Evan Kranzler 2020-04-11 15:40:32 -04:00
parent 7efec1294f
commit 461b54114b
2 changed files with 135 additions and 0 deletions

View file

@ -0,0 +1,134 @@
package mage.cards.l;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class LuminousBroodmoth extends CardImpl {
public LuminousBroodmoth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
this.subtype.add(SubType.INSECT);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever a creature you control without flying dies, return it to the battlefield under its owner's control with a flying counter on it.
this.addAbility(new LuminousBroodmothTriggeredAbility());
}
private LuminousBroodmoth(final LuminousBroodmoth card) {
super(card);
}
@Override
public LuminousBroodmoth copy() {
return new LuminousBroodmoth(this);
}
}
class LuminousBroodmothTriggeredAbility extends TriggeredAbilityImpl {
LuminousBroodmothTriggeredAbility() {
super(Zone.BATTLEFIELD, new LuminousBroodmothEffect(), false);
}
private LuminousBroodmothTriggeredAbility(final LuminousBroodmothTriggeredAbility ability) {
super(ability);
}
@Override
public LuminousBroodmothTriggeredAbility copy() {
return new LuminousBroodmothTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getTarget() == null || zEvent.getTarget().getId().equals(this.getSourceId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTarget().getId());
if (permanent != null
&& zEvent.getToZone() == Zone.GRAVEYARD
&& zEvent.getFromZone() == Zone.BATTLEFIELD
&& permanent.isCreature()
&& !permanent.getAbilities().containsKey(FlyingAbility.getInstance().getId())
&& permanent.isControlledBy(this.controllerId)) {
this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId()));
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever a creature you control without flying dies, " +
"return it to the battlefield under its owner's control with a flying counter on it.";
}
}
class LuminousBroodmothEffect extends OneShotEffect {
LuminousBroodmothEffect() {
super(Outcome.PutCardInPlay);
}
private LuminousBroodmothEffect(final LuminousBroodmothEffect effect) {
super(effect);
}
@Override
public LuminousBroodmothEffect copy() {
return new LuminousBroodmothEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card == null || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
return false;
}
Player player = game.getPlayer(card.getOwnerId());
if (player == null) {
return false;
}
player.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
permanent.addCounters(CounterType.FLYING.createInstance(), source, game);
return true;
}
}

View file

@ -187,6 +187,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet {
cards.add(new SetCardInfo("Lead the Stampede", 163, Rarity.UNCOMMON, mage.cards.l.LeadTheStampede.class));
cards.add(new SetCardInfo("Light of Hope", 20, Rarity.COMMON, mage.cards.l.LightOfHope.class));
cards.add(new SetCardInfo("Lore Drakkis", 194, Rarity.UNCOMMON, mage.cards.l.LoreDrakkis.class));
cards.add(new SetCardInfo("Luminous Broodmoth", 316, Rarity.MYTHIC, mage.cards.l.LuminousBroodmoth.class));
cards.add(new SetCardInfo("Lurking Deadeye", 94, Rarity.COMMON, mage.cards.l.LurkingDeadeye.class));
cards.add(new SetCardInfo("Majestic Auricorn", 22, Rarity.UNCOMMON, mage.cards.m.MajesticAuricorn.class));
cards.add(new SetCardInfo("Maned Serval", 23, Rarity.COMMON, mage.cards.m.ManedServal.class));