mirror of
https://github.com/magefree/mage.git
synced 2026-01-22 11:19:55 -08:00
[WWK] Rest for the Weary
This commit is contained in:
parent
d587714138
commit
67bd84d603
6 changed files with 137 additions and 42 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
41
Mage/src/mage/watchers/common/LandfallWatcher.java
Normal file
41
Mage/src/mage/watchers/common/LandfallWatcher.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue