Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions Mage.Sets/src/mage/cards/d/DepthshakerTitan.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.abilities.effects.common.continuous.AddCardTypeTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
Expand All @@ -17,8 +17,16 @@
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTargets;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledArtifactPermanent;
import mage.filter.predicate.Predicates;
Expand Down Expand Up @@ -51,11 +59,7 @@ public DepthshakerTitan(UUID ownerId, CardSetInfo setInfo) {
ability.addEffect(new SetBasePowerToughnessTargetEffect(
3, 3, Duration.Custom
).setText(" become 3/3 artifact creatures"));
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(
new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new SacrificeTargetEffect().setText("sacrifice those artifacts")
), true
).withCopyToPointer(true).setText("Sacrifice them at the beginning of the next end step"));
Comment thread
muz marked this conversation as resolved.
ability.addEffect(new DepthshakerTitanEffect());
ability.addTarget(new TargetPermanent(0, Integer.MAX_VALUE, filter));
this.addAbility(ability);

Expand Down Expand Up @@ -84,3 +88,36 @@ public DepthshakerTitan copy() {
return new DepthshakerTitan(this);
}
}

class DepthshakerTitanEffect extends OneShotEffect {

DepthshakerTitanEffect() {
super(Outcome.Sacrifice);
staticText = "Sacrifice them at the beginning of the next end step";
}

private DepthshakerTitanEffect(final DepthshakerTitanEffect effect) {
super(effect);
}

@Override
public DepthshakerTitanEffect copy() {
return new DepthshakerTitanEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = source.getTargets().get(0).getTargets()
Comment thread
muz marked this conversation as resolved.
.stream()
.map(game::getPermanent)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (permanents.isEmpty()) {
return false;
}
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice those artifacts");
sacrificeEffect.setTargetPointer(new FixedTargets(permanents, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class CreateDelayedTriggeredAbilityEffect extends OneShotEffect {
private final DelayedTriggeredAbility ability;
private final boolean copyTargets;
private final String rulePrefix;
private boolean copyToPointer = false;

public CreateDelayedTriggeredAbilityEffect(DelayedTriggeredAbility ability) {
this(ability, true);
}
Expand All @@ -39,7 +37,6 @@ protected CreateDelayedTriggeredAbilityEffect(final CreateDelayedTriggeredAbilit
this.ability = effect.ability.copy();
this.copyTargets = effect.copyTargets;
this.rulePrefix = effect.rulePrefix;
this.copyToPointer = effect.copyToPointer;
}

@Override
Expand All @@ -51,7 +48,7 @@ public CreateDelayedTriggeredAbilityEffect copy() {
public boolean apply(Game game, Ability source) {
DelayedTriggeredAbility delayedAbility = ability.copy();
if (this.copyTargets) {
if (copyToPointer || source.getTargets().isEmpty()) {
if (source.getTargets().isEmpty()) {
delayedAbility.getEffects().setTargetPointer(this.getTargetPointer().copy());
} else {
delayedAbility.getTargets().addAll(source.getTargets());
Expand Down Expand Up @@ -92,11 +89,6 @@ public CreateDelayedTriggeredAbilityEffect setTargetPointer(TargetPointer target
return this;
}

public CreateDelayedTriggeredAbilityEffect withCopyToPointer(boolean copyToPointer) {
this.copyToPointer = copyToPointer;
Comment thread
muz marked this conversation as resolved.
return this;
}

@Override
public CreateDelayedTriggeredAbilityEffect withTargetDescription(String target) {
ability.getEffects().forEach(effect -> effect.withTargetDescription(target));
Expand Down
Loading