This commit is contained in:
Achilles 2017-07-16 10:31:22 -05:00
parent 20c8c1a9c9
commit 5cebe20768
4 changed files with 96 additions and 14 deletions

View file

@ -28,7 +28,6 @@
package mage.cards.r;
import mage.Mana;
import mage.abilities.condition.common.LandfallCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalManaEffect;
import mage.abilities.effects.common.BasicManaEffect;
@ -37,9 +36,10 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.watchers.common.LandfallWatcher;
import java.util.UUID;
import mage.abilities.condition.common.PlayLandCondition;
import mage.watchers.common.PlayLandWatcher;
/**
*
@ -48,16 +48,16 @@ import java.util.UUID;
public class RiverOfTears extends CardImpl {
public RiverOfTears(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
// {T}: Add {U} to your mana pool. If you played a land this turn, add {B} to your mana pool instead.
this.addAbility(new ConditionalManaAbility(Zone.BATTLEFIELD, new ConditionalManaEffect(
new BasicManaEffect(Mana.BlackMana(1)),
new BasicManaEffect(Mana.BlueMana(1)),
LandfallCondition.instance,
PlayLandCondition.instance,
"Add {U} to your mana pool. If you played a land this turn, add {B} to your mana pool instead"),
new TapSourceCost()),
new LandfallWatcher());
new TapSourceCost()),
new PlayLandWatcher());
}
public RiverOfTears(final RiverOfTears card) {

View file

@ -0,0 +1,20 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.watchers.common.PlayLandWatcher;
/**
* @author jeffwadsworth
*/
public enum PlayLandCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
PlayLandWatcher watcher = (PlayLandWatcher) game.getState().getWatchers().get(PlayLandWatcher.class.getSimpleName());
return watcher != null
&& watcher.landPlayed(source.getControllerId());
}
}

View file

@ -15,8 +15,8 @@ import mage.watchers.Watcher;
*/
public class LandfallWatcher extends Watcher {
final Set<UUID> playerPlayedLand = new HashSet<>(); // player that played land
final Set<UUID> landPlayed = new HashSet<>(); // land played
final Set<UUID> playerPlayedLand = new HashSet<>(); // player that had a land enter the battlefield
final Set<UUID> landEnteredBattlefield = new HashSet<>(); // land played
public LandfallWatcher() {
super(LandfallWatcher.class.getSimpleName(), WatcherScope.GAME);
@ -25,7 +25,7 @@ public class LandfallWatcher extends Watcher {
public LandfallWatcher(final LandfallWatcher watcher) {
super(watcher);
playerPlayedLand.addAll(watcher.playerPlayedLand);
landPlayed.addAll(watcher.landPlayed);
landEnteredBattlefield.addAll(watcher.landEnteredBattlefield);
}
@Override
@ -35,13 +35,13 @@ public class LandfallWatcher extends Watcher {
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.LAND_PLAYED) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent != null
&& permanent.isLand()
&& !playerPlayedLand.contains(event.getPlayerId())) {
playerPlayedLand.add(event.getPlayerId());
landPlayed.add(event.getTargetId());
landEnteredBattlefield.add(event.getTargetId());
}
}
}
@ -49,7 +49,7 @@ public class LandfallWatcher extends Watcher {
@Override
public void reset() {
playerPlayedLand.clear();
landPlayed.clear();
landEnteredBattlefield.clear();
super.reset();
}
@ -57,7 +57,7 @@ public class LandfallWatcher extends Watcher {
return playerPlayedLand.contains(playerId);
}
public boolean wasLandPlayed(UUID landId) {
return landPlayed.contains(landId);
public boolean landEnteredBattlefield(UUID landId) {
return landEnteredBattlefield.contains(landId);
}
}

View file

@ -0,0 +1,62 @@
package mage.watchers.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
/**
* @author jeffwadsworth
*/
public class PlayLandWatcher extends Watcher {
final Set<UUID> playerPlayedLand = new HashSet<>(); // player that played land
final Set<UUID> landPlayed = new HashSet<>(); // land played
public PlayLandWatcher() {
super(PlayLandWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public PlayLandWatcher(final PlayLandWatcher watcher) {
super(watcher);
playerPlayedLand.addAll(watcher.playerPlayedLand);
landPlayed.addAll(watcher.landPlayed);
}
@Override
public PlayLandWatcher copy() {
return new PlayLandWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.LAND_PLAYED) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent != null
&& permanent.isLand()
&& !playerPlayedLand.contains(event.getPlayerId())) {
playerPlayedLand.add(event.getPlayerId());
landPlayed.add(event.getTargetId());
}
}
}
@Override
public void reset() {
playerPlayedLand.clear();
landPlayed.clear();
super.reset();
}
public boolean landPlayed(UUID playerId) {
return playerPlayedLand.contains(playerId);
}
public boolean wasLandPlayed(UUID landId) {
return landPlayed.contains(landId);
}
}