mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
cleanup custom source untapped conditions
This commit is contained in:
parent
595a1d6f14
commit
26605220f7
5 changed files with 16 additions and 122 deletions
|
|
@ -1,52 +0,0 @@
|
|||
|
||||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
|
||||
public class SourceTappedBeforeUntapStepCondition implements Condition {
|
||||
|
||||
UUID permanentId = null;
|
||||
boolean permanentWasTappedBeforeUntapStep = false;
|
||||
int lastTurnNum = -1;
|
||||
|
||||
|
||||
|
||||
public void setPermanentId(UUID permanentId) {
|
||||
this.permanentId = permanentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
TurnPhase turnPhase = game.getTurn().getPhase().getType();
|
||||
Step step = game.getPhase().getStep();
|
||||
Permanent permanent = game.getBattlefield().getPermanent(permanentId);
|
||||
|
||||
if (permanent != null) {
|
||||
if (lastTurnNum != game.getTurnNum() && turnPhase == TurnPhase.BEGINNING) {
|
||||
lastTurnNum = game.getTurnNum();
|
||||
permanentWasTappedBeforeUntapStep = permanent.isTapped();
|
||||
}
|
||||
|
||||
if (step.getType() == PhaseStep.UNTAP) {
|
||||
return permanentWasTappedBeforeUntapStep;
|
||||
} else {
|
||||
return permanent.isTapped();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ import mage.game.permanent.Permanent;
|
|||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public enum SourceTappedCondition implements Condition {
|
||||
TAPPED(true),
|
||||
UNTAPPED(false);
|
||||
|
|
@ -24,4 +23,9 @@ public enum SourceTappedCondition implements Condition {
|
|||
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
return permanent != null && permanent.isTapped() == tapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{this} is " + (tapped ? "tapped" : "untapped");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue