forked from External/mage
implement [ACR] Senu, Keen-Eyed Protector ; small refactor on AttacksAndIsNotBlockedTriggeredAbility's setTargetPointer
This commit is contained in:
parent
c41052066d
commit
9bc1289341
21 changed files with 426 additions and 140 deletions
|
|
@ -2,6 +2,7 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -10,17 +11,17 @@ import mage.target.targetpointer.FixedTarget;
|
|||
|
||||
public class AttacksAndIsNotBlockedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final boolean setTargetPointer;
|
||||
private final SetTargetPointer setTargetPointer;
|
||||
|
||||
public AttacksAndIsNotBlockedTriggeredAbility(Effect effect) {
|
||||
this(effect, false, false);
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public AttacksAndIsNotBlockedTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, false);
|
||||
this(effect, optional, SetTargetPointer.NONE);
|
||||
}
|
||||
|
||||
public AttacksAndIsNotBlockedTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
public AttacksAndIsNotBlockedTriggeredAbility(Effect effect, boolean optional, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
setTriggerPhrase("Whenever {this} attacks and isn't blocked, ");
|
||||
|
|
@ -47,10 +48,16 @@ public class AttacksAndIsNotBlockedTriggeredAbility extends TriggeredAbilityImpl
|
|||
if (!event.getTargetId().equals(getSourceId())) {
|
||||
return false;
|
||||
}
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(
|
||||
game.getCombat().getDefendingPlayerId(getSourceId(), game), game
|
||||
));
|
||||
switch (setTargetPointer) {
|
||||
case NONE:
|
||||
break;
|
||||
case PLAYER:
|
||||
this.getEffects().setTargetPointer(new FixedTarget(
|
||||
game.getCombat().getDefendingPlayerId(getSourceId(), game), game
|
||||
));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Wrong code usage: not supported setTargetPointer");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue