[WWK] Rest for the Weary

This commit is contained in:
Loki 2011-11-06 00:22:51 +04:00
parent d587714138
commit 67bd84d603
6 changed files with 137 additions and 42 deletions

View file

@ -0,0 +1,26 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.watchers.Watcher;
/**
* @author Loki
*/
public class LandfallCondition implements Condition {
private static LandfallCondition instance = new LandfallCondition();
public static LandfallCondition getInstance() {
return instance;
}
private LandfallCondition() {
}
@Override
public boolean apply(Game game, Ability source) {
Watcher watcher = game.getState().getWatchers().get("LandPlayed", source.getControllerId());
return watcher.conditionMet();
}
}

View file

@ -0,0 +1,41 @@
package mage.watchers.common;
import mage.Constants;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.watchers.WatcherImpl;
/**
* @author BetaSteward_at_googlemail.com
* @author Loki
*/
public class LandfallWatcher extends WatcherImpl<LandfallWatcher> {
public LandfallWatcher() {
super("LandPlayed", Constants.WatcherScope.PLAYER);
}
public LandfallWatcher(final LandfallWatcher watcher) {
super(watcher);
}
@Override
public LandfallWatcher copy() {
return new LandfallWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (condition == true) //no need to check - condition has already occured
return;
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Constants.Zone.BATTLEFIELD) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.getCardType().contains(Constants.CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
condition = true;
}
}
}
}