mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
refacted SourceTappedCondition to use a single enum
This commit is contained in:
parent
d54fdb71b1
commit
25f47bde63
47 changed files with 61 additions and 64 deletions
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -8,21 +6,22 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public enum SourceTappedCondition implements Condition {
|
||||
TAPPED(true),
|
||||
UNTAPPED(false);
|
||||
private final boolean tapped;
|
||||
|
||||
instance;
|
||||
SourceTappedCondition(boolean tapped) {
|
||||
this.tapped = tapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
return permanent.isTapped();
|
||||
}
|
||||
return false;
|
||||
return permanent != null && permanent.isTapped() == tapped;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import mage.game.events.GameEvent;
|
|||
public class DontUntapAsLongAsSourceTappedEffect extends ConditionalContinuousRuleModifyingEffect {
|
||||
|
||||
public DontUntapAsLongAsSourceTappedEffect() {
|
||||
super(new DontUntapInControllersUntapStepTargetEffect(Duration.Custom), SourceTappedCondition.instance);
|
||||
super(new DontUntapInControllersUntapStepTargetEffect(Duration.Custom), SourceTappedCondition.TAPPED);
|
||||
staticText = "It doesn't untap during its controller's untap step for as long as {this} remains tapped.";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue