Fix BecomesBlockedAttachedTriggeredAbility (#9325)

This commit is contained in:
Alex W. Jackson 2022-07-27 00:41:22 -04:00
parent 4b511775db
commit 516ac042a2
13 changed files with 134 additions and 433 deletions

View file

@ -6,15 +6,14 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -32,9 +31,7 @@ public final class DelifsCone extends CardImpl {
// {tap}, Sacrifice Delif's Cone: This turn, when target creature you control attacks and isn't blocked, you may gain life equal to its power. If you do, it assigns no combat damage this turn.
Ability ability = new SimpleActivatedAbility(
new CreateDelayedTriggeredAbilityEffect(
new DelifsConeTriggeredAbility(), false
), new TapSourceCost()
new CreateDelayedTriggeredAbilityEffect(new DelifsConeTriggeredAbility()), new TapSourceCost()
);
ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetControlledCreaturePermanent());
@ -55,7 +52,7 @@ class DelifsConeTriggeredAbility extends DelayedTriggeredAbility {
DelifsConeTriggeredAbility() {
super(new DelifsConeLifeEffect(), Duration.EndOfTurn, false, true);
this.addEffect(new DelifsConePreventEffect());
this.addEffect(new AssignNoCombatDamageTargetEffect());
}
private DelifsConeTriggeredAbility(final DelifsConeTriggeredAbility ability) {
@ -110,45 +107,3 @@ class DelifsConeLifeEffect extends OneShotEffect {
return false;
}
}
class DelifsConePreventEffect extends ReplacementEffectImpl {
DelifsConePreventEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
}
private DelifsConePreventEffect(final DelifsConePreventEffect effect) {
super(effect);
}
@Override
public DelifsConePreventEffect copy() {
return new DelifsConePreventEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch (event.getType()) {
case DAMAGE_PERMANENT:
case DAMAGE_PLAYER:
return true;
default:
return false;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return ((DamageEvent) event).isCombatDamage() && event.getTargetId().equals(targetPointer.getFirst(game, source));
}
}

View file

@ -6,9 +6,9 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.RegenerateTargetEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -17,7 +17,6 @@ import mage.constants.Duration;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.target.common.TargetControlledCreaturePermanent;
@ -59,7 +58,7 @@ public final class DelifsCube extends CardImpl {
class DelifsCubeTriggeredAbility extends DelayedTriggeredAbility {
DelifsCubeTriggeredAbility() {
super(new DelifsCubePreventEffect(), Duration.EndOfTurn, false, false);
super(new AssignNoCombatDamageTargetEffect(Duration.EndOfTurn, "it assigns no combat damage this turn"), Duration.EndOfTurn, false, false);
this.addEffect(new AddCountersSourceEffect(CounterType.CUBE.createInstance()));
}
@ -88,45 +87,3 @@ class DelifsCubeTriggeredAbility extends DelayedTriggeredAbility {
"it assigns no combat damage this turn and you put a cube counter on {this}.";
}
}
class DelifsCubePreventEffect extends ReplacementEffectImpl {
DelifsCubePreventEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
}
private DelifsCubePreventEffect(final DelifsCubePreventEffect effect) {
super(effect);
}
@Override
public DelifsCubePreventEffect copy() {
return new DelifsCubePreventEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch (event.getType()) {
case DAMAGE_PERMANENT:
case DAMAGE_PLAYER:
return true;
default:
return false;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return ((DamageEvent) event).isCombatDamage() && event.getTargetId().equals(targetPointer.getFirst(game, source));
}
}

View file

@ -4,15 +4,14 @@ import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -66,7 +65,7 @@ class GazeOfPainDelayedTriggeredAbility extends DelayedTriggeredAbility {
}
this.getEffects().clear();
this.addEffect(new GazeOfPainEffect(new MageObjectReference(event.getTargetId(), game)));
this.addEffect(new GazeOfPainDamageEffect().setTargetPointer(new FixedTarget(event.getTargetId(), game)));
this.addEffect(new AssignNoCombatDamageTargetEffect().setTargetPointer(new FixedTarget(event.getTargetId(), game)));
return true;
}
@ -113,45 +112,3 @@ class GazeOfPainEffect extends OneShotEffect {
&& targeted.damage(creature.getPower().getValue(), creature.getId(), source, game) > 0;
}
}
class GazeOfPainDamageEffect extends ReplacementEffectImpl {
GazeOfPainDamageEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
}
private GazeOfPainDamageEffect(final GazeOfPainDamageEffect effect) {
super(effect);
}
@Override
public GazeOfPainDamageEffect copy() {
return new GazeOfPainDamageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch (event.getType()) {
case DAMAGE_PERMANENT:
case DAMAGE_PLAYER:
return true;
default:
return false;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return ((DamageEvent) event).isCombatDamage() && event.getSourceId().equals(targetPointer.getFirst(game, source));
}
}

View file

@ -1,26 +1,22 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author L_J
* @author awjackson
*/
public final class LaccolithGrunt extends CardImpl {
@ -31,7 +27,7 @@ public final class LaccolithGrunt extends CardImpl {
this.toughness = new MageInt(2);
// Whenever Laccolith Grunt becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new LaccolithEffect().setText("you may have it deal damage equal to its power to target creature"), true);
Ability ability = new BecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(new SourcePermanentPowerCount()).setText("it deal damage equal to its power to target creature"), true);
ability.addEffect(new AssignNoCombatDamageSourceEffect(Duration.EndOfTurn, true));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
@ -45,41 +41,4 @@ public final class LaccolithGrunt extends CardImpl {
public LaccolithGrunt copy() {
return new LaccolithGrunt(this);
}
class LaccolithEffect extends OneShotEffect {
public LaccolithEffect() {
super(Outcome.Damage);
staticText = "{this} deals damage equal to its power to target creature";
}
public LaccolithEffect(final LaccolithEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent == null) {
return false;
}
int damage = sourcePermanent.getPower().getValue();
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(damage, sourcePermanent.getId(), source, game, false, true);
return true;
}
return false;
}
@Override
public LaccolithEffect copy() {
return new LaccolithEffect(this);
}
}
}

View file

@ -4,19 +4,13 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedAttachedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageSourceEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
@ -24,7 +18,7 @@ import mage.target.common.TargetCreaturePermanent;
/**
*
* @author L_J
* @author awjackson
*/
public final class LaccolithRig extends CardImpl {
@ -35,16 +29,15 @@ public final class LaccolithRig extends CardImpl {
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted creature becomes blocked, you may have it deal damage equal to its power to target creature. If you do, the first creature assigns no combat damage this turn.
Ability ability2 = new BecomesBlockedAttachedTriggeredAbility(new LaccolithRigEffect(), true);
ability2.addTarget(new TargetCreaturePermanent());
Effect effect = new GainAbilityTargetEffect(new SimpleStaticAbility(Zone.BATTLEFIELD, new AssignNoCombatDamageSourceEffect(Duration.Custom, true).setText("")), Duration.EndOfTurn, "If you do, the first creature assigns no combat damage this turn");
ability2.addEffect(effect);
this.addAbility(ability2);
// Whenever enchanted creature becomes blocked, you may have it deal damage equal to its power to target creature.
// If you do, the first creature assigns no combat damage this turn.
Ability ability = new BecomesBlockedAttachedTriggeredAbility(new LaccolithRigEffect(), true, SetTargetPointer.PERMANENT);
ability.addEffect(new AssignNoCombatDamageTargetEffect(Duration.EndOfTurn, "if you do, the first creature assigns no combat damage this turn"));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
private LaccolithRig(final LaccolithRig card) {
@ -61,7 +54,7 @@ class LaccolithRigEffect extends OneShotEffect {
public LaccolithRigEffect() {
super(Outcome.Damage);
this.staticText = "you may have it deal damage equal to its power to target creature";
this.staticText = "it deal damage equal to its power to target creature";
}
public LaccolithRigEffect(final LaccolithRigEffect effect) {
@ -75,24 +68,12 @@ class LaccolithRigEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment == null) {
Permanent ownCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent targetCreature = game.getPermanent(source.getTargets().get(0).getFirstTarget());
if (ownCreature == null || targetCreature == null) {
return false;
}
Permanent ownCreature = game.getPermanent(enchantment.getAttachedTo());
if (ownCreature != null) {
int damage = ownCreature.getPower().getValue();
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
targetCreature.damage(damage, ownCreature.getId(), source, game, false, true);
targetCreature.damage(ownCreature.getPower().getValue(), ownCreature.getId(), source, game, false, true);
return true;
}
}
return false;
}
}

View file

@ -1,26 +1,22 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author L_J
* @author awjackson
*/
public final class LaccolithTitan extends CardImpl {
@ -30,8 +26,8 @@ public final class LaccolithTitan extends CardImpl {
this.power = new MageInt(6);
this.toughness = new MageInt(6);
// Whenever Laccolith Grunt becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new LaccolithEffect().setText("you may have it deal damage equal to its power to target creature"), true);
// Whenever Laccolith Titan becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(new SourcePermanentPowerCount()).setText("it deal damage equal to its power to target creature"), true);
ability.addEffect(new AssignNoCombatDamageSourceEffect(Duration.EndOfTurn, true));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
@ -45,41 +41,4 @@ public final class LaccolithTitan extends CardImpl {
public LaccolithTitan copy() {
return new LaccolithTitan(this);
}
class LaccolithEffect extends OneShotEffect {
public LaccolithEffect() {
super(Outcome.Damage);
staticText = "{this} deals damage equal to its power to target creature";
}
public LaccolithEffect(final LaccolithEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent == null) {
return false;
}
int damage = sourcePermanent.getPower().getValue();
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(damage, sourcePermanent.getId(), source, game, false, true);
return true;
}
return false;
}
@Override
public LaccolithEffect copy() {
return new LaccolithEffect(this);
}
}
}

View file

@ -1,26 +1,22 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author L_J
* @author awjackson
*/
public final class LaccolithWarrior extends CardImpl {
@ -31,8 +27,8 @@ public final class LaccolithWarrior extends CardImpl {
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Whenever Laccolith Grunt becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new LaccolithEffect().setText("you may have it deal damage equal to its power to target creature"), true);
// Whenever Laccolith Warrior becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(new SourcePermanentPowerCount()).setText("it deal damage equal to its power to target creature"), true);
ability.addEffect(new AssignNoCombatDamageSourceEffect(Duration.EndOfTurn, true));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
@ -46,41 +42,4 @@ public final class LaccolithWarrior extends CardImpl {
public LaccolithWarrior copy() {
return new LaccolithWarrior(this);
}
class LaccolithEffect extends OneShotEffect {
public LaccolithEffect() {
super(Outcome.Damage);
staticText = "{this} deals damage equal to its power to target creature";
}
public LaccolithEffect(final LaccolithEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent == null) {
return false;
}
int damage = sourcePermanent.getPower().getValue();
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(damage, sourcePermanent.getId(), source, game, false, true);
return true;
}
return false;
}
@Override
public LaccolithEffect copy() {
return new LaccolithEffect(this);
}
}
}

View file

@ -1,26 +1,22 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.AssignNoCombatDamageSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author L_J
* @author awjackson
*/
public final class LaccolithWhelp extends CardImpl {
@ -30,8 +26,8 @@ public final class LaccolithWhelp extends CardImpl {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// Whenever Laccolith Grunt becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new LaccolithEffect().setText("you may have it deal damage equal to its power to target creature"), true);
// Whenever Laccolith Whelp becomes blocked, you may have it deal damage equal to its power to target creature. If you do, Laccolith Grunt assigns no combat damage this turn.
Ability ability = new BecomesBlockedSourceTriggeredAbility(new DamageTargetEffect(new SourcePermanentPowerCount()).setText("it deal damage equal to its power to target creature"), true);
ability.addEffect(new AssignNoCombatDamageSourceEffect(Duration.EndOfTurn, true));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
@ -45,41 +41,4 @@ public final class LaccolithWhelp extends CardImpl {
public LaccolithWhelp copy() {
return new LaccolithWhelp(this);
}
class LaccolithEffect extends OneShotEffect {
public LaccolithEffect() {
super(Outcome.Damage);
staticText = "{this} deals damage equal to its power to target creature";
}
public LaccolithEffect(final LaccolithEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent == null) {
return false;
}
int damage = sourcePermanent.getPower().getValue();
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(damage, sourcePermanent.getId(), source, game, false, true);
return true;
}
return false;
}
@Override
public LaccolithEffect copy() {
return new LaccolithEffect(this);
}
}
}

View file

@ -1,45 +1,39 @@
package mage.cards.p;
import java.util.List;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedAttachedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author jeffwadsworth
* @author awjackson
*/
public final class PretendersClaim extends CardImpl {
public PretendersClaim(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted creature becomes blocked, tap all lands defending player controls.
this.addAbility(new BecomesBlockedAttachedTriggeredAbility(new TapDefendingPlayerLandEffect(), false));
this.addAbility(new BecomesBlockedAttachedTriggeredAbility(
new TapAllTargetPlayerControlsEffect(StaticFilters.FILTER_LANDS)
.setText("tap all lands defending player controls"),
false, SetTargetPointer.PLAYER
));
}
private PretendersClaim(final PretendersClaim card) {
@ -51,37 +45,3 @@ public final class PretendersClaim extends CardImpl {
return new PretendersClaim(this);
}
}
class TapDefendingPlayerLandEffect extends OneShotEffect {
public TapDefendingPlayerLandEffect() {
super(Outcome.Tap);
staticText = "tap all lands defending player controls";
}
public TapDefendingPlayerLandEffect(final TapDefendingPlayerLandEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (aura != null
&& aura.getAttachedTo() != null) {
Player defendingPlayer = game.getPlayer(game.getCombat().getDefendingPlayerId(aura.getAttachedTo(), game));
if (defendingPlayer != null) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, defendingPlayer.getId(), game);
for (Permanent land : permanents) {
land.tap(source, game);
}
return true;
}
}
return false;
}
@Override
public TapDefendingPlayerLandEffect copy() {
return new TapDefendingPlayerLandEffect(this);
}
}

View file

@ -8,9 +8,7 @@ import mage.abilities.effects.common.TakeTheInitiativeEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -33,7 +31,7 @@ public final class TrailblazersTorch extends CardImpl {
// Whenever equipped creature becomes blocked, it deals 2 damage to each creature blocking it.
this.addAbility(new BecomesBlockedAttachedTriggeredAbility(
new TrailblazersTorchEffect(), false
new TrailblazersTorchEffect(), false, SetTargetPointer.PERMANENT
).setTriggerPhrase("Whenever equipped creature becomes blocked, "));
// Equip {1}

View file

@ -9,7 +9,7 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.Optional;
import java.util.UUID;
/**
* @author L_J
@ -39,16 +39,21 @@ public class BecomesBlockedAttachedTriggeredAbility extends TriggeredAbilityImpl
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = Optional
.ofNullable(getSourcePermanentOrLKI(game))
.map(Permanent::getAttachedTo)
.map(game::getPermanent)
.orElse(null);
if (permanent == null) {
Permanent enchantment = getSourcePermanentOrLKI(game);
UUID blockedId = event.getTargetId();
if (enchantment == null || !blockedId.equals(enchantment.getAttachedTo())) {
return false;
}
if (setTargetPointer == SetTargetPointer.PERMANENT) {
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
switch (setTargetPointer) {
case PERMANENT:
getEffects().setTargetPointer(new FixedTarget(blockedId, game));
break;
case PLAYER:
UUID playerId = game.getCombat().getDefendingPlayerId(blockedId, game);
if (playerId != null) {
getEffects().setTargetPointer(new FixedTarget(playerId));
}
break;
}
return true;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
@ -16,21 +15,17 @@ import mage.game.events.GameEvent;
public class AssignNoCombatDamageSourceEffect extends ReplacementEffectImpl {
private boolean partOfOptionalEffect;
public AssignNoCombatDamageSourceEffect(Duration duration) {
this(duration, false);
}
public AssignNoCombatDamageSourceEffect(Duration duration, boolean partOfOptionalEffect) {
super(duration, Outcome.PreventDamage);
this.partOfOptionalEffect = partOfOptionalEffect;
staticText = setText();
staticText = setText(partOfOptionalEffect);
}
public AssignNoCombatDamageSourceEffect(final AssignNoCombatDamageSourceEffect effect) {
super(effect);
this.partOfOptionalEffect = effect.partOfOptionalEffect;
}
@Override
@ -65,12 +60,8 @@ public class AssignNoCombatDamageSourceEffect extends ReplacementEffectImpl {
return event.getSourceId().equals(source.getSourceId()) && damageEvent.isCombatDamage();
}
private String setText() {
String text = "";
if(partOfOptionalEffect) {
text = "If you do, ";
}
text += "{this} assigns no combat damage";
private String setText(boolean partOfOptionalEffect) {
String text = (partOfOptionalEffect ? "If you do, " : "") + "{this} assigns no combat damage";
switch(duration) {
case EndOfTurn:
text += " this turn";

View file

@ -0,0 +1,61 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
/**
*
* @author awjackson
*/
public class AssignNoCombatDamageTargetEffect extends ReplacementEffectImpl {
public AssignNoCombatDamageTargetEffect() {
this(Duration.EndOfTurn, "if you do, it assigns no combat damage this turn");
}
public AssignNoCombatDamageTargetEffect(Duration duration, String text) {
super(duration, Outcome.PreventDamage);
staticText = text;
}
public AssignNoCombatDamageTargetEffect(final AssignNoCombatDamageTargetEffect effect) {
super(effect);
}
@Override
public AssignNoCombatDamageTargetEffect copy() {
return new AssignNoCombatDamageTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch (event.getType()) {
case DAMAGE_PERMANENT:
case DAMAGE_PLAYER:
return true;
default:
return false;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return ((DamageEvent) event).isCombatDamage() && event.getSourceId().equals(targetPointer.getFirst(game, source));
}
}