[EOE] Implement Temporal Intervention

This commit is contained in:
theelk801 2025-07-07 15:03:16 -04:00
parent 7582123f55
commit 442530993c
6 changed files with 137 additions and 0 deletions

View file

@ -0,0 +1,32 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint;
import mage.game.Game;
import mage.watchers.common.VoidWatcher;
/**
* Requires {@link mage.watchers.common.VoidWatcher}
*
* @author TheElk801
*/
public enum VoidCondition implements Condition {
instance;
private static final Hint hint = new ConditionHint(instance);
public static Hint getHint() {
return hint;
}
@Override
public boolean apply(Game game, Ability source) {
return VoidWatcher.checkPlayer(source.getControllerId(), game);
}
@Override
public String toString() {
return "a nonland permanent left the battlefield this turn or a spell was warped this turn";
}
}

View file

@ -63,6 +63,7 @@ public enum AbilityWord {
THRESHOLD("Threshold"),
UNDERGROWTH("Undergrowth"),
VALIANT("Valiant"),
VOID("Void"),
WILL_OF_THE_COUNCIL("Will of the council"),
WILL_OF_THE_PLANESWALKERS("Will of the planeswalkers");

View file

@ -0,0 +1,56 @@
package mage.watchers.common;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* TODO: this doesn't handle warp yet
*
* @author TheElk801
*/
public class VoidWatcher extends Watcher {
// need to track separately for each player as it needs to be in range
private final Set<UUID> players = new HashSet<>();
public VoidWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
switch (event.getType()) {
case SPELL_CAST:
return;
case ZONE_CHANGE:
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (Zone.BATTLEFIELD.match(zEvent.getFromZone())
&& zEvent.getTarget() != null
&& !zEvent.getTarget().isLand(game)) {
players.addAll(game.getState().getPlayersInRange(zEvent.getTarget().getControllerId(), game));
}
}
}
@Override
public void reset() {
super.reset();
players.clear();
}
public static boolean checkPlayer(UUID playerId, Game game) {
return game
.getState()
.getWatcher(VoidWatcher.class)
.players
.contains(playerId);
}
}