forked from External/mage
Genericize BroodOfCockroaches, make it one effect
This commit is contained in:
parent
2d827c9375
commit
f2272045ad
1 changed files with 11 additions and 43 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue