From f2272045ad6f242e19e9efd4828e8305e8ea56b2 Mon Sep 17 00:00:00 2001 From: Steven Knipe Date: Thu, 20 Feb 2025 13:47:33 -0800 Subject: [PATCH] Genericize BroodOfCockroaches, make it one effect --- .../src/mage/cards/b/BroodOfCockroaches.java | 54 ++++--------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/BroodOfCockroaches.java b/Mage.Sets/src/mage/cards/b/BroodOfCockroaches.java index 28b4e7998f2..9e3b9fd2a2c 100644 --- a/Mage.Sets/src/mage/cards/b/BroodOfCockroaches.java +++ b/Mage.Sets/src/mage/cards/b/BroodOfCockroaches.java @@ -1,26 +1,20 @@ package mage.cards.b; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; -import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.LoseLifeSourceControllerEffect; -import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.game.Game; -import mage.target.targetpointer.FixedTarget; import java.util.UUID; /** - * @author mpouedras + * @author mpouedras, notgreat */ public final class BroodOfCockroaches extends CardImpl { @@ -33,7 +27,14 @@ public final class BroodOfCockroaches extends CardImpl { // When Brood of Cockroaches is put into your graveyard from the battlefield, // at the beginning of the next end step, you lose 1 life and return Brood of Cockroaches to your hand. - this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new BroodOfCockroachesEffect(), false, true)); + + AtTheBeginOfNextEndStepDelayedTriggeredAbility delayed = + new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1)); + + delayed.addEffect(new ReturnSourceFromGraveyardToHandEffect().concatBy("and")); + CreateDelayedTriggeredAbilityEffect delayedEffect = new CreateDelayedTriggeredAbilityEffect(delayed); + + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(delayedEffect, false, true)); } private BroodOfCockroaches(final BroodOfCockroaches card) { @@ -45,36 +46,3 @@ public final class BroodOfCockroaches extends CardImpl { return new BroodOfCockroaches(this); } } - -class BroodOfCockroachesEffect extends OneShotEffect { - private static final String effectText = "at the beginning of the next end step, you lose 1 life and return {this} to your hand."; - - BroodOfCockroachesEffect() { - super(Outcome.Benefit); - staticText = effectText; - } - - private BroodOfCockroachesEffect(final BroodOfCockroachesEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = - new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1)); - game.addDelayedTriggeredAbility(delayedLifeLost, source); - - Effect effect = new ReturnToHandTargetEffect(); - effect.setText("return {this} to your hand."); - effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter())); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); - game.addDelayedTriggeredAbility(delayedAbility, source); - - return true; - } - - @Override - public BroodOfCockroachesEffect copy() { - return new BroodOfCockroachesEffect(this); - } -}