mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
over-hauled watchers
This commit is contained in:
parent
caaa81a42b
commit
c00e34c051
46 changed files with 473 additions and 673 deletions
|
|
@ -30,22 +30,14 @@ package mage.sets.championsofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.Constants;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.DiesTriggeredAbility;
|
import mage.abilities.common.DiesTriggeredAbility;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
|
||||||
import mage.abilities.effects.common.DiscardTargetEffect;
|
import mage.abilities.effects.common.DiscardTargetEffect;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.events.ZoneChangeEvent;
|
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
import mage.watchers.Watcher;
|
|
||||||
import mage.watchers.WatcherImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Loki
|
* @author Loki
|
||||||
|
|
@ -60,10 +52,10 @@ public class AshenSkinZubera extends CardImpl<AshenSkinZubera> {
|
||||||
this.color.setBlack(true);
|
this.color.setBlack(true);
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
Ability ability = new DiesTriggeredAbility(new DiscardTargetEffect(new AshenSkinZuberaDynamicValue()));
|
Ability ability = new DiesTriggeredAbility(new DiscardTargetEffect(new ZuberasDiedDynamicValue()));
|
||||||
ability.addTarget(new TargetOpponent());
|
ability.addTarget(new TargetOpponent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
this.addWatcher(new AshenSkinZuberaWatcher());
|
this.addWatcher(new ZuberasDiedWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AshenSkinZubera(final AshenSkinZubera card) {
|
public AshenSkinZubera(final AshenSkinZubera card) {
|
||||||
|
|
@ -77,64 +69,3 @@ public class AshenSkinZubera extends CardImpl<AshenSkinZubera> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AshenSkinZuberaWatcher extends WatcherImpl<AshenSkinZuberaWatcher> {
|
|
||||||
|
|
||||||
public int zuberasDiedThisTurn = 0;
|
|
||||||
|
|
||||||
public AshenSkinZuberaWatcher() {
|
|
||||||
super("ZuberasDiedAshenSkinZubera");
|
|
||||||
}
|
|
||||||
|
|
||||||
public AshenSkinZuberaWatcher(final AshenSkinZuberaWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AshenSkinZuberaWatcher copy() {
|
|
||||||
return new AshenSkinZuberaWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
|
||||||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
|
||||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
|
||||||
if (card != null && card.hasSubtype("Zubera")) {
|
|
||||||
zuberasDiedThisTurn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
|
||||||
zuberasDiedThisTurn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class AshenSkinZuberaDynamicValue implements DynamicValue {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int calculate(Game game, Ability sourceAbility) {
|
|
||||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedAshenSkinZubera");
|
|
||||||
return ((AshenSkinZuberaWatcher) watcher).zuberasDiedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DynamicValue clone() {
|
|
||||||
return new AshenSkinZuberaDynamicValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "a";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return "Zubera put into a graveyard from play this turn";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -30,7 +30,6 @@ package mage.sets.championsofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.Constants;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
|
@ -38,14 +37,10 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.common.DiesTriggeredAbility;
|
import mage.abilities.common.DiesTriggeredAbility;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.events.ZoneChangeEvent;
|
|
||||||
import mage.game.permanent.token.SpiritToken;
|
import mage.game.permanent.token.SpiritToken;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
import mage.watchers.WatcherImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -61,8 +56,8 @@ public class DrippingTongueZubera extends CardImpl<DrippingTongueZubera> {
|
||||||
this.color.setGreen(true);
|
this.color.setGreen(true);
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SpiritToken(), new DrippingTongueZuberaDynamicValue()), false));
|
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SpiritToken(), new ZuberasDiedDynamicValue()), false));
|
||||||
this.addWatcher(new DrippingTongueZuberaWatcher());
|
this.addWatcher(new ZuberasDiedWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrippingTongueZubera (final DrippingTongueZubera card) {
|
public DrippingTongueZubera (final DrippingTongueZubera card) {
|
||||||
|
|
@ -75,65 +70,3 @@ public class DrippingTongueZubera extends CardImpl<DrippingTongueZubera> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DrippingTongueZuberaWatcher extends WatcherImpl<DrippingTongueZuberaWatcher> {
|
|
||||||
|
|
||||||
public int zuberasDiedThisTurn = 0;
|
|
||||||
|
|
||||||
public DrippingTongueZuberaWatcher() {
|
|
||||||
super("ZuberasDiedDrippingTongueZubera");
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrippingTongueZuberaWatcher(final DrippingTongueZuberaWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DrippingTongueZuberaWatcher copy() {
|
|
||||||
return new DrippingTongueZuberaWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
|
||||||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
|
||||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
|
||||||
if (card != null && card.hasSubtype("Zubera")) {
|
|
||||||
zuberasDiedThisTurn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
|
||||||
zuberasDiedThisTurn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class DrippingTongueZuberaDynamicValue implements DynamicValue {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int calculate(Game game, Ability sourceAbility) {
|
|
||||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedDrippingTongueZubera");
|
|
||||||
return ((DrippingTongueZuberaWatcher) watcher).zuberasDiedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DynamicValue clone() {
|
|
||||||
return new DrippingTongueZuberaDynamicValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return "Zubera put into a graveyard from play this turn";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -30,22 +30,14 @@ package mage.sets.championsofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.Constants;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.DiesTriggeredAbility;
|
import mage.abilities.common.DiesTriggeredAbility;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.events.ZoneChangeEvent;
|
|
||||||
import mage.target.common.TargetCreatureOrPlayer;
|
import mage.target.common.TargetCreatureOrPlayer;
|
||||||
import mage.watchers.Watcher;
|
|
||||||
import mage.watchers.WatcherImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -61,10 +53,10 @@ public class EmberFistZubera extends CardImpl<EmberFistZubera> {
|
||||||
this.color.setRed(true);
|
this.color.setRed(true);
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
Ability ability = new DiesTriggeredAbility(new DamageTargetEffect(new EmberFistZuberaDynamicValue()));
|
Ability ability = new DiesTriggeredAbility(new DamageTargetEffect(new ZuberasDiedDynamicValue()));
|
||||||
ability.addTarget(new TargetCreatureOrPlayer());
|
ability.addTarget(new TargetCreatureOrPlayer());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
this.addWatcher(new EmberFistZuberaWatcher());
|
this.addWatcher(new ZuberasDiedWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmberFistZubera (final EmberFistZubera card) {
|
public EmberFistZubera (final EmberFistZubera card) {
|
||||||
|
|
@ -78,65 +70,3 @@ public class EmberFistZubera extends CardImpl<EmberFistZubera> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class EmberFistZuberaWatcher extends WatcherImpl<EmberFistZuberaWatcher> {
|
|
||||||
|
|
||||||
public int zuberasDiedThisTurn = 0;
|
|
||||||
|
|
||||||
public EmberFistZuberaWatcher() {
|
|
||||||
super("ZuberasDiedEmberFistZubera");
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmberFistZuberaWatcher(final EmberFistZuberaWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EmberFistZuberaWatcher copy() {
|
|
||||||
return new EmberFistZuberaWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
|
||||||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
|
||||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
|
||||||
if (card != null && card.hasSubtype("Zubera")) {
|
|
||||||
zuberasDiedThisTurn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
|
||||||
zuberasDiedThisTurn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class EmberFistZuberaDynamicValue implements DynamicValue {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int calculate(Game game, Ability sourceAbility) {
|
|
||||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedEmberFistZubera");
|
|
||||||
return ((EmberFistZuberaWatcher) watcher).zuberasDiedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DynamicValue clone() {
|
|
||||||
return new EmberFistZuberaDynamicValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return "Zubera put into all graveyards from play this turn";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.DiesTriggeredAbility;
|
import mage.abilities.common.DiesTriggeredAbility;
|
||||||
|
|
@ -43,7 +44,6 @@ import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.watchers.Watcher;
|
|
||||||
import mage.watchers.WatcherImpl;
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -59,8 +59,8 @@ public class FloatingDreamZubera extends CardImpl<FloatingDreamZubera> {
|
||||||
this.color.setBlue(true);
|
this.color.setBlue(true);
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
this.addAbility(new DiesTriggeredAbility(new DrawCardControllerEffect(new FloatingDreamZuberaDynamicValue())));
|
this.addAbility(new DiesTriggeredAbility(new DrawCardControllerEffect(new ZuberasDiedDynamicValue())));
|
||||||
this.addWatcher(new FloatingDreamZuberaWatcher());
|
this.addWatcher(new ZuberasDiedWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FloatingDreamZubera(final FloatingDreamZubera card) {
|
public FloatingDreamZubera(final FloatingDreamZubera card) {
|
||||||
|
|
@ -75,35 +75,33 @@ public class FloatingDreamZubera extends CardImpl<FloatingDreamZubera> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class FloatingDreamZuberaWatcher extends WatcherImpl<FloatingDreamZuberaWatcher> {
|
class ZuberasDiedWatcher extends WatcherImpl<ZuberasDiedWatcher> {
|
||||||
|
|
||||||
public int zuberasDiedThisTurn = 0;
|
public int zuberasDiedThisTurn = 0;
|
||||||
|
|
||||||
public FloatingDreamZuberaWatcher() {
|
public ZuberasDiedWatcher() {
|
||||||
super("ZuberasDiedFloatingDreamZubera");
|
super("ZuberasDied", WatcherScope.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FloatingDreamZuberaWatcher(final FloatingDreamZuberaWatcher watcher) {
|
public ZuberasDiedWatcher(final ZuberasDiedWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
|
this.zuberasDiedThisTurn = watcher.zuberasDiedThisTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FloatingDreamZuberaWatcher copy() {
|
public ZuberasDiedWatcher copy() {
|
||||||
return new FloatingDreamZuberaWatcher(this);
|
return new ZuberasDiedWatcher(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
|
||||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||||
if (card != null && card.hasSubtype("Zubera")) {
|
if (card != null && card.hasSubtype("Zubera")) {
|
||||||
zuberasDiedThisTurn++;
|
zuberasDiedThisTurn++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
|
@ -113,17 +111,17 @@ class FloatingDreamZuberaWatcher extends WatcherImpl<FloatingDreamZuberaWatcher>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FloatingDreamZuberaDynamicValue implements DynamicValue {
|
class ZuberasDiedDynamicValue implements DynamicValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calculate(Game game, Ability sourceAbility) {
|
public int calculate(Game game, Ability sourceAbility) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedFloatingDreamZubera");
|
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied");
|
||||||
return ((FloatingDreamZuberaWatcher) watcher).zuberasDiedThisTurn;
|
return watcher.zuberasDiedThisTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DynamicValue clone() {
|
public ZuberasDiedDynamicValue clone() {
|
||||||
return new FloatingDreamZuberaDynamicValue();
|
return new ZuberasDiedDynamicValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -133,6 +131,6 @@ class FloatingDreamZuberaDynamicValue implements DynamicValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return "for each Zubera put into a graveyard from play this turn";
|
return "for each Zubera that died this turn";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +44,7 @@ import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.DestroyAllEffect;
|
import mage.abilities.effects.common.DestroyAllEffect;
|
||||||
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
|
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
|
||||||
import mage.abilities.keyword.IndestructibleAbility;
|
import mage.abilities.keyword.IndestructibleAbility;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
|
@ -105,10 +106,10 @@ class MyojinOfCleansingFireEntersBattlefieldEffect extends OneShotEffect<MyojinO
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "CastFromHand");
|
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
|
||||||
Permanent p = game.getPermanent(source.getSourceId());
|
Permanent p = game.getPermanent(source.getSourceId());
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
|
Watcher watcher = game.getState().getWatchers().get("CastFromHand", source.getSourceId());
|
||||||
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
p.addCounters(CounterType.DIVINITY.createInstance(), game);
|
p.addCounters(CounterType.DIVINITY.createInstance(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class SilentChantZubera extends CardImpl<SilentChantZubera> {
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
Ability ability = new DiesTriggeredAbility(new GainLifeEffect(new SilentChantZuberaDynamicValue()));
|
Ability ability = new DiesTriggeredAbility(new GainLifeEffect(new SilentChantZuberaDynamicValue()));
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
this.addWatcher(new AshenSkinZuberaWatcher());
|
this.addWatcher(new ZuberasDiedWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SilentChantZubera (final SilentChantZubera card) {
|
public SilentChantZubera (final SilentChantZubera card) {
|
||||||
|
|
@ -76,54 +76,16 @@ public class SilentChantZubera extends CardImpl<SilentChantZubera> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SilentChantZuberaWatcher extends WatcherImpl<SilentChantZuberaWatcher> {
|
|
||||||
|
|
||||||
public int zuberasDiedThisTurn = 0;
|
|
||||||
|
|
||||||
public SilentChantZuberaWatcher() {
|
|
||||||
super("ZuberasDiedSilentChantZubera");
|
|
||||||
}
|
|
||||||
|
|
||||||
public SilentChantZuberaWatcher(final SilentChantZuberaWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SilentChantZuberaWatcher copy() {
|
|
||||||
return new SilentChantZuberaWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
|
||||||
if (((ZoneChangeEvent) event).getFromZone() == Constants.Zone.BATTLEFIELD &&
|
|
||||||
((ZoneChangeEvent) event).getToZone() == Constants.Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
|
||||||
if (card != null && card.hasSubtype("Zubera")) {
|
|
||||||
zuberasDiedThisTurn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
|
||||||
zuberasDiedThisTurn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class SilentChantZuberaDynamicValue implements DynamicValue {
|
class SilentChantZuberaDynamicValue implements DynamicValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calculate(Game game, Ability sourceAbility) {
|
public int calculate(Game game, Ability sourceAbility) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedSilentChantZubera");
|
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied");
|
||||||
return ((SilentChantZuberaWatcher) watcher).zuberasDiedThisTurn;
|
return watcher.zuberasDiedThisTurn * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DynamicValue clone() {
|
public SilentChantZuberaDynamicValue clone() {
|
||||||
return new SilentChantZuberaDynamicValue();
|
return new SilentChantZuberaDynamicValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,6 +96,6 @@ class SilentChantZuberaDynamicValue implements DynamicValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return "Zubera put into a graveyard from play this turn";
|
return "for each Zubera that died this turn";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +39,6 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.abilities.keyword.FirstStrikeAbility;
|
import mage.abilities.keyword.FirstStrikeAbility;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -47,8 +46,7 @@ import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.common.DamagedByWatcher;
|
||||||
import mage.watchers.WatcherImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -70,7 +68,7 @@ public class AbattoirGhoul extends CardImpl<AbattoirGhoul> {
|
||||||
AbattoirGhoulEffect effect = new AbattoirGhoulEffect();
|
AbattoirGhoulEffect effect = new AbattoirGhoulEffect();
|
||||||
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||||
this.addWatcher(new AbattoirGhoulWatcher());
|
this.addWatcher(new DamagedByWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbattoirGhoul(final AbattoirGhoul card) {
|
public AbattoirGhoul(final AbattoirGhoul card) {
|
||||||
|
|
@ -118,47 +116,15 @@ class AbattoirGhoulEffect extends ReplacementEffectImpl<AbattoirGhoulEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == EventType.ZONE_CHANGE &&
|
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD &&
|
Permanent p = game.getPermanent(source.getSourceId());
|
||||||
((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
if (p != null) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "AbattoirGhoulDamagedCreature");
|
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||||
if (watcher != null)
|
if (watcher != null)
|
||||||
return watcher.conditionMet();
|
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AbattoirGhoulWatcher extends WatcherImpl<AbattoirGhoulWatcher> {
|
|
||||||
|
|
||||||
public AbattoirGhoulWatcher() {
|
|
||||||
super("AbattoirGhoulDamagedCreature");
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbattoirGhoulWatcher(final AbattoirGhoulWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AbattoirGhoulWatcher copy() {
|
|
||||||
return new AbattoirGhoulWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (condition == true) //no need to check - condition has already occured
|
|
||||||
return;
|
|
||||||
if (event.getType() == EventType.DAMAGED_CREATURE) {
|
|
||||||
Card card = game.getCard(sourceId);
|
|
||||||
|
|
||||||
if (card != null && card.getId().equals(event.getSourceId())) {
|
|
||||||
condition = true;
|
|
||||||
AbattoirGhoulEffect effect = (AbattoirGhoulEffect)card.getAbilities().get(2).getEffects().get(0);
|
|
||||||
effect.setValue("player", game.getPlayer(card.getOwnerId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -84,7 +84,7 @@ class BrimstoneVolleyEffect extends OneShotEffect<BrimstoneVolleyEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int damage = 3;
|
int damage = 3;
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "Morbid");
|
Watcher watcher = game.getState().getWatchers().get("Morbid");
|
||||||
if (watcher.conditionMet()) {
|
if (watcher.conditionMet()) {
|
||||||
damage = 5;
|
damage = 5;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public class CivilizedScholar extends CardImpl<CivilizedScholar> {
|
||||||
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CivilizedScholarEffect(), new TapSourceCost()));
|
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CivilizedScholarEffect(), new TapSourceCost()));
|
||||||
this.addAbility(new TransformAbility());
|
this.addAbility(new TransformAbility());
|
||||||
|
|
||||||
this.addWatcher(new HomicidalBrute.HomicidalBruteWatcher());
|
// this.addWatcher(new HomicidalBrute.HomicidalBruteWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CivilizedScholar(final CivilizedScholar card) {
|
public CivilizedScholar(final CivilizedScholar card) {
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.watchers.WatcherImpl;
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
|
|
@ -65,6 +65,7 @@ public class HomicidalBrute extends CardImpl<HomicidalBrute> {
|
||||||
|
|
||||||
// At the beginning of your end step, if Homicidal Brute didn't attack this turn, tap Homicidal Brute, then transform it.
|
// At the beginning of your end step, if Homicidal Brute didn't attack this turn, tap Homicidal Brute, then transform it.
|
||||||
this.addAbility(new HomicidalBruteTriggeredAbility());
|
this.addAbility(new HomicidalBruteTriggeredAbility());
|
||||||
|
this.addWatcher(new HomicidalBruteWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HomicidalBrute(final HomicidalBrute card) {
|
public HomicidalBrute(final HomicidalBrute card) {
|
||||||
|
|
@ -76,12 +77,12 @@ public class HomicidalBrute extends CardImpl<HomicidalBrute> {
|
||||||
return new HomicidalBrute(this);
|
return new HomicidalBrute(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HomicidalBruteWatcher extends WatcherImpl<HomicidalBruteWatcher> {
|
}
|
||||||
|
|
||||||
public Map<UUID, Set<UUID>> blockedCreatures = new HashMap<UUID, Set<UUID>>();
|
class HomicidalBruteWatcher extends WatcherImpl<HomicidalBruteWatcher> {
|
||||||
|
|
||||||
public HomicidalBruteWatcher() {
|
public HomicidalBruteWatcher() {
|
||||||
super("HomicidalBruteWatcher");
|
super("HomicidalBruteAttacked", WatcherScope.CARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) {
|
public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) {
|
||||||
|
|
@ -95,12 +96,13 @@ public class HomicidalBrute extends CardImpl<HomicidalBrute> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
|
if (condition == true)
|
||||||
|
return;
|
||||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
||||||
condition = true;
|
condition = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl<HomicidalBruteTriggeredAbility> {
|
class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl<HomicidalBruteTriggeredAbility> {
|
||||||
|
|
||||||
|
|
@ -121,7 +123,7 @@ class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl<HomicidalBrute
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.END_PHASE_PRE && event.getPlayerId().equals(this.controllerId)) {
|
if (event.getType() == GameEvent.EventType.END_PHASE_PRE && event.getPlayerId().equals(this.controllerId)) {
|
||||||
HomicidalBrute.HomicidalBruteWatcher watcher = (HomicidalBrute.HomicidalBruteWatcher) game.getState().getWatchers().get(this.controllerId, "HomicidalBruteWatcher");
|
Watcher watcher = game.getState().getWatchers().get("HomicidalBruteAttacked", sourceId);
|
||||||
if (watcher != null && !watcher.conditionMet()) {
|
if (watcher != null && !watcher.conditionMet()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class ReaperFromTheAbyssAbility extends TriggeredAbilityImpl<ReaperFromTheAbyssA
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE) {
|
if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(controllerId, "Morbid");
|
Watcher watcher = game.getState().getWatchers().get("Morbid");
|
||||||
return watcher.conditionMet();
|
return watcher.conditionMet();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class SkirsdagHighPriestCost extends CostImpl<SkirsdagHighPriestCost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||||
return game.getState().getWatchers().get(controllerId, "Morbid").conditionMet();
|
return game.getState().getWatchers().get("Morbid").conditionMet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,14 @@ import mage.Constants.CardType;
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -81,7 +83,7 @@ public class AngelicArbiter extends CardImpl<AngelicArbiter> {
|
||||||
class AngelicArbiterWatcher1 extends WatcherImpl<AngelicArbiterWatcher1> {
|
class AngelicArbiterWatcher1 extends WatcherImpl<AngelicArbiterWatcher1> {
|
||||||
|
|
||||||
public AngelicArbiterWatcher1() {
|
public AngelicArbiterWatcher1() {
|
||||||
super("CastSpell");
|
super("OpponentCastSpell", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AngelicArbiterWatcher1(final AngelicArbiterWatcher1 watcher) {
|
public AngelicArbiterWatcher1(final AngelicArbiterWatcher1 watcher) {
|
||||||
|
|
@ -106,7 +108,7 @@ class AngelicArbiterWatcher1 extends WatcherImpl<AngelicArbiterWatcher1> {
|
||||||
class AngelicArbiterWatcher2 extends WatcherImpl<AngelicArbiterWatcher2> {
|
class AngelicArbiterWatcher2 extends WatcherImpl<AngelicArbiterWatcher2> {
|
||||||
|
|
||||||
public AngelicArbiterWatcher2() {
|
public AngelicArbiterWatcher2() {
|
||||||
super("Attacked");
|
super("OpponentAttacked", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AngelicArbiterWatcher2(final AngelicArbiterWatcher2 watcher) {
|
public AngelicArbiterWatcher2(final AngelicArbiterWatcher2 watcher) {
|
||||||
|
|
@ -155,7 +157,7 @@ class AngelicArbiterEffect1 extends ReplacementEffectImpl<AngelicArbiterEffect1>
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == EventType.DECLARE_ATTACKER && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
if (event.getType() == EventType.DECLARE_ATTACKER && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "CastSpell");
|
Watcher watcher = game.getState().getWatchers().get("OpponentCastSpell", source.getControllerId());
|
||||||
if (watcher != null && watcher.conditionMet())
|
if (watcher != null && watcher.conditionMet())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -193,7 +195,7 @@ class AngelicArbiterEffect2 extends ReplacementEffectImpl<AngelicArbiterEffect2>
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == EventType.CAST_SPELL && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
if (event.getType() == EventType.CAST_SPELL && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "Attacked");
|
Watcher watcher = game.getState().getWatchers().get("OpponentAttacked", source.getControllerId());
|
||||||
if (watcher != null && watcher.conditionMet())
|
if (watcher != null && watcher.conditionMet())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ import mage.abilities.effects.RestrictionEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
|
import mage.watchers.common.BloodthirstWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -95,10 +97,7 @@ class BloodcrazedGoblinEffect extends RestrictionEffect<BloodcrazedGoblinEffect>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents");
|
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId());
|
||||||
if (watcher != null) {
|
|
||||||
return !watcher.conditionMet();
|
return !watcher.conditionMet();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,11 @@ import mage.Constants.CardType;
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.Zone;
|
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.abilities.effects.common.DamageXTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -46,8 +44,7 @@ import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetCreatureOrPlayer;
|
import mage.target.common.TargetCreatureOrPlayer;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.common.DamagedByWatcher;
|
||||||
import mage.watchers.WatcherImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -60,10 +57,10 @@ public class RedSunsZenith extends CardImpl<RedSunsZenith> {
|
||||||
this.expansionSetCode = "MBS";
|
this.expansionSetCode = "MBS";
|
||||||
this.color.setRed(true);
|
this.color.setRed(true);
|
||||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||||
this.getSpellAbility().addEffect(new DamageXTargetEffect());
|
this.getSpellAbility().addEffect(new DamageTargetEffect(new ManacostVariableValue()));
|
||||||
this.getSpellAbility().addEffect(new RedSunsZenithEffect());
|
this.getSpellAbility().addEffect(new RedSunsZenithEffect());
|
||||||
this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance());
|
this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance());
|
||||||
this.addWatcher(new RedSunsZenithWatcher());
|
this.addWatcher(new DamagedByWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public RedSunsZenith(final RedSunsZenith card) {
|
public RedSunsZenith(final RedSunsZenith card) {
|
||||||
|
|
@ -109,42 +106,12 @@ class RedSunsZenithEffect extends ReplacementEffectImpl<RedSunsZenithEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == EventType.ZONE_CHANGE &&
|
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD &&
|
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||||
((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "RedSunsZenithDamagedCreature");
|
|
||||||
if (watcher != null)
|
if (watcher != null)
|
||||||
return watcher.conditionMet();
|
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class RedSunsZenithWatcher extends WatcherImpl<RedSunsZenithWatcher> {
|
|
||||||
|
|
||||||
public RedSunsZenithWatcher() {
|
|
||||||
super("RedSunsZenithDamagedCreature");
|
|
||||||
}
|
|
||||||
|
|
||||||
public RedSunsZenithWatcher(final RedSunsZenithWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RedSunsZenithWatcher copy() {
|
|
||||||
return new RedSunsZenithWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (condition == true) //no need to check - condition has already occured
|
|
||||||
return;
|
|
||||||
if (event.getType() == EventType.DAMAGED_CREATURE) {
|
|
||||||
Card card = game.getCard(sourceId);
|
|
||||||
if (card != null && card.getSpellAbility().getId().equals(event.getSourceId()))
|
|
||||||
condition = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.newphyrexia;
|
package mage.sets.newphyrexia;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -36,12 +38,14 @@ import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.TurnPhase;
|
import mage.Constants.TurnPhase;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.keyword.DefenderAbility;
|
import mage.abilities.keyword.DefenderAbility;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -127,10 +131,9 @@ class CathedralMembraneEffect extends OneShotEffect<CathedralMembraneEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get(source.getControllerId(), "CathedralMembraneWatcher");
|
CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get("CathedralMembraneWatcher", source.getSourceId());
|
||||||
if (watcher != null && watcher.blockedCreatures.containsKey(source.getSourceId())) {
|
if (watcher != null) {
|
||||||
Set<UUID> creatures = watcher.blockedCreatures.get(source.getSourceId());
|
for (UUID uuid : watcher.blockedCreatures) {
|
||||||
for (UUID uuid : creatures) {
|
|
||||||
Permanent permanent = game.getPermanent(uuid);
|
Permanent permanent = game.getPermanent(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
permanent.damage(6, source.getSourceId(), game, true, false);
|
permanent.damage(6, source.getSourceId(), game, true, false);
|
||||||
|
|
@ -143,14 +146,15 @@ class CathedralMembraneEffect extends OneShotEffect<CathedralMembraneEffect> {
|
||||||
|
|
||||||
class CathedralMembraneWatcher extends WatcherImpl<CathedralMembraneWatcher> {
|
class CathedralMembraneWatcher extends WatcherImpl<CathedralMembraneWatcher> {
|
||||||
|
|
||||||
public Map<UUID, Set<UUID>> blockedCreatures = new HashMap<UUID, Set<UUID>>();
|
public List<UUID> blockedCreatures = new ArrayList<UUID>();
|
||||||
|
|
||||||
public CathedralMembraneWatcher() {
|
public CathedralMembraneWatcher() {
|
||||||
super("CathedralMembraneWatcher");
|
super("CathedralMembraneWatcher", WatcherScope.CARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CathedralMembraneWatcher(final CathedralMembraneWatcher watcher) {
|
public CathedralMembraneWatcher(final CathedralMembraneWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
|
this.blockedCreatures = watcher.blockedCreatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -161,13 +165,8 @@ class CathedralMembraneWatcher extends WatcherImpl<CathedralMembraneWatcher> {
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
||||||
Set<UUID> creatures = blockedCreatures.get(sourceId);
|
if (!blockedCreatures.contains(event.getTargetId())) {
|
||||||
if (creatures != null) {
|
blockedCreatures.add(event.getTargetId());
|
||||||
creatures.add(event.getTargetId());
|
|
||||||
} else {
|
|
||||||
creatures = new HashSet<UUID>();
|
|
||||||
creatures.add(event.getTargetId());
|
|
||||||
blockedCreatures.put(sourceId, creatures);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,12 @@ package mage.sets.newphyrexia;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -56,7 +57,7 @@ public class FreshMeat extends CardImpl<FreshMeat> {
|
||||||
this.color.setGreen(true);
|
this.color.setGreen(true);
|
||||||
|
|
||||||
this.addWatcher(new FreshMeatWatcher());
|
this.addWatcher(new FreshMeatWatcher());
|
||||||
this.getSpellAbility().addEffect(new FreshMeatEffect());
|
this.getSpellAbility().addEffect(new CreateTokenEffect(new BeastToken(), new FreshMeatDynamicValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FreshMeat(final FreshMeat card) {
|
public FreshMeat(final FreshMeat card) {
|
||||||
|
|
@ -74,7 +75,7 @@ class FreshMeatWatcher extends WatcherImpl<FreshMeatWatcher> {
|
||||||
private int creaturesCount = 0;
|
private int creaturesCount = 0;
|
||||||
|
|
||||||
public FreshMeatWatcher() {
|
public FreshMeatWatcher() {
|
||||||
super("CreaturesDiedFreshMeat");
|
super("YourCreaturesDied", WatcherScope.PLAYER);
|
||||||
condition = true;
|
condition = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,9 +95,7 @@ class FreshMeatWatcher extends WatcherImpl<FreshMeatWatcher> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.ZONE_CHANGE
|
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD
|
|
||||||
&& ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||||
if (card != null && card.getOwnerId().equals(this.controllerId) && card.getCardType().contains(CardType.CREATURE)) {
|
if (card != null && card.getOwnerId().equals(this.controllerId) && card.getCardType().contains(CardType.CREATURE)) {
|
||||||
creaturesCount++;
|
creaturesCount++;
|
||||||
|
|
@ -111,28 +110,28 @@ class FreshMeatWatcher extends WatcherImpl<FreshMeatWatcher> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FreshMeatEffect extends OneShotEffect<FreshMeatEffect> {
|
class FreshMeatDynamicValue implements DynamicValue {
|
||||||
|
|
||||||
public FreshMeatEffect() {
|
@Override
|
||||||
super(Outcome.PutCreatureInPlay);
|
public int calculate(Game game, Ability sourceAbility) {
|
||||||
this.staticText = "Put a 3/3 green Beast creature token onto the battlefield for each creature put into your graveyard from the battlefield this turn";
|
FreshMeatWatcher watcher = (FreshMeatWatcher) game.getState().getWatchers().get("YourCreaturesDied", sourceAbility.getControllerId());
|
||||||
}
|
if (watcher != null)
|
||||||
|
return watcher.getCreaturesCount();
|
||||||
public FreshMeatEffect(final FreshMeatEffect effect) {
|
return 0;
|
||||||
super(effect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FreshMeatEffect copy() {
|
public FreshMeatDynamicValue clone() {
|
||||||
return new FreshMeatEffect(this);
|
return new FreshMeatDynamicValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public String toString() {
|
||||||
FreshMeatWatcher watcher = (FreshMeatWatcher) game.getState().getWatchers().get(source.getControllerId(), "CreaturesDiedFreshMeat");
|
return "1";
|
||||||
int count = watcher.getCreaturesCount();
|
}
|
||||||
BeastToken token = new BeastToken();
|
|
||||||
token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId());
|
@Override
|
||||||
return true;
|
public String getMessage() {
|
||||||
|
return "for each creature put into your graveyard from the battlefield this turn";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ package mage.sets.riseoftheeldrazi;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
|
@ -92,7 +93,7 @@ class VengevineAbility extends TriggeredAbilityImpl<VengevineAbility> {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.SPELL_CAST && event.getPlayerId().equals(controllerId)) {
|
if (event.getType() == EventType.SPELL_CAST && event.getPlayerId().equals(controllerId)) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(controllerId, "CreatureCast");
|
Watcher watcher = game.getState().getWatchers().get("CreatureCast", controllerId);
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -113,11 +114,12 @@ class VengevineWatcher extends WatcherImpl<VengevineWatcher> {
|
||||||
int creatureSpellCount = 0;
|
int creatureSpellCount = 0;
|
||||||
|
|
||||||
public VengevineWatcher() {
|
public VengevineWatcher() {
|
||||||
super("CreatureCast");
|
super("CreatureCast", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VengevineWatcher(final VengevineWatcher watcher) {
|
public VengevineWatcher(final VengevineWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
|
this.creatureSpellCount = watcher.creatureSpellCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
|
|
@ -83,7 +84,7 @@ class FleshAllergyWatcher extends WatcherImpl<FleshAllergyWatcher> {
|
||||||
public int creaturesDiedThisTurn = 0;
|
public int creaturesDiedThisTurn = 0;
|
||||||
|
|
||||||
public FleshAllergyWatcher() {
|
public FleshAllergyWatcher() {
|
||||||
super("CreaturesDiedFleshAllergy");
|
super("CreaturesDied", WatcherScope.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FleshAllergyWatcher(final FleshAllergyWatcher watcher) {
|
public FleshAllergyWatcher(final FleshAllergyWatcher watcher) {
|
||||||
|
|
@ -97,16 +98,13 @@ class FleshAllergyWatcher extends WatcherImpl<FleshAllergyWatcher> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.ZONE_CHANGE) {
|
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||||
if (((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD &&
|
|
||||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) {
|
|
||||||
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||||
creaturesDiedThisTurn++;
|
creaturesDiedThisTurn++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
|
@ -120,7 +118,7 @@ class FleshAllergyEffect extends OneShotEffect<FleshAllergyEffect> {
|
||||||
|
|
||||||
public FleshAllergyEffect() {
|
public FleshAllergyEffect() {
|
||||||
super(Outcome.DestroyPermanent);
|
super(Outcome.DestroyPermanent);
|
||||||
staticText = "Destroy target creature. Its controller loses life equal to the number of creatures that died this turn";
|
staticText = "Its controller loses life equal to the number of creatures that died this turn";
|
||||||
}
|
}
|
||||||
|
|
||||||
public FleshAllergyEffect(final FleshAllergyEffect effect) {
|
public FleshAllergyEffect(final FleshAllergyEffect effect) {
|
||||||
|
|
@ -134,12 +132,12 @@ class FleshAllergyEffect extends OneShotEffect<FleshAllergyEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "CreaturesDiedFleshAllergy");
|
FleshAllergyWatcher watcher = (FleshAllergyWatcher) game.getState().getWatchers().get("CreaturesDied");
|
||||||
Card card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
|
Card card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
|
||||||
if (card != null && watcher != null) {
|
if (card != null && watcher != null) {
|
||||||
Player player = game.getPlayer(((Permanent)card).getControllerId());
|
Player player = game.getPlayer(((Permanent)card).getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int amount = ((FleshAllergyWatcher)watcher).creaturesDiedThisTurn;
|
int amount = watcher.creaturesDiedThisTurn;
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
player.loseLife(amount, game);
|
player.loseLife(amount, game);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,12 @@ package mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.condition.common.MetalcraftCondition;
|
import mage.abilities.condition.common.MetalcraftCondition;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
|
@ -91,7 +93,7 @@ class MoltenPsycheEffect extends OneShotEffect<MoltenPsycheEffect> {
|
||||||
player.getHand().clear();
|
player.getHand().clear();
|
||||||
player.drawCards(count, game);
|
player.drawCards(count, game);
|
||||||
if (MetalcraftCondition.getInstance().apply(game, source) && !playerId.equals(source.getControllerId())) {
|
if (MetalcraftCondition.getInstance().apply(game, source) && !playerId.equals(source.getControllerId())) {
|
||||||
MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get(source.getControllerId(), "CardsDrawnMoltenPsyche");
|
MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get("CardsDrawn");
|
||||||
player.damage(watcher.getDraws(playerId), source.getId(), game, false, true);
|
player.damage(watcher.getDraws(playerId), source.getId(), game, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,11 +113,14 @@ class MoltenPsycheWatcher extends WatcherImpl<MoltenPsycheWatcher> {
|
||||||
private Map<UUID, Integer> draws = new HashMap<UUID, Integer>();
|
private Map<UUID, Integer> draws = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
public MoltenPsycheWatcher() {
|
public MoltenPsycheWatcher() {
|
||||||
super("CardsDrawnMoltenPsyche");
|
super("CardsDrawn", WatcherScope.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MoltenPsycheWatcher(final MoltenPsycheWatcher watcher) {
|
public MoltenPsycheWatcher(final MoltenPsycheWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
|
for (Entry<UUID, Integer> entry: watcher.draws.entrySet()) {
|
||||||
|
draws.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.watchers.WatcherImpl;
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
|
|
@ -98,11 +99,10 @@ class SteelHellkiteDestroyEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatchers().get(source.getControllerId(), "SteelHellkiteWatcher");
|
SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatchers().get("SteelHellkiteWatcher", source.getSourceId());
|
||||||
if (watcher != null && watcher.damagedPlayers.containsKey(source.getSourceId())) {
|
if (watcher != null) {
|
||||||
Set<UUID> players = watcher.damagedPlayers.get(source.getSourceId());
|
|
||||||
int xValue = source.getManaCostsToPay().getX();
|
int xValue = source.getManaCostsToPay().getX();
|
||||||
for (UUID uuid : players) {
|
for (UUID uuid : watcher.damagedPlayers) {
|
||||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents()) {
|
for (Permanent permanent: game.getBattlefield().getAllActivePermanents()) {
|
||||||
if (permanent.getControllerId().equals(uuid) && permanent.getManaCost().convertedManaCost() == xValue) {
|
if (permanent.getControllerId().equals(uuid) && permanent.getManaCost().convertedManaCost() == xValue) {
|
||||||
permanent.destroy(source.getId(), game, false);
|
permanent.destroy(source.getId(), game, false);
|
||||||
|
|
@ -116,14 +116,17 @@ class SteelHellkiteDestroyEffect extends OneShotEffect {
|
||||||
|
|
||||||
class SteelHellkiteWatcher extends WatcherImpl<SteelHellkiteWatcher> {
|
class SteelHellkiteWatcher extends WatcherImpl<SteelHellkiteWatcher> {
|
||||||
|
|
||||||
public Map<UUID, Set<UUID>> damagedPlayers = new HashMap<UUID, Set<UUID>>();
|
public List<UUID> damagedPlayers = new ArrayList<UUID>();
|
||||||
|
|
||||||
public SteelHellkiteWatcher() {
|
public SteelHellkiteWatcher() {
|
||||||
super("SteelHellkiteWatcher");
|
super("SteelHellkiteWatcher", WatcherScope.CARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SteelHellkiteWatcher(final SteelHellkiteWatcher watcher) {
|
public SteelHellkiteWatcher(final SteelHellkiteWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
|
for (UUID playerId: watcher.damagedPlayers) {
|
||||||
|
damagedPlayers.add(playerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -138,13 +141,8 @@ class SteelHellkiteWatcher extends WatcherImpl<SteelHellkiteWatcher> {
|
||||||
UUID sourceId = damageEvent.getSourceId();
|
UUID sourceId = damageEvent.getSourceId();
|
||||||
Permanent permanent = game.getPermanent(sourceId);
|
Permanent permanent = game.getPermanent(sourceId);
|
||||||
if (sourceId != null && permanent != null && permanent.getName().equals("Steel Hellkite")) {
|
if (sourceId != null && permanent != null && permanent.getName().equals("Steel Hellkite")) {
|
||||||
Set<UUID> players = damagedPlayers.get(sourceId);
|
if (!damagedPlayers.contains(event.getTargetId())) {
|
||||||
if (players != null) {
|
damagedPlayers.add(event.getTargetId());
|
||||||
players.add(damageEvent.getPlayerId());
|
|
||||||
} else {
|
|
||||||
players = new HashSet<UUID>();
|
|
||||||
players.add(damageEvent.getPlayerId());
|
|
||||||
damagedPlayers.put(sourceId, players);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@
|
||||||
|
|
||||||
package mage.sets.scarsofmirrodin;
|
package mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
|
@ -41,10 +44,10 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
import mage.watchers.Watcher;
|
|
||||||
import mage.watchers.WatcherImpl;
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Loki
|
* @author Loki
|
||||||
|
|
@ -74,15 +77,17 @@ public class TunnelIgnus extends CardImpl<TunnelIgnus> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TunnelIgnusWatcher extends WatcherImpl {
|
class TunnelIgnusWatcher extends WatcherImpl {
|
||||||
int count = 0;
|
protected Map<UUID, Integer> counts = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
public TunnelIgnusWatcher() {
|
public TunnelIgnusWatcher() {
|
||||||
super("LandPlayedCount");
|
super("LandPlayedCount", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) {
|
public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
this.count = watcher.count;
|
for (Entry<UUID, Integer> entry: watcher.counts.entrySet()) {
|
||||||
|
counts.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -92,15 +97,14 @@ class TunnelIgnusWatcher extends WatcherImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
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) {
|
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Constants.Zone.BATTLEFIELD) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent.getCardType().contains(CardType.LAND) && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) {
|
if (permanent.getCardType().contains(CardType.LAND) && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) {
|
||||||
count++;
|
int count = 1;
|
||||||
if (count > 1) {
|
if (counts.containsKey(permanent.getControllerId())) {
|
||||||
condition = true;
|
count += counts.get(permanent.getControllerId());
|
||||||
}
|
}
|
||||||
|
counts.put(permanent.getControllerId(), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +112,7 @@ class TunnelIgnusWatcher extends WatcherImpl {
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
count = 0;
|
counts.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,19 +132,19 @@ class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl<TunnelIgnusTrigge
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(this.getControllerId(), "LandPlayedCount");
|
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Constants.Zone.BATTLEFIELD) {
|
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Constants.Zone.BATTLEFIELD) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND) && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) {
|
if (permanent != null && permanent.getCardType().contains(CardType.LAND) && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) {
|
||||||
|
TunnelIgnusWatcher watcher = (TunnelIgnusWatcher) game.getState().getWatchers().get("LandPlayedCount", this.controllerId);
|
||||||
|
if (watcher != null && watcher.counts.get(permanent.getControllerId()) > 1) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import mage.Constants.SubLayer;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -63,7 +64,7 @@ public class Groundswell extends CardImpl<Groundswell> {
|
||||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||||
this.getSpellAbility().addEffect(new GroundswellEffect(Duration.EndOfTurn));
|
this.getSpellAbility().addEffect(new GroundswellEffect(Duration.EndOfTurn));
|
||||||
|
|
||||||
this.addWatcher(new GroundswellWatcher());
|
this.addWatcher(new LandfallWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Groundswell(final Groundswell card) {
|
public Groundswell(final Groundswell card) {
|
||||||
|
|
@ -76,34 +77,6 @@ public class Groundswell extends CardImpl<Groundswell> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GroundswellWatcher extends WatcherImpl<GroundswellWatcher> {
|
|
||||||
|
|
||||||
public GroundswellWatcher() {
|
|
||||||
super("LandPlayed");
|
|
||||||
}
|
|
||||||
|
|
||||||
public GroundswellWatcher(final GroundswellWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GroundswellWatcher copy() {
|
|
||||||
return new GroundswellWatcher(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (condition == true) //no need to check - condition has already occured
|
|
||||||
return;
|
|
||||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD) {
|
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
|
||||||
if (permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
|
|
||||||
condition = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GroundswellEffect extends ContinuousEffectImpl<GroundswellEffect> {
|
class GroundswellEffect extends ContinuousEffectImpl<GroundswellEffect> {
|
||||||
|
|
||||||
public GroundswellEffect(Duration duration) {
|
public GroundswellEffect(Duration duration) {
|
||||||
|
|
@ -122,7 +95,7 @@ class GroundswellEffect extends ContinuousEffectImpl<GroundswellEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "LandPlayed");
|
Watcher watcher = game.getState().getWatchers().get("LandPlayed", source.getControllerId());
|
||||||
Permanent target = (Permanent) game.getPermanent(source.getFirstTarget());
|
Permanent target = (Permanent) game.getPermanent(source.getFirstTarget());
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -70,7 +71,7 @@ public class SearingBlaze extends CardImpl<SearingBlaze> {
|
||||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||||
this.getSpellAbility().addTarget(new SearingBlazeTarget());
|
this.getSpellAbility().addTarget(new SearingBlazeTarget());
|
||||||
this.getSpellAbility().addEffect(new SearingBlazeEffect());
|
this.getSpellAbility().addEffect(new SearingBlazeEffect());
|
||||||
this.addWatcher(new SearingBlazeWatcher());
|
this.addWatcher(new LandfallWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearingBlaze(final SearingBlaze card) {
|
public SearingBlaze(final SearingBlaze card) {
|
||||||
|
|
@ -84,19 +85,19 @@ public class SearingBlaze extends CardImpl<SearingBlaze> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearingBlazeWatcher extends WatcherImpl<SearingBlazeWatcher> {
|
class LandfallWatcher extends WatcherImpl<LandfallWatcher> {
|
||||||
|
|
||||||
public SearingBlazeWatcher() {
|
public LandfallWatcher() {
|
||||||
super("LandPlayed");
|
super("LandPlayed", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearingBlazeWatcher(final SearingBlazeWatcher watcher) {
|
public LandfallWatcher(final LandfallWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearingBlazeWatcher copy() {
|
public LandfallWatcher copy() {
|
||||||
return new SearingBlazeWatcher(this);
|
return new LandfallWatcher(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -131,7 +132,7 @@ class SearingBlazeEffect extends OneShotEffect<SearingBlazeEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "LandPlayed");
|
Watcher watcher = game.getState().getWatchers().get("LandPlayed", source.getControllerId());
|
||||||
Player player = game.getPlayer(source.getTargets().get(0).getFirstTarget());
|
Player player = game.getPlayer(source.getTargets().get(0).getFirstTarget());
|
||||||
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import mage.watchers.Watcher;
|
||||||
import mage.watchers.WatcherImpl;
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -73,7 +74,7 @@ public class ArchiveTrap extends CardImpl<ArchiveTrap> {
|
||||||
class ArchiveTrapWatcher extends WatcherImpl<ArchiveTrapWatcher> {
|
class ArchiveTrapWatcher extends WatcherImpl<ArchiveTrapWatcher> {
|
||||||
|
|
||||||
public ArchiveTrapWatcher() {
|
public ArchiveTrapWatcher() {
|
||||||
super("LibrarySearched");
|
super("LibrarySearched", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArchiveTrapWatcher(final ArchiveTrapWatcher watcher) {
|
public ArchiveTrapWatcher(final ArchiveTrapWatcher watcher) {
|
||||||
|
|
@ -113,7 +114,7 @@ class ArchiveTrapAlternativeCost extends AlternativeCostImpl<ArchiveTrapAlternat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(Game game, Ability source) {
|
public boolean isAvailable(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "LibrarySearched");
|
Watcher watcher = game.getState().getWatchers().get("LibrarySearched", source.getControllerId());
|
||||||
if (watcher != null && watcher.conditionMet())
|
if (watcher != null && watcher.conditionMet())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,15 @@
|
||||||
package mage.sets.zendikar;
|
package mage.sets.zendikar;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
|
import mage.Constants.ColoredManaSymbol;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.AlternativeCostImpl;
|
import mage.abilities.costs.AlternativeCostImpl;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.ColoredManaCost;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -77,7 +79,7 @@ public class CobraTrap extends CardImpl<CobraTrap> {
|
||||||
class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
||||||
|
|
||||||
public CobraTrapWatcher() {
|
public CobraTrapWatcher() {
|
||||||
super("noncreature permanent destroyed");
|
super("noncreature permanent destroyed", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CobraTrapWatcher(final CobraTrapWatcher watcher) {
|
public CobraTrapWatcher(final CobraTrapWatcher watcher) {
|
||||||
|
|
@ -91,11 +93,7 @@ class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.END_TURN_STEP_POST) {
|
if (condition == true) { // no need to check - condition has already occured
|
||||||
condition = false;
|
|
||||||
}
|
|
||||||
if (condition == true) // no need to check - condition has already occured
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getType() == EventType.DESTROYED_PERMANENT
|
if (event.getType() == EventType.DESTROYED_PERMANENT
|
||||||
|
|
@ -110,8 +108,8 @@ class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
||||||
class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeCost> {
|
class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeCost> {
|
||||||
|
|
||||||
public CobraTrapAlternativeCost() {
|
public CobraTrapAlternativeCost() {
|
||||||
super("you may pay {0} rather than pay Cobra Trap's mana cost");
|
super("you may pay {G} rather than pay Cobra Trap's mana cost");
|
||||||
this.add(new GenericManaCost(0));
|
this.add(new ColoredManaCost(ColoredManaSymbol.G));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CobraTrapAlternativeCost(final CobraTrapAlternativeCost cost) {
|
public CobraTrapAlternativeCost(final CobraTrapAlternativeCost cost) {
|
||||||
|
|
@ -125,7 +123,7 @@ class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(Game game, Ability source) {
|
public boolean isAvailable(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "noncreature permanent destroyed");
|
Watcher watcher = game.getState().getWatchers().get("noncreature permanent destroyed", source.getControllerId());
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +132,6 @@ class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return "If a creature spell you cast this turn was countered by a spell or ability an opponent controlled, you may pay {0} rather than pay Cobra Trap's mana cost.";
|
return "If a noncreature permanent under your control was destroyed this turn by a spell or ability an opponent controlled, you may pay {G} rather than pay Cobra Trap's mana cost.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,20 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.zendikar;
|
package mage.sets.zendikar;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.AlternativeCostImpl;
|
import mage.abilities.costs.AlternativeCostImpl;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.FilterSpell;
|
import mage.filter.FilterSpell;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -78,16 +83,17 @@ public class MindbreakTrap extends CardImpl<MindbreakTrap> {
|
||||||
|
|
||||||
class MindbreakTrapWatcher extends WatcherImpl<MindbreakTrapWatcher> {
|
class MindbreakTrapWatcher extends WatcherImpl<MindbreakTrapWatcher> {
|
||||||
|
|
||||||
protected int spellCast;
|
private Map<UUID, Integer> counts = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
public MindbreakTrapWatcher() {
|
public MindbreakTrapWatcher() {
|
||||||
super("opponent cast three or more spells");
|
super("opponent cast three or more spells", WatcherScope.PLAYER);
|
||||||
spellCast = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindbreakTrapWatcher(final MindbreakTrapWatcher watcher) {
|
public MindbreakTrapWatcher(final MindbreakTrapWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
this.spellCast = watcher.spellCast;
|
for (Entry<UUID, Integer> entry: watcher.counts.entrySet()) {
|
||||||
|
counts.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -97,24 +103,27 @@ class MindbreakTrapWatcher extends WatcherImpl<MindbreakTrapWatcher> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.END_TURN_STEP_POST) {
|
if (condition == true) { // no need to check - condition has already occured
|
||||||
condition = false;
|
|
||||||
spellCast = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (condition == true) // no need to check - condition has already occured
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Logger.getAnonymousLogger().info(((Integer) spellCast).toString());
|
|
||||||
if (event.getType() == EventType.SPELL_CAST
|
if (event.getType() == EventType.SPELL_CAST
|
||||||
&& game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
&& game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
||||||
spellCast++;
|
int count = 1;
|
||||||
if (spellCast >= 3) {
|
if (counts.containsKey(event.getPlayerId())) {
|
||||||
|
count += counts.get(event.getPlayerId());
|
||||||
|
if (count >= 3)
|
||||||
condition = true;
|
condition = true;
|
||||||
}
|
}
|
||||||
|
counts.put(event.getPlayerId(), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
super.reset();
|
||||||
|
counts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlternativeCost> {
|
class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlternativeCost> {
|
||||||
|
|
@ -135,7 +144,7 @@ class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(Game game, Ability source) {
|
public boolean isAvailable(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "opponent cast three or more spells");
|
Watcher watcher = game.getState().getWatchers().get("opponent cast three or more spells", source.getControllerId());
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -144,9 +153,10 @@ class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return "If a creature spell you cast this turn was countered by a spell or ability an opponent controlled, you may pay {0} rather than pay Mindbreak Trap's mana cost.";
|
return "If an opponent cast three or more spells this turn, you may pay {0} rather than pay Mindbreak Trap's mana cost.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MindbreakEffect extends OneShotEffect<MindbreakEffect>{
|
class MindbreakEffect extends OneShotEffect<MindbreakEffect>{
|
||||||
|
|
||||||
MindbreakEffect(MindbreakEffect effect) {
|
MindbreakEffect(MindbreakEffect effect) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.AlternativeCostImpl;
|
import mage.abilities.costs.AlternativeCostImpl;
|
||||||
|
|
@ -93,7 +94,7 @@ public class SummoningTrap extends CardImpl<SummoningTrap> {
|
||||||
class SummoningTrapWatcher extends WatcherImpl<SummoningTrapWatcher> {
|
class SummoningTrapWatcher extends WatcherImpl<SummoningTrapWatcher> {
|
||||||
|
|
||||||
public SummoningTrapWatcher() {
|
public SummoningTrapWatcher() {
|
||||||
super("CreatureSpellCountered");
|
super("CreatureSpellCountered", WatcherScope.PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SummoningTrapWatcher(final SummoningTrapWatcher watcher) {
|
public SummoningTrapWatcher(final SummoningTrapWatcher watcher) {
|
||||||
|
|
@ -107,11 +108,7 @@ class SummoningTrapWatcher extends WatcherImpl<SummoningTrapWatcher> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.END_TURN_STEP_POST) {
|
if (condition == true) {// no need to check - condition has already occured
|
||||||
condition = false;
|
|
||||||
}
|
|
||||||
if (condition == true) // no need to check - condition has already occured
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getType() == EventType.COUNTERED
|
if (event.getType() == EventType.COUNTERED
|
||||||
|
|
@ -140,7 +137,7 @@ class SummoningTrapAlternativeCost extends AlternativeCostImpl<SummoningTrapAlte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(Game game, Ability source) {
|
public boolean isAvailable(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "CreatureSpellCountered");
|
Watcher watcher = game.getState().getWatchers().get("CreatureSpellCountered", source.getControllerId());
|
||||||
if (watcher != null && watcher.conditionMet()) {
|
if (watcher != null && watcher.conditionMet()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,12 @@ public final class Constants {
|
||||||
AURA
|
AURA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum WatcherScope {
|
||||||
|
GAME,
|
||||||
|
PLAYER,
|
||||||
|
CARD
|
||||||
|
}
|
||||||
|
|
||||||
public static final List<String> PlaneswalkerTypes = new ArrayList<String>()
|
public static final List<String> PlaneswalkerTypes = new ArrayList<String>()
|
||||||
{{add("Ajani"); add("Bolas"); add("Chandra"); add("Elspeth");add("Garruk"); add("Jace"); add("Liliana"); add("Nissa"); add("Sarkhan"); add("Sorin"); add("Tezzeret");}};
|
{{add("Ajani"); add("Bolas"); add("Chandra"); add("Elspeth");add("Garruk"); add("Jace"); add("Liliana"); add("Nissa"); add("Sarkhan"); add("Sorin"); add("Tezzeret");}};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class MorbidCondition implements Condition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "Morbid");
|
Watcher watcher = game.getState().getWatchers().get("Morbid");
|
||||||
return watcher.conditionMet();
|
return watcher.conditionMet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class NoSpellsWereCastLastTurnCondition implements Condition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(source.getControllerId(), "CastSpellLastTurnWatcher");
|
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
|
||||||
return watcher.getAmountOfSpellsCastOnPrevTurn() == 0;
|
return watcher.getAmountOfSpellsCastOnPrevTurn() == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class TwoOrMoreSpellsWereCastLastTurnCondition implements Condition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(source.getControllerId(), "CastSpellLastTurnWatcher");
|
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
|
||||||
return watcher.getAmountOfSpellsCastOnPrevTurn() >= 2;
|
return watcher.getAmountOfSpellsCastOnPrevTurn() >= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
|
import mage.watchers.common.BloodthirstWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -53,13 +55,16 @@ class BloodthirstEffect extends OneShotEffect<BloodthirstEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents");
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (player != null) {
|
||||||
|
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId());
|
||||||
if (watcher.conditionMet()) {
|
if (watcher.conditionMet()) {
|
||||||
Permanent p = game.getPermanent(source.getSourceId());
|
Permanent p = game.getPermanent(source.getSourceId());
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.addCounters(CounterType.P1P1.createInstance(amount), game);
|
p.addCounters(CounterType.P1P1.createInstance(amount), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public interface Card extends MageObject {
|
||||||
public void addWatcher(Watcher watcher);
|
public void addWatcher(Watcher watcher);
|
||||||
public SpellAbility getSpellAbility();
|
public SpellAbility getSpellAbility();
|
||||||
public List<String> getRules();
|
public List<String> getRules();
|
||||||
public Watchers getWatchers();
|
public List<Watcher> getWatchers();
|
||||||
public String getExpansionSetCode();
|
public String getExpansionSetCode();
|
||||||
public void setExpansionSetCode(String expansionSetCode);
|
public void setExpansionSetCode(String expansionSetCode);
|
||||||
public void setFaceDown(boolean value);
|
public void setFaceDown(boolean value);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageObjectImpl;
|
import mage.MageObjectImpl;
|
||||||
|
|
@ -50,7 +51,7 @@ import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.PermanentCard;
|
import mage.game.permanent.PermanentCard;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
import mage.watchers.Watchers;
|
import mage.watchers.WatcherImpl;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
|
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
|
||||||
|
|
@ -60,7 +61,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
|
|
||||||
protected UUID ownerId;
|
protected UUID ownerId;
|
||||||
protected int cardNumber;
|
protected int cardNumber;
|
||||||
protected Watchers watchers = new Watchers();
|
protected List<Watcher> watchers = new ArrayList<Watcher>();
|
||||||
protected String expansionSetCode;
|
protected String expansionSetCode;
|
||||||
protected Rarity rarity;
|
protected Rarity rarity;
|
||||||
protected boolean faceDown;
|
protected boolean faceDown;
|
||||||
|
|
@ -97,7 +98,9 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
cardNumber = card.cardNumber;
|
cardNumber = card.cardNumber;
|
||||||
expansionSetCode = card.expansionSetCode;
|
expansionSetCode = card.expansionSetCode;
|
||||||
rarity = card.rarity;
|
rarity = card.rarity;
|
||||||
watchers = card.watchers.copy();
|
for (Watcher watcher: (List<Watcher>)card.watchers) {
|
||||||
|
this.watchers.add(watcher.copy());
|
||||||
|
}
|
||||||
faceDown = card.faceDown;
|
faceDown = card.faceDown;
|
||||||
|
|
||||||
canTransform = card.canTransform;
|
canTransform = card.canTransform;
|
||||||
|
|
@ -112,7 +115,6 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
this.objectId = UUID.randomUUID();
|
this.objectId = UUID.randomUUID();
|
||||||
this.abilities.newOriginalId();
|
this.abilities.newOriginalId();
|
||||||
this.abilities.setSourceId(objectId);
|
this.abilities.setSourceId(objectId);
|
||||||
this.watchers.setSourceId(objectId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Card createCard(String name) {
|
public static Card createCard(String name) {
|
||||||
|
|
@ -190,7 +192,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Watchers getWatchers() {
|
public List<Watcher> getWatchers() {
|
||||||
return watchers;
|
return watchers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ import mage.watchers.Watcher;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import mage.abilities.common.ChancellorAbility;
|
import mage.abilities.common.ChancellorAbility;
|
||||||
|
|
||||||
import mage.abilities.mana.TriggeredManaAbility;
|
import mage.abilities.mana.TriggeredManaAbility;
|
||||||
|
|
@ -160,6 +161,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
state.setZone(card.getId(), Zone.OUTSIDE);
|
state.setZone(card.getId(), Zone.OUTSIDE);
|
||||||
for (Watcher watcher: card.getWatchers()) {
|
for (Watcher watcher: card.getWatchers()) {
|
||||||
watcher.setControllerId(ownerId);
|
watcher.setControllerId(ownerId);
|
||||||
|
watcher.setSourceId(card.getId());
|
||||||
state.getWatchers().add(watcher);
|
state.getWatchers().add(watcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,8 @@ public class ZoneChangeEvent extends GameEvent {
|
||||||
public Permanent getTarget() {
|
public Permanent getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDiesEvent() {
|
||||||
|
return (toZone == Zone.GRAVEYARD && fromZone == Zone.BATTLEFIELD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Watchers getWatchers() {
|
public List<Watcher> getWatchers() {
|
||||||
return card.getWatchers();
|
return card.getWatchers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,6 @@ import mage.game.stack.StackAbility;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.target.common.TargetCardInLibrary;
|
import mage.target.common.TargetCardInLibrary;
|
||||||
import mage.target.common.TargetDiscard;
|
import mage.target.common.TargetDiscard;
|
||||||
import mage.watchers.Watcher;
|
|
||||||
import mage.watchers.common.BloodthirstWatcher;
|
import mage.watchers.common.BloodthirstWatcher;
|
||||||
|
|
||||||
public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable {
|
public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable {
|
||||||
|
|
@ -188,9 +187,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.passedTurn = false;
|
this.passedTurn = false;
|
||||||
this.canGainLife = true;
|
this.canGainLife = true;
|
||||||
this.canLoseLife = true;
|
this.canLoseLife = true;
|
||||||
Watcher bloodthirst = new BloodthirstWatcher();
|
game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
|
||||||
bloodthirst.setControllerId(playerId);
|
|
||||||
game.getState().getWatchers().add(bloodthirst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.watchers;
|
package mage.watchers;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -42,9 +43,11 @@ public abstract class WatcherImpl<T extends WatcherImpl<T>> implements Watcher<T
|
||||||
protected UUID sourceId;
|
protected UUID sourceId;
|
||||||
protected String key;
|
protected String key;
|
||||||
protected boolean condition;
|
protected boolean condition;
|
||||||
|
protected WatcherScope scope;
|
||||||
|
|
||||||
public WatcherImpl(String key) {
|
public WatcherImpl(String key, WatcherScope scope) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WatcherImpl(final WatcherImpl watcher) {
|
public WatcherImpl(final WatcherImpl watcher) {
|
||||||
|
|
@ -52,6 +55,7 @@ public abstract class WatcherImpl<T extends WatcherImpl<T>> implements Watcher<T
|
||||||
this.key = watcher.key;
|
this.key = watcher.key;
|
||||||
this.controllerId = watcher.controllerId;
|
this.controllerId = watcher.controllerId;
|
||||||
this.sourceId = watcher.sourceId;
|
this.sourceId = watcher.sourceId;
|
||||||
|
this.scope = watcher.scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -76,6 +80,14 @@ public abstract class WatcherImpl<T extends WatcherImpl<T>> implements Watcher<T
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
|
switch (scope) {
|
||||||
|
case GAME:
|
||||||
|
return key;
|
||||||
|
case PLAYER:
|
||||||
|
return controllerId + key;
|
||||||
|
case CARD:
|
||||||
|
return sourceId + key;
|
||||||
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@
|
||||||
|
|
||||||
package mage.watchers;
|
package mage.watchers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -37,46 +38,59 @@ import mage.game.events.GameEvent;
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class Watchers extends ArrayList<Watcher> {
|
public class Watchers extends HashMap<String, Watcher> {
|
||||||
|
|
||||||
|
public Watchers() {}
|
||||||
|
|
||||||
|
public Watchers(final Watchers watchers) {
|
||||||
|
for (Map.Entry<String, Watcher> entry: watchers.entrySet()) {
|
||||||
|
this.put(entry.getKey(), entry.getValue().copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Watchers copy() {
|
public Watchers copy() {
|
||||||
Watchers newCopy = new Watchers();
|
return new Watchers(this);
|
||||||
for (Watcher watcher: this) {
|
|
||||||
newCopy.add(watcher.copy());
|
|
||||||
}
|
}
|
||||||
return newCopy;
|
|
||||||
|
public void add(Watcher watcher) {
|
||||||
|
if (!this.containsKey(watcher.getKey()))
|
||||||
|
this.put(watcher.getKey(), watcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
for (Watcher watcher: this) {
|
for (Watcher watcher: this.values()) {
|
||||||
watcher.watch(event, game);
|
watcher.watch(event, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
for (Watcher watcher: this) {
|
for (Watcher watcher: this.values()) {
|
||||||
watcher.reset();
|
watcher.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSourceId(UUID sourceId) {
|
// public void setSourceId(UUID sourceId) {
|
||||||
for (Watcher watcher: this) {
|
// for (Watcher watcher: this.values()) {
|
||||||
watcher.setSourceId(sourceId);
|
// watcher.setSourceId(sourceId);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setControllerId(UUID controllerId) {
|
||||||
|
// for (Watcher watcher: this.values()) {
|
||||||
|
// watcher.setControllerId(controllerId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public Watcher get(String key, UUID id) {
|
||||||
|
return this.get(id + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setControllerId(UUID controllerId) {
|
// public Watcher get(UUID controllerId, UUID sourceId, String key) {
|
||||||
for (Watcher watcher: this) {
|
// for (Watcher watcher: this) {
|
||||||
watcher.setControllerId(controllerId);
|
// if ((watcher.getControllerId() == null || watcher.getControllerId().equals(controllerId)) && watcher.getKey().equals(key) && watcher.getSourceId().equals(sourceId))
|
||||||
}
|
// return watcher;
|
||||||
}
|
// }
|
||||||
|
// return null;
|
||||||
public Watcher get(UUID controllerId, String key) {
|
// }
|
||||||
for (Watcher watcher: this) {
|
|
||||||
if ((watcher.getControllerId() == null || watcher.getControllerId().equals(controllerId)) && watcher.getKey().equals(key))
|
|
||||||
return watcher;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.watchers.common;
|
package mage.watchers.common;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamagedPlayerEvent;
|
import mage.game.events.DamagedPlayerEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -10,8 +12,9 @@ import mage.watchers.WatcherImpl;
|
||||||
* @author Loki
|
* @author Loki
|
||||||
*/
|
*/
|
||||||
public class BloodthirstWatcher extends WatcherImpl<BloodthirstWatcher> {
|
public class BloodthirstWatcher extends WatcherImpl<BloodthirstWatcher> {
|
||||||
public BloodthirstWatcher() {
|
public BloodthirstWatcher(UUID controllerId) {
|
||||||
super("DamagedOpponents");
|
super("DamagedOpponents", WatcherScope.PLAYER);
|
||||||
|
this.controllerId = controllerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BloodthirstWatcher(final BloodthirstWatcher watcher) {
|
public BloodthirstWatcher(final BloodthirstWatcher watcher) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package mage.watchers.common;
|
package mage.watchers.common;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
|
|
@ -8,7 +9,7 @@ import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
public class CastFromHandWatcher extends WatcherImpl<CastFromHandWatcher> {
|
public class CastFromHandWatcher extends WatcherImpl<CastFromHandWatcher> {
|
||||||
public CastFromHandWatcher() {
|
public CastFromHandWatcher() {
|
||||||
super("CastFromHand");
|
super("CastFromHand", WatcherScope.CARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CastFromHandWatcher(final CastFromHandWatcher watcher) {
|
public CastFromHandWatcher(final CastFromHandWatcher watcher) {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.watchers.common;
|
package mage.watchers.common;
|
||||||
|
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.watchers.WatcherImpl;
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
@ -42,7 +43,7 @@ public class CastSpellLastTurnWatcher extends WatcherImpl<CastSpellLastTurnWatch
|
||||||
private int amountOfSpellsCastOnCurrentTurn;
|
private int amountOfSpellsCastOnCurrentTurn;
|
||||||
|
|
||||||
public CastSpellLastTurnWatcher() {
|
public CastSpellLastTurnWatcher() {
|
||||||
super("CastSpellLastTurnWatcher");
|
super("CastSpellLastTurnWatcher", WatcherScope.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CastSpellLastTurnWatcher(final CastSpellLastTurnWatcher watcher) {
|
public CastSpellLastTurnWatcher(final CastSpellLastTurnWatcher watcher) {
|
||||||
|
|
|
||||||
76
Mage/src/mage/watchers/common/DamagedByWatcher.java
Normal file
76
Mage/src/mage/watchers/common/DamagedByWatcher.java
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.watchers.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.watchers.WatcherImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class DamagedByWatcher extends WatcherImpl<DamagedByWatcher> {
|
||||||
|
|
||||||
|
public List<UUID> damagedCreatures = new ArrayList<UUID>();
|
||||||
|
|
||||||
|
public DamagedByWatcher() {
|
||||||
|
super("DamagedByWatcher", WatcherScope.CARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamagedByWatcher(final DamagedByWatcher watcher) {
|
||||||
|
super(watcher);
|
||||||
|
this.damagedCreatures = watcher.damagedCreatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DamagedByWatcher copy() {
|
||||||
|
return new DamagedByWatcher(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void watch(GameEvent event, Game game) {
|
||||||
|
if (event.getType() == EventType.DAMAGED_CREATURE) {
|
||||||
|
if (sourceId.equals(event.getSourceId()) && !damagedCreatures.contains(event.getTargetId())) {
|
||||||
|
damagedCreatures.add(event.getTargetId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
super.reset();
|
||||||
|
damagedCreatures.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -30,6 +30,7 @@ package mage.watchers.common;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
|
import mage.Constants.WatcherScope;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
|
@ -43,7 +44,7 @@ import mage.watchers.WatcherImpl;
|
||||||
public class MorbidWatcher extends WatcherImpl<MorbidWatcher> {
|
public class MorbidWatcher extends WatcherImpl<MorbidWatcher> {
|
||||||
|
|
||||||
public MorbidWatcher() {
|
public MorbidWatcher() {
|
||||||
super("Morbid");
|
super("Morbid", WatcherScope.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MorbidWatcher(final MorbidWatcher watcher) {
|
public MorbidWatcher(final MorbidWatcher watcher) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue