forked from External/mage
[LTR] Implement King of the Oathbreakers (#10619)
* make a new BecomesTargetTriggeredAbility to filter on target permanents.
This commit is contained in:
parent
2188c690c6
commit
2c505bbcac
48 changed files with 313 additions and 127 deletions
|
|
@ -3,8 +3,10 @@ package mage.abilities.common;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -12,9 +14,16 @@ import mage.game.events.GameEvent;
|
|||
*/
|
||||
public class PhaseInTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public PhaseInTriggeredAbility(Effect effect, boolean optional) {
|
||||
private FilterPermanent filter;
|
||||
|
||||
public PhaseInTriggeredAbility(Effect effect, FilterPermanent filter) {
|
||||
this(effect, filter, false);
|
||||
}
|
||||
|
||||
public PhaseInTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
setTriggerPhrase("When {this} phases in, ");
|
||||
this.filter = filter;
|
||||
setTriggerPhrase("Whenever " + filter.getMessage() + " phases in, ");
|
||||
}
|
||||
|
||||
public PhaseInTriggeredAbility(final PhaseInTriggeredAbility ability) {
|
||||
|
|
@ -33,6 +42,7 @@ public class PhaseInTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return getSourceId().equals(event.getTargetId());
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return permanent != null && filter.match(permanent, getControllerId(), this, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue