mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
Fix Spectral Prison rules text. Add filter support to BecomesTargetAttachedTriggeredAbility
This commit is contained in:
parent
6113c5e2e0
commit
62bc6ed848
7 changed files with 36 additions and 205 deletions
|
|
@ -1,12 +1,14 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
|
|
@ -15,19 +17,26 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class BecomesTargetAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterStackObject filter;
|
||||
private final String enchantType;
|
||||
|
||||
public BecomesTargetAttachedTriggeredAbility(Effect effect) {
|
||||
this(effect, "creature");
|
||||
this(effect, StaticFilters.FILTER_SPELL_OR_ABILITY_A);
|
||||
}
|
||||
|
||||
public BecomesTargetAttachedTriggeredAbility(Effect effect, String enchantType) {
|
||||
public BecomesTargetAttachedTriggeredAbility(Effect effect, FilterStackObject filter) {
|
||||
this(effect, filter, "creature");
|
||||
}
|
||||
|
||||
public BecomesTargetAttachedTriggeredAbility(Effect effect, FilterStackObject filter, String enchantType) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this.filter = filter.copy();
|
||||
this.enchantType = enchantType;
|
||||
}
|
||||
|
||||
public BecomesTargetAttachedTriggeredAbility(final BecomesTargetAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter.copy();
|
||||
this.enchantType = ability.enchantType;
|
||||
}
|
||||
|
||||
|
|
@ -44,8 +53,10 @@ public class BecomesTargetAttachedTriggeredAbility extends TriggeredAbilityImpl
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchantment = game.getPermanent(sourceId);
|
||||
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
if (event.getTargetId().equals(enchantment.getAttachedTo())) {
|
||||
if (event.getTargetId().equals(enchantment.getAttachedTo())
|
||||
&& filter.match(sourceObject, getSourceId(), getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +65,6 @@ public class BecomesTargetAttachedTriggeredAbility extends TriggeredAbilityImpl
|
|||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "When enchanted " + enchantType + " becomes the target of a spell or ability, " ;
|
||||
return "When enchanted " + enchantType + " becomes the target of " + filter.getMessage() + ", ";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue