From 461b54114b39ad645acf080b6df812405233d8a5 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 11 Apr 2020 15:40:32 -0400 Subject: [PATCH] Implemented Luminous Broodmoth --- .../src/mage/cards/l/LuminousBroodmoth.java | 134 ++++++++++++++++++ .../src/mage/sets/IkoriaLairOfBehemoths.java | 1 + 2 files changed, 135 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/l/LuminousBroodmoth.java diff --git a/Mage.Sets/src/mage/cards/l/LuminousBroodmoth.java b/Mage.Sets/src/mage/cards/l/LuminousBroodmoth.java new file mode 100644 index 00000000000..cad7881b473 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LuminousBroodmoth.java @@ -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; + } +} diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 9b147039a3b..1b1aab9218e 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -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));