mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
BlocksSourceTriggeredAbility now triggers only once when the source somehow blocks multiple creatures. Cards that need the other way now use BlocksCreatureTriggeredAbility instead. Fixes #8874. Fixes #8875.
This commit is contained in:
parent
212bb075ee
commit
62655793da
40 changed files with 188 additions and 192 deletions
|
|
@ -7,8 +7,8 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author North
|
||||
|
|
@ -41,21 +41,16 @@ public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityIm
|
|||
if (!event.getTargetId().equals(this.getSourceId())) {
|
||||
return false;
|
||||
}
|
||||
Permanent blocker = game.getPermanent(event.getSourceId());
|
||||
if (!filter.match(blocker, game)) {
|
||||
if (!filter.match(game.getPermanent(event.getSourceId()), getControllerId(), this, game)) {
|
||||
return false;
|
||||
}
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
|
||||
}
|
||||
getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "Whenever {this} becomes blocked by "
|
||||
+ (filter.getMessage().startsWith("an ") ? "" : "a ")
|
||||
+ filter.getMessage() + ", " ;
|
||||
return "Whenever {this} becomes blocked by " + CardUtil.addArticle(filter.getMessage()) + ", ";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -16,6 +17,10 @@ public class BlocksCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
private final FilterCreaturePermanent filter;
|
||||
|
||||
public BlocksCreatureTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public BlocksCreatureTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, StaticFilters.FILTER_PERMANENT_CREATURE, optional);
|
||||
}
|
||||
|
|
@ -37,8 +42,14 @@ public class BlocksCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getSourceId().equals(this.getSourceId())
|
||||
&& filter.match(game.getPermanent(event.getTargetId()), getControllerId(), this, game);
|
||||
if (!event.getSourceId().equals(this.getSourceId())) {
|
||||
return false;
|
||||
}
|
||||
if (!filter.match(game.getPermanent(event.getTargetId()), getControllerId(), this, game)) {
|
||||
return false;
|
||||
}
|
||||
getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -6,7 +5,7 @@ import mage.abilities.TriggeredAbilityImpl;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -14,50 +13,32 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*/
|
||||
public class BlocksSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private boolean setTargetPointer;
|
||||
private boolean once = false;
|
||||
public BlocksSourceTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public BlocksSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, false);
|
||||
}
|
||||
|
||||
public BlocksSourceTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
this(effect, optional, setTargetPointer, false);
|
||||
}
|
||||
|
||||
public BlocksSourceTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer, boolean once) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
this.once = once;
|
||||
}
|
||||
|
||||
public BlocksSourceTriggeredAbility(final BlocksSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
this.once = ability.once;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
|
||||
return event.getType() == GameEvent.EventType.DECLARED_BLOCKERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(this.getSourceId())) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Permanent permanent = game.getPermanent(getSourceId());
|
||||
return permanent != null && permanent.getBlocking() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "When" + (once ? "" : "ever") + " {this} blocks" + (setTargetPointer ? " a creature, " : ", ") ;
|
||||
return "Whenever {this} blocks, ";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@ public class BoostSourceEffect extends ContinuousEffectImpl implements SourceEff
|
|||
private final boolean lockedIn;
|
||||
|
||||
public BoostSourceEffect(int power, int toughness, Duration duration) {
|
||||
this(StaticValue.get(power), StaticValue.get(toughness), duration, false);
|
||||
this(power, toughness, duration, "{this}");
|
||||
}
|
||||
|
||||
public BoostSourceEffect(int power, int toughness, Duration duration, String description) {
|
||||
this(StaticValue.get(power), StaticValue.get(toughness), duration, false, description);
|
||||
}
|
||||
|
||||
public BoostSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.BlocksSourceTriggeredAbility;
|
||||
import mage.abilities.common.BlocksCreatureTriggeredAbility;
|
||||
import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
|
@ -20,9 +20,8 @@ public final class MesmerizingBenthidToken extends TokenImpl {
|
|||
subtype.add(SubType.ILLUSION);
|
||||
power = new MageInt(0);
|
||||
toughness = new MageInt(2);
|
||||
this.addAbility(new BlocksSourceTriggeredAbility(
|
||||
new DontUntapInControllersNextUntapStepTargetEffect("that creature"),
|
||||
false, true
|
||||
this.addAbility(new BlocksCreatureTriggeredAbility(
|
||||
new DontUntapInControllersNextUntapStepTargetEffect("that creature")
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue