mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Improved CreatureEntersBattlefieldTriggeredAbility: if a target is required for the effect then that target must be added in the constructor.
This commit is contained in:
parent
3e3957e323
commit
0e7ef05c5d
2 changed files with 25 additions and 6 deletions
|
@ -34,6 +34,7 @@ import mage.MageInt;
|
||||||
import mage.abilities.common.CreatureEntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.CreatureEntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -51,7 +52,7 @@ public class BloodSeeker extends CardImpl<BloodSeeker> {
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
this.addAbility(new CreatureEntersBattlefieldTriggeredAbility(new LoseLifeTargetEffect(1), true, true));
|
this.addAbility(new CreatureEntersBattlefieldTriggeredAbility(new LoseLifeTargetEffect(1), true, true, new TargetPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BloodSeeker(final BloodSeeker card) {
|
public BloodSeeker(final BloodSeeker card) {
|
||||||
|
|
|
@ -36,7 +36,9 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.target.Target;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -76,7 +78,19 @@ public class CreatureEntersBattlefieldTriggeredAbility extends TriggeredAbilityI
|
||||||
public CreatureEntersBattlefieldTriggeredAbility(Effect effect, boolean optional, boolean opponentController) {
|
public CreatureEntersBattlefieldTriggeredAbility(Effect effect, boolean optional, boolean opponentController) {
|
||||||
super(Zone.BATTLEFIELD, effect, optional);
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
this.opponentController = opponentController;
|
this.opponentController = opponentController;
|
||||||
this.addTarget(new TargetPlayer());
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param effect
|
||||||
|
* @param optional
|
||||||
|
* @param opponentController
|
||||||
|
* @param target - needed if the ability targets a player or a creature
|
||||||
|
*/
|
||||||
|
public CreatureEntersBattlefieldTriggeredAbility(Effect effect, boolean optional, boolean opponentController, Target target) {
|
||||||
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
|
this.opponentController = opponentController;
|
||||||
|
this.addTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatureEntersBattlefieldTriggeredAbility(CreatureEntersBattlefieldTriggeredAbility ability) {
|
public CreatureEntersBattlefieldTriggeredAbility(CreatureEntersBattlefieldTriggeredAbility ability) {
|
||||||
|
@ -90,10 +104,14 @@ public class CreatureEntersBattlefieldTriggeredAbility extends TriggeredAbilityI
|
||||||
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
|
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
|
||||||
&& permanent.getCardType().contains(CardType.CREATURE)
|
&& permanent.getCardType().contains(CardType.CREATURE)
|
||||||
&& (permanent.getControllerId().equals(this.controllerId) ^ opponentController)) {
|
&& (permanent.getControllerId().equals(this.controllerId) ^ opponentController)) {
|
||||||
if (opponentController) {
|
if (!this.getTargets().isEmpty()) {
|
||||||
this.getTargets().get(0).add(permanent.getControllerId(), game);
|
Target target = this.getTargets().get(0);
|
||||||
} else {
|
if (target instanceof TargetPlayer) {
|
||||||
this.getTargets().remove(0);
|
target.add(permanent.getControllerId(), game);
|
||||||
|
}
|
||||||
|
if (target instanceof TargetCreaturePermanent) {
|
||||||
|
target.add(event.getTargetId(), game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue