Reworking "as long as you control this" effects (WIP) (#8620)

* added WhileControlled duration, removed SourceOnBattlefieldControlUnchangedCondition

* refactored effects which keep things tapped

* a few additional missed cards

* refactored cards which check for being controlled and tapped

* [NEO] Implemented Kyodai, Soul of Kamigawa
This commit is contained in:
Evan Kranzler 2022-01-30 22:00:10 -05:00 committed by GitHub
parent 0ca75806fe
commit d030848552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 495 additions and 1239 deletions

View file

@ -1,7 +1,5 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
@ -12,18 +10,27 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleModifyingEffectImpl {
private final String targetName;
public DontUntapInControllersUntapStepTargetEffect(Duration duration) {
this(duration, "That creature");
}
public DontUntapInControllersUntapStepTargetEffect(Duration duration, String targetName) {
super(duration, Outcome.Detriment);
this.targetName = targetName;
}
public DontUntapInControllersUntapStepTargetEffect(final DontUntapInControllersUntapStepTargetEffect effect) {
super(effect);
this.targetName = effect.targetName;
}
@Override
@ -36,16 +43,6 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM
return false;
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
Permanent permanentToUntap = game.getPermanent((event.getTargetId()));
if (permanentToUntap != null && mageObject != null) {
return permanentToUntap.getIdName() + " doesn't untap (" + mageObject.getIdName() + ')';
}
return null;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP;
@ -53,14 +50,16 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
for (UUID targetId : targetPointer.getTargets(game, source)) {
if (event.getTargetId().equals(targetId)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && game.isActivePlayer(permanent.getControllerId())) {
return true;
}
}
if (game.getTurn().getStepType() != PhaseStep.UNTAP) {
return false;
}
for (UUID targetId : targetPointer.getTargets(game, source)) {
if (!event.getTargetId().equals(targetId)) {
continue;
}
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && game.isActivePlayer(permanent.getControllerId())) {
return true;
}
}
return false;
@ -68,11 +67,11 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM
@Override
public String getText(Mode mode) {
if (staticText != null) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "target " + mode.getTargets().get(0).getTargetName()
+ " doesn't untap during its controller's untap step" + (getDuration().toString().isEmpty() ? "" : " " + getDuration());
return targetName + " doesn't untap during its controller's untap step"
+ (getDuration().toString().isEmpty() ? "" : " ") + getDuration();
}
}