mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Nettling Impl - Fixed that the conditional delayed destroy ability did not work corretly (fixes #4142).
This commit is contained in:
parent
583033ff3b
commit
9e4beb6b51
3 changed files with 131 additions and 18 deletions
|
|
@ -28,7 +28,9 @@
|
|||
package mage.abilities.common.delayed;
|
||||
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
@ -42,6 +44,7 @@ import mage.game.permanent.Permanent;
|
|||
public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
private TargetController targetController;
|
||||
private Condition condition;
|
||||
|
||||
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Effect effect) {
|
||||
this(effect, TargetController.ANY);
|
||||
|
|
@ -52,14 +55,20 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
|
|||
}
|
||||
|
||||
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone zone, Effect effect, TargetController targetController) {
|
||||
super(effect);
|
||||
this(zone, effect, targetController, null);
|
||||
}
|
||||
|
||||
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone zone, Effect effect, TargetController targetController, Condition condition) {
|
||||
super(effect, Duration.EndOfTurn);
|
||||
this.zone = zone;
|
||||
this.targetController = targetController;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(final AtTheBeginOfNextEndStepDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.targetController = ability.targetController;
|
||||
this.condition = ability.condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -69,27 +78,34 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
boolean correctEndPhase = false;
|
||||
switch (targetController) {
|
||||
case ANY:
|
||||
return true;
|
||||
correctEndPhase = true;
|
||||
break;
|
||||
case YOU:
|
||||
return event.getPlayerId().equals(this.controllerId);
|
||||
|
||||
correctEndPhase = event.getPlayerId().equals(this.controllerId);
|
||||
break;
|
||||
case OPPONENT:
|
||||
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||
return true;
|
||||
correctEndPhase = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONTROLLER_ATTACHED_TO:
|
||||
Permanent attachment = game.getPermanent(sourceId);
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
return true;
|
||||
correctEndPhase = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (correctEndPhase) {
|
||||
if (condition != null && !condition.apply(game, this)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue