mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Much simpler way to implement DontUntapAsLongAsSourceTappedEffect.
This also works correctly when the source permanent untaps and then taps again.
This commit is contained in:
parent
d9e1a72ad1
commit
705bdabafb
1 changed files with 10 additions and 20 deletions
|
@ -30,20 +30,22 @@ package mage.abilities.effects.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.RestrictionEffect;
|
import mage.abilities.condition.common.SourceTappedCondition;
|
||||||
|
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
|
||||||
|
import mage.abilities.effects.common.DontUntapInControllersUntapStepTargetEffect;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DontUntapAsLongAsSourceTappedEffect extends RestrictionEffect {
|
public class DontUntapAsLongAsSourceTappedEffect extends ConditionalContinuousRuleModifyingEffect {
|
||||||
|
|
||||||
public DontUntapAsLongAsSourceTappedEffect() {
|
public DontUntapAsLongAsSourceTappedEffect() {
|
||||||
super(Duration.WhileOnBattlefield);
|
super(new DontUntapInControllersUntapStepTargetEffect(Duration.Custom), SourceTappedCondition.getInstance());
|
||||||
staticText = "It doesn't untap during its controller's untap step for as long as {source} remains tapped.";
|
staticText = "It doesn't untap during its controller's untap step for as long as {source} remains tapped.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,23 +54,11 @@ public class DontUntapAsLongAsSourceTappedEffect extends RestrictionEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
if(event.getType() == GameEvent.EventType.UNTAP && event.getTargetId().equals(source.getSourceId())) {
|
||||||
if(sourcePermanent != null && sourcePermanent.isTapped()) {
|
effect.discard();
|
||||||
String name = sourcePermanent.getName();
|
|
||||||
if(sourcePermanent.getConnectedCards(name).size() > 0) {
|
|
||||||
UUID target = sourcePermanent.getConnectedCards(name).get(0);
|
|
||||||
if(target != null && target.equals(permanent.getId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return super.applies(event, source, game);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeUntapped(Permanent permanent, Ability source, Game game) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue