mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00: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 mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.common.DiscardTargetEffect;
|
||||
import mage.cards.Card;
|
||||
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.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
|
@ -60,10 +52,10 @@ public class AshenSkinZubera extends CardImpl<AshenSkinZubera> {
|
|||
this.color.setBlack(true);
|
||||
this.power = new MageInt(1);
|
||||
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());
|
||||
this.addAbility(ability);
|
||||
this.addWatcher(new AshenSkinZuberaWatcher());
|
||||
this.addWatcher(new ZuberasDiedWatcher());
|
||||
}
|
||||
|
||||
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 mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
|
@ -38,14 +37,10 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.token.SpiritToken;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -61,8 +56,8 @@ public class DrippingTongueZubera extends CardImpl<DrippingTongueZubera> {
|
|||
this.color.setGreen(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(2);
|
||||
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SpiritToken(), new DrippingTongueZuberaDynamicValue()), false));
|
||||
this.addWatcher(new DrippingTongueZuberaWatcher());
|
||||
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SpiritToken(), new ZuberasDiedDynamicValue()), false));
|
||||
this.addWatcher(new ZuberasDiedWatcher());
|
||||
}
|
||||
|
||||
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 mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.Card;
|
||||
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.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -61,10 +53,10 @@ public class EmberFistZubera extends CardImpl<EmberFistZubera> {
|
|||
this.color.setRed(true);
|
||||
this.power = new MageInt(1);
|
||||
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());
|
||||
this.addAbility(ability);
|
||||
this.addWatcher(new EmberFistZuberaWatcher());
|
||||
this.addWatcher(new ZuberasDiedWatcher());
|
||||
}
|
||||
|
||||
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.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
|
@ -43,7 +44,6 @@ import mage.cards.CardImpl;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
|
@ -59,8 +59,8 @@ public class FloatingDreamZubera extends CardImpl<FloatingDreamZubera> {
|
|||
this.color.setBlue(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(2);
|
||||
this.addAbility(new DiesTriggeredAbility(new DrawCardControllerEffect(new FloatingDreamZuberaDynamicValue())));
|
||||
this.addWatcher(new FloatingDreamZuberaWatcher());
|
||||
this.addAbility(new DiesTriggeredAbility(new DrawCardControllerEffect(new ZuberasDiedDynamicValue())));
|
||||
this.addWatcher(new ZuberasDiedWatcher());
|
||||
}
|
||||
|
||||
public FloatingDreamZubera(final FloatingDreamZubera card) {
|
||||
|
@ -75,32 +75,30 @@ public class FloatingDreamZubera extends CardImpl<FloatingDreamZubera> {
|
|||
}
|
||||
|
||||
|
||||
class FloatingDreamZuberaWatcher extends WatcherImpl<FloatingDreamZuberaWatcher> {
|
||||
class ZuberasDiedWatcher extends WatcherImpl<ZuberasDiedWatcher> {
|
||||
|
||||
public int zuberasDiedThisTurn = 0;
|
||||
|
||||
public FloatingDreamZuberaWatcher() {
|
||||
super("ZuberasDiedFloatingDreamZubera");
|
||||
public ZuberasDiedWatcher() {
|
||||
super("ZuberasDied", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public FloatingDreamZuberaWatcher(final FloatingDreamZuberaWatcher watcher) {
|
||||
public ZuberasDiedWatcher(final ZuberasDiedWatcher watcher) {
|
||||
super(watcher);
|
||||
this.zuberasDiedThisTurn = watcher.zuberasDiedThisTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatingDreamZuberaWatcher copy() {
|
||||
return new FloatingDreamZuberaWatcher(this);
|
||||
public ZuberasDiedWatcher copy() {
|
||||
return new ZuberasDiedWatcher(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++;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card != null && card.hasSubtype("Zubera")) {
|
||||
zuberasDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,17 +111,17 @@ class FloatingDreamZuberaWatcher extends WatcherImpl<FloatingDreamZuberaWatcher>
|
|||
|
||||
}
|
||||
|
||||
class FloatingDreamZuberaDynamicValue implements DynamicValue {
|
||||
class ZuberasDiedDynamicValue implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility) {
|
||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedFloatingDreamZubera");
|
||||
return ((FloatingDreamZuberaWatcher) watcher).zuberasDiedThisTurn;
|
||||
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied");
|
||||
return watcher.zuberasDiedThisTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue clone() {
|
||||
return new FloatingDreamZuberaDynamicValue();
|
||||
public ZuberasDiedDynamicValue clone() {
|
||||
return new ZuberasDiedDynamicValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,6 +131,6 @@ class FloatingDreamZuberaDynamicValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
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.continious.GainAbilitySourceEffect;
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
@ -105,10 +106,10 @@ class MyojinOfCleansingFireEntersBattlefieldEffect extends OneShotEffect<MyojinO
|
|||
|
||||
@Override
|
||||
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());
|
||||
if (p != null) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
Watcher watcher = game.getState().getWatchers().get("CastFromHand", source.getSourceId());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
p.addCounters(CounterType.DIVINITY.createInstance(), game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SilentChantZubera extends CardImpl<SilentChantZubera> {
|
|||
this.toughness = new MageInt(2);
|
||||
Ability ability = new DiesTriggeredAbility(new GainLifeEffect(new SilentChantZuberaDynamicValue()));
|
||||
this.addAbility(ability);
|
||||
this.addWatcher(new AshenSkinZuberaWatcher());
|
||||
this.addWatcher(new ZuberasDiedWatcher());
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility) {
|
||||
Watcher watcher = game.getState().getWatchers().get(sourceAbility.getControllerId(), "ZuberasDiedSilentChantZubera");
|
||||
return ((SilentChantZuberaWatcher) watcher).zuberasDiedThisTurn;
|
||||
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied");
|
||||
return watcher.zuberasDiedThisTurn * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue clone() {
|
||||
public SilentChantZuberaDynamicValue clone() {
|
||||
return new SilentChantZuberaDynamicValue();
|
||||
}
|
||||
|
||||
|
@ -134,6 +96,6 @@ class SilentChantZuberaDynamicValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
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.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -47,8 +46,7 @@ import mage.game.events.GameEvent.EventType;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -70,7 +68,7 @@ public class AbattoirGhoul extends CardImpl<AbattoirGhoul> {
|
|||
AbattoirGhoulEffect effect = new AbattoirGhoulEffect();
|
||||
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||
this.addWatcher(new AbattoirGhoulWatcher());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
}
|
||||
|
||||
public AbattoirGhoul(final AbattoirGhoul card) {
|
||||
|
@ -118,47 +116,15 @@ class AbattoirGhoulEffect extends ReplacementEffectImpl<AbattoirGhoulEffect> {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE &&
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD &&
|
||||
((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "AbattoirGhoulDamagedCreature");
|
||||
if (watcher != null)
|
||||
return watcher.conditionMet();
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null)
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
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
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int damage = 3;
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "Morbid");
|
||||
Watcher watcher = game.getState().getWatchers().get("Morbid");
|
||||
if (watcher.conditionMet()) {
|
||||
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 TransformAbility());
|
||||
|
||||
this.addWatcher(new HomicidalBrute.HomicidalBruteWatcher());
|
||||
// this.addWatcher(new HomicidalBrute.HomicidalBruteWatcher());
|
||||
}
|
||||
|
||||
public CivilizedScholar(final CivilizedScholar card) {
|
||||
|
|
|
@ -39,10 +39,10 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.cards.Card;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
this.addAbility(new HomicidalBruteTriggeredAbility());
|
||||
this.addWatcher(new HomicidalBruteWatcher());
|
||||
}
|
||||
|
||||
public HomicidalBrute(final HomicidalBrute card) {
|
||||
|
@ -76,28 +77,29 @@ public class HomicidalBrute extends CardImpl<HomicidalBrute> {
|
|||
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() {
|
||||
super("HomicidalBruteWatcher");
|
||||
}
|
||||
public HomicidalBruteWatcher() {
|
||||
super("HomicidalBruteAttacked", WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HomicidalBruteWatcher copy() {
|
||||
return new HomicidalBruteWatcher(this);
|
||||
}
|
||||
@Override
|
||||
public HomicidalBruteWatcher copy() {
|
||||
return new HomicidalBruteWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
||||
condition = true;
|
||||
}
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (condition == true)
|
||||
return;
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
||||
condition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +123,7 @@ class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl<HomicidalBrute
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
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()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class ReaperFromTheAbyssAbility extends TriggeredAbilityImpl<ReaperFromTheAbyssA
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
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 false;
|
||||
|
|
|
@ -94,7 +94,7 @@ class SkirsdagHighPriestCost extends CostImpl<SkirsdagHighPriestCost> {
|
|||
|
||||
@Override
|
||||
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
|
||||
|
|
|
@ -33,12 +33,14 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -81,7 +83,7 @@ public class AngelicArbiter extends CardImpl<AngelicArbiter> {
|
|||
class AngelicArbiterWatcher1 extends WatcherImpl<AngelicArbiterWatcher1> {
|
||||
|
||||
public AngelicArbiterWatcher1() {
|
||||
super("CastSpell");
|
||||
super("OpponentCastSpell", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public AngelicArbiterWatcher1(final AngelicArbiterWatcher1 watcher) {
|
||||
|
@ -106,7 +108,7 @@ class AngelicArbiterWatcher1 extends WatcherImpl<AngelicArbiterWatcher1> {
|
|||
class AngelicArbiterWatcher2 extends WatcherImpl<AngelicArbiterWatcher2> {
|
||||
|
||||
public AngelicArbiterWatcher2() {
|
||||
super("Attacked");
|
||||
super("OpponentAttacked", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public AngelicArbiterWatcher2(final AngelicArbiterWatcher2 watcher) {
|
||||
|
@ -155,9 +157,9 @@ class AngelicArbiterEffect1 extends ReplacementEffectImpl<AngelicArbiterEffect1>
|
|||
@Override
|
||||
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())) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "CastSpell");
|
||||
if (watcher != null && watcher.conditionMet())
|
||||
return true;
|
||||
Watcher watcher = game.getState().getWatchers().get("OpponentCastSpell", source.getControllerId());
|
||||
if (watcher != null && watcher.conditionMet())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -193,9 +195,9 @@ class AngelicArbiterEffect2 extends ReplacementEffectImpl<AngelicArbiterEffect2>
|
|||
@Override
|
||||
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())) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "Attacked");
|
||||
if (watcher != null && watcher.conditionMet())
|
||||
return true;
|
||||
Watcher watcher = game.getState().getWatchers().get("OpponentAttacked", source.getControllerId());
|
||||
if (watcher != null && watcher.conditionMet())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,9 @@ import mage.abilities.effects.RestrictionEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.BloodthirstWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -95,10 +97,7 @@ class BloodcrazedGoblinEffect extends RestrictionEffect<BloodcrazedGoblinEffect>
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents");
|
||||
if (watcher != null) {
|
||||
return !watcher.conditionMet();
|
||||
}
|
||||
return false;
|
||||
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId());
|
||||
return !watcher.conditionMet();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,13 +32,11 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
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.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -46,8 +44,7 @@ import mage.game.events.GameEvent.EventType;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,10 +57,10 @@ public class RedSunsZenith extends CardImpl<RedSunsZenith> {
|
|||
this.expansionSetCode = "MBS";
|
||||
this.color.setRed(true);
|
||||
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(ShuffleSpellEffect.getInstance());
|
||||
this.addWatcher(new RedSunsZenithWatcher());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
}
|
||||
|
||||
public RedSunsZenith(final RedSunsZenith card) {
|
||||
|
@ -109,42 +106,12 @@ class RedSunsZenithEffect extends ReplacementEffectImpl<RedSunsZenithEffect> {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE &&
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD &&
|
||||
((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "RedSunsZenithDamagedCreature");
|
||||
if (watcher != null)
|
||||
return watcher.conditionMet();
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null)
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -36,12 +38,14 @@ import mage.Constants;
|
|||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.TurnPhase;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -127,10 +131,9 @@ class CathedralMembraneEffect extends OneShotEffect<CathedralMembraneEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get(source.getControllerId(), "CathedralMembraneWatcher");
|
||||
if (watcher != null && watcher.blockedCreatures.containsKey(source.getSourceId())) {
|
||||
Set<UUID> creatures = watcher.blockedCreatures.get(source.getSourceId());
|
||||
for (UUID uuid : creatures) {
|
||||
CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get("CathedralMembraneWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
for (UUID uuid : watcher.blockedCreatures) {
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if (permanent != null) {
|
||||
permanent.damage(6, source.getSourceId(), game, true, false);
|
||||
|
@ -143,14 +146,15 @@ class CathedralMembraneEffect extends OneShotEffect<CathedralMembraneEffect> {
|
|||
|
||||
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() {
|
||||
super("CathedralMembraneWatcher");
|
||||
super("CathedralMembraneWatcher", WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public CathedralMembraneWatcher(final CathedralMembraneWatcher watcher) {
|
||||
super(watcher);
|
||||
this.blockedCreatures = watcher.blockedCreatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,13 +165,8 @@ class CathedralMembraneWatcher extends WatcherImpl<CathedralMembraneWatcher> {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED && event.getSourceId().equals(sourceId)) {
|
||||
Set<UUID> creatures = blockedCreatures.get(sourceId);
|
||||
if (creatures != null) {
|
||||
creatures.add(event.getTargetId());
|
||||
} else {
|
||||
creatures = new HashSet<UUID>();
|
||||
creatures.add(event.getTargetId());
|
||||
blockedCreatures.put(sourceId, creatures);
|
||||
if (!blockedCreatures.contains(event.getTargetId())) {
|
||||
blockedCreatures.add(event.getTargetId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,12 @@ package mage.sets.newphyrexia;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
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.CardImpl;
|
||||
import mage.game.Game;
|
||||
|
@ -56,7 +57,7 @@ public class FreshMeat extends CardImpl<FreshMeat> {
|
|||
this.color.setGreen(true);
|
||||
|
||||
this.addWatcher(new FreshMeatWatcher());
|
||||
this.getSpellAbility().addEffect(new FreshMeatEffect());
|
||||
this.getSpellAbility().addEffect(new CreateTokenEffect(new BeastToken(), new FreshMeatDynamicValue()));
|
||||
}
|
||||
|
||||
public FreshMeat(final FreshMeat card) {
|
||||
|
@ -74,7 +75,7 @@ class FreshMeatWatcher extends WatcherImpl<FreshMeatWatcher> {
|
|||
private int creaturesCount = 0;
|
||||
|
||||
public FreshMeatWatcher() {
|
||||
super("CreaturesDiedFreshMeat");
|
||||
super("YourCreaturesDied", WatcherScope.PLAYER);
|
||||
condition = true;
|
||||
}
|
||||
|
||||
|
@ -94,9 +95,7 @@ class FreshMeatWatcher extends WatcherImpl<FreshMeatWatcher> {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD
|
||||
&& ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (card != null && card.getOwnerId().equals(this.controllerId) && card.getCardType().contains(CardType.CREATURE)) {
|
||||
creaturesCount++;
|
||||
|
@ -111,28 +110,28 @@ class FreshMeatWatcher extends WatcherImpl<FreshMeatWatcher> {
|
|||
}
|
||||
}
|
||||
|
||||
class FreshMeatEffect extends OneShotEffect<FreshMeatEffect> {
|
||||
class FreshMeatDynamicValue implements DynamicValue {
|
||||
|
||||
public FreshMeatEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
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";
|
||||
}
|
||||
|
||||
public FreshMeatEffect(final FreshMeatEffect effect) {
|
||||
super(effect);
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility) {
|
||||
FreshMeatWatcher watcher = (FreshMeatWatcher) game.getState().getWatchers().get("YourCreaturesDied", sourceAbility.getControllerId());
|
||||
if (watcher != null)
|
||||
return watcher.getCreaturesCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FreshMeatEffect copy() {
|
||||
return new FreshMeatEffect(this);
|
||||
public FreshMeatDynamicValue clone() {
|
||||
return new FreshMeatDynamicValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FreshMeatWatcher watcher = (FreshMeatWatcher) game.getState().getWatchers().get(source.getControllerId(), "CreaturesDiedFreshMeat");
|
||||
int count = watcher.getCreaturesCount();
|
||||
BeastToken token = new BeastToken();
|
||||
token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
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 mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
|
@ -92,10 +93,10 @@ class VengevineAbility extends TriggeredAbilityImpl<VengevineAbility> {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.SPELL_CAST && event.getPlayerId().equals(controllerId)) {
|
||||
Watcher watcher = game.getState().getWatchers().get(controllerId, "CreatureCast");
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
return true;
|
||||
}
|
||||
Watcher watcher = game.getState().getWatchers().get("CreatureCast", controllerId);
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -113,11 +114,12 @@ class VengevineWatcher extends WatcherImpl<VengevineWatcher> {
|
|||
int creatureSpellCount = 0;
|
||||
|
||||
public VengevineWatcher() {
|
||||
super("CreatureCast");
|
||||
super("CreatureCast", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public VengevineWatcher(final VengevineWatcher watcher) {
|
||||
super(watcher);
|
||||
this.creatureSpellCount = watcher.creatureSpellCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
|||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
|
@ -83,7 +84,7 @@ class FleshAllergyWatcher extends WatcherImpl<FleshAllergyWatcher> {
|
|||
public int creaturesDiedThisTurn = 0;
|
||||
|
||||
public FleshAllergyWatcher() {
|
||||
super("CreaturesDiedFleshAllergy");
|
||||
super("CreaturesDied", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public FleshAllergyWatcher(final FleshAllergyWatcher watcher) {
|
||||
|
@ -97,14 +98,11 @@ class FleshAllergyWatcher extends WatcherImpl<FleshAllergyWatcher> {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE) {
|
||||
if (((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD &&
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
creaturesDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
creaturesDiedThisTurn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +118,7 @@ class FleshAllergyEffect extends OneShotEffect<FleshAllergyEffect> {
|
|||
|
||||
public FleshAllergyEffect() {
|
||||
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) {
|
||||
|
@ -134,18 +132,18 @@ class FleshAllergyEffect extends OneShotEffect<FleshAllergyEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "CreaturesDiedFleshAllergy");
|
||||
Card card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
|
||||
if (card != null && watcher != null) {
|
||||
Player player = game.getPlayer(((Permanent)card).getControllerId());
|
||||
if (player != null) {
|
||||
int amount = ((FleshAllergyWatcher)watcher).creaturesDiedThisTurn;
|
||||
if (amount > 0) {
|
||||
player.loseLife(amount, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
FleshAllergyWatcher watcher = (FleshAllergyWatcher) game.getState().getWatchers().get("CreaturesDied");
|
||||
Card card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
|
||||
if (card != null && watcher != null) {
|
||||
Player player = game.getPlayer(((Permanent)card).getControllerId());
|
||||
if (player != null) {
|
||||
int amount = watcher.creaturesDiedThisTurn;
|
||||
if (amount > 0) {
|
||||
player.loseLife(amount, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,12 @@ package mage.sets.scarsofmirrodin;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.MetalcraftCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -91,9 +93,9 @@ class MoltenPsycheEffect extends OneShotEffect<MoltenPsycheEffect> {
|
|||
player.getHand().clear();
|
||||
player.drawCards(count, game);
|
||||
if (MetalcraftCondition.getInstance().apply(game, source) && !playerId.equals(source.getControllerId())) {
|
||||
MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get(source.getControllerId(), "CardsDrawnMoltenPsyche");
|
||||
player.damage(watcher.getDraws(playerId), source.getId(), game, false, true);
|
||||
}
|
||||
MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get("CardsDrawn");
|
||||
player.damage(watcher.getDraws(playerId), source.getId(), game, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -111,11 +113,14 @@ class MoltenPsycheWatcher extends WatcherImpl<MoltenPsycheWatcher> {
|
|||
private Map<UUID, Integer> draws = new HashMap<UUID, Integer>();
|
||||
|
||||
public MoltenPsycheWatcher() {
|
||||
super("CardsDrawnMoltenPsyche");
|
||||
super("CardsDrawn", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public MoltenPsycheWatcher(final MoltenPsycheWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry: watcher.draws.entrySet()) {
|
||||
draws.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,6 +47,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.watchers.WatcherImpl;
|
||||
|
||||
import java.util.*;
|
||||
import mage.Constants.WatcherScope;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -98,32 +99,34 @@ class SteelHellkiteDestroyEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatchers().get(source.getControllerId(), "SteelHellkiteWatcher");
|
||||
if (watcher != null && watcher.damagedPlayers.containsKey(source.getSourceId())) {
|
||||
Set<UUID> players = watcher.damagedPlayers.get(source.getSourceId());
|
||||
int xValue = source.getManaCostsToPay().getX();
|
||||
for (UUID uuid : players) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getControllerId().equals(uuid) && permanent.getManaCost().convertedManaCost() == xValue) {
|
||||
permanent.destroy(source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatchers().get("SteelHellkiteWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
int xValue = source.getManaCostsToPay().getX();
|
||||
for (UUID uuid : watcher.damagedPlayers) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getControllerId().equals(uuid) && permanent.getManaCost().convertedManaCost() == xValue) {
|
||||
permanent.destroy(source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
super("SteelHellkiteWatcher");
|
||||
super("SteelHellkiteWatcher", WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public SteelHellkiteWatcher(final SteelHellkiteWatcher watcher) {
|
||||
super(watcher);
|
||||
for (UUID playerId: watcher.damagedPlayers) {
|
||||
damagedPlayers.add(playerId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,14 +141,9 @@ class SteelHellkiteWatcher extends WatcherImpl<SteelHellkiteWatcher> {
|
|||
UUID sourceId = damageEvent.getSourceId();
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (sourceId != null && permanent != null && permanent.getName().equals("Steel Hellkite")) {
|
||||
Set<UUID> players = damagedPlayers.get(sourceId);
|
||||
if (players != null) {
|
||||
players.add(damageEvent.getPlayerId());
|
||||
} else {
|
||||
players = new HashSet<UUID>();
|
||||
players.add(damageEvent.getPlayerId());
|
||||
damagedPlayers.put(sourceId, players);
|
||||
}
|
||||
if (!damagedPlayers.contains(event.getTargetId())) {
|
||||
damagedPlayers.add(event.getTargetId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
package mage.sets.scarsofmirrodin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
|
@ -41,10 +44,10 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.WatcherScope;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
|
@ -74,15 +77,17 @@ public class TunnelIgnus extends CardImpl<TunnelIgnus> {
|
|||
}
|
||||
|
||||
class TunnelIgnusWatcher extends WatcherImpl {
|
||||
int count = 0;
|
||||
protected Map<UUID, Integer> counts = new HashMap<UUID, Integer>();
|
||||
|
||||
public TunnelIgnusWatcher() {
|
||||
super("LandPlayedCount");
|
||||
super("LandPlayedCount", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) {
|
||||
super(watcher);
|
||||
this.count = watcher.count;
|
||||
for (Entry<UUID, Integer> entry: watcher.counts.entrySet()) {
|
||||
counts.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,15 +97,14 @@ class TunnelIgnusWatcher extends WatcherImpl {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (condition == true) //no need to check - condition has already occured
|
||||
return;
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Constants.Zone.BATTLEFIELD) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.getCardType().contains(CardType.LAND) && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) {
|
||||
count++;
|
||||
if (count > 1) {
|
||||
condition = true;
|
||||
int count = 1;
|
||||
if (counts.containsKey(permanent.getControllerId())) {
|
||||
count += counts.get(permanent.getControllerId());
|
||||
}
|
||||
counts.put(permanent.getControllerId(), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +112,7 @@ class TunnelIgnusWatcher extends WatcherImpl {
|
|||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
count = 0;
|
||||
counts.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,18 +132,18 @@ class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl<TunnelIgnusTrigge
|
|||
|
||||
@Override
|
||||
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) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND) && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Constants.Zone.BATTLEFIELD) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
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()) {
|
||||
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import mage.Constants.SubLayer;
|
|||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -63,7 +64,7 @@ public class Groundswell extends CardImpl<Groundswell> {
|
|||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().addEffect(new GroundswellEffect(Duration.EndOfTurn));
|
||||
|
||||
this.addWatcher(new GroundswellWatcher());
|
||||
this.addWatcher(new LandfallWatcher());
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
public GroundswellEffect(Duration duration) {
|
||||
|
@ -122,19 +95,19 @@ class GroundswellEffect extends ContinuousEffectImpl<GroundswellEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "LandPlayed");
|
||||
Permanent target = (Permanent) game.getPermanent(source.getFirstTarget());
|
||||
if (target != null) {
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
target.addPower(4);
|
||||
target.addToughness(4);
|
||||
}
|
||||
else{
|
||||
target.addPower(2);
|
||||
target.addToughness(2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Watcher watcher = game.getState().getWatchers().get("LandPlayed", source.getControllerId());
|
||||
Permanent target = (Permanent) game.getPermanent(source.getFirstTarget());
|
||||
if (target != null) {
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
target.addPower(4);
|
||||
target.addToughness(4);
|
||||
}
|
||||
else{
|
||||
target.addPower(2);
|
||||
target.addToughness(2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
|||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -70,7 +71,7 @@ public class SearingBlaze extends CardImpl<SearingBlaze> {
|
|||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
this.getSpellAbility().addTarget(new SearingBlazeTarget());
|
||||
this.getSpellAbility().addEffect(new SearingBlazeEffect());
|
||||
this.addWatcher(new SearingBlazeWatcher());
|
||||
this.addWatcher(new LandfallWatcher());
|
||||
}
|
||||
|
||||
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() {
|
||||
super("LandPlayed");
|
||||
public LandfallWatcher() {
|
||||
super("LandPlayed", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public SearingBlazeWatcher(final SearingBlazeWatcher watcher) {
|
||||
public LandfallWatcher(final LandfallWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearingBlazeWatcher copy() {
|
||||
return new SearingBlazeWatcher(this);
|
||||
public LandfallWatcher copy() {
|
||||
return new LandfallWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,26 +132,26 @@ class SearingBlazeEffect extends OneShotEffect<SearingBlazeEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "LandPlayed");
|
||||
Player player = game.getPlayer(source.getTargets().get(0).getFirstTarget());
|
||||
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
if (player != null) {
|
||||
player.damage(3, source.getSourceId(), game, false, true);
|
||||
}
|
||||
if (creature != null) {
|
||||
creature.damage(3, source.getSourceId(), game, true, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (player != null) {
|
||||
player.damage(1, source.getSourceId(), game, false, true);
|
||||
}
|
||||
if (creature != null) {
|
||||
creature.damage(1, source.getSourceId(), game, true, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
Watcher watcher = game.getState().getWatchers().get("LandPlayed", source.getControllerId());
|
||||
Player player = game.getPlayer(source.getTargets().get(0).getFirstTarget());
|
||||
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
if (player != null) {
|
||||
player.damage(3, source.getSourceId(), game, false, true);
|
||||
}
|
||||
if (creature != null) {
|
||||
creature.damage(3, source.getSourceId(), game, true, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (player != null) {
|
||||
player.damage(1, source.getSourceId(), game, false, true);
|
||||
}
|
||||
if (creature != null) {
|
||||
creature.damage(1, source.getSourceId(), game, true, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import mage.watchers.Watcher;
|
|||
import mage.watchers.WatcherImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.WatcherScope;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -73,7 +74,7 @@ public class ArchiveTrap extends CardImpl<ArchiveTrap> {
|
|||
class ArchiveTrapWatcher extends WatcherImpl<ArchiveTrapWatcher> {
|
||||
|
||||
public ArchiveTrapWatcher() {
|
||||
super("LibrarySearched");
|
||||
super("LibrarySearched", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public ArchiveTrapWatcher(final ArchiveTrapWatcher watcher) {
|
||||
|
@ -113,7 +114,7 @@ class ArchiveTrapAlternativeCost extends AlternativeCostImpl<ArchiveTrapAlternat
|
|||
|
||||
@Override
|
||||
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())
|
||||
return true;
|
||||
return false;
|
||||
|
|
|
@ -28,13 +28,15 @@
|
|||
package mage.sets.zendikar;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.ColoredManaSymbol;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.abilities.Ability;
|
||||
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.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -77,7 +79,7 @@ public class CobraTrap extends CardImpl<CobraTrap> {
|
|||
class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
||||
|
||||
public CobraTrapWatcher() {
|
||||
super("noncreature permanent destroyed");
|
||||
super("noncreature permanent destroyed", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public CobraTrapWatcher(final CobraTrapWatcher watcher) {
|
||||
|
@ -91,11 +93,7 @@ class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.END_TURN_STEP_POST) {
|
||||
condition = false;
|
||||
}
|
||||
if (condition == true) // no need to check - condition has already occured
|
||||
{
|
||||
if (condition == true) { // no need to check - condition has already occured
|
||||
return;
|
||||
}
|
||||
if (event.getType() == EventType.DESTROYED_PERMANENT
|
||||
|
@ -110,8 +108,8 @@ class CobraTrapWatcher extends WatcherImpl<CobraTrapWatcher> {
|
|||
class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeCost> {
|
||||
|
||||
public CobraTrapAlternativeCost() {
|
||||
super("you may pay {0} rather than pay Cobra Trap's mana cost");
|
||||
this.add(new GenericManaCost(0));
|
||||
super("you may pay {G} rather than pay Cobra Trap's mana cost");
|
||||
this.add(new ColoredManaCost(ColoredManaSymbol.G));
|
||||
}
|
||||
|
||||
public CobraTrapAlternativeCost(final CobraTrapAlternativeCost cost) {
|
||||
|
@ -125,7 +123,7 @@ class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeC
|
|||
|
||||
@Override
|
||||
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()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -134,6 +132,6 @@ class CobraTrapAlternativeCost extends AlternativeCostImpl<CobraTrapAlternativeC
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.AlternativeCostImpl;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.game.Game;
|
||||
|
@ -78,16 +83,17 @@ public class MindbreakTrap extends CardImpl<MindbreakTrap> {
|
|||
|
||||
class MindbreakTrapWatcher extends WatcherImpl<MindbreakTrapWatcher> {
|
||||
|
||||
protected int spellCast;
|
||||
private Map<UUID, Integer> counts = new HashMap<UUID, Integer>();
|
||||
|
||||
public MindbreakTrapWatcher() {
|
||||
super("opponent cast three or more spells");
|
||||
spellCast = 0;
|
||||
super("opponent cast three or more spells", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public MindbreakTrapWatcher(final MindbreakTrapWatcher watcher) {
|
||||
super(watcher);
|
||||
this.spellCast = watcher.spellCast;
|
||||
for (Entry<UUID, Integer> entry: watcher.counts.entrySet()) {
|
||||
counts.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,24 +103,27 @@ class MindbreakTrapWatcher extends WatcherImpl<MindbreakTrapWatcher> {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.END_TURN_STEP_POST) {
|
||||
condition = false;
|
||||
spellCast = 0;
|
||||
if (condition == true) { // no need to check - condition has already occured
|
||||
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
|
||||
&& game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
||||
spellCast++;
|
||||
if (spellCast >= 3) {
|
||||
condition = true;
|
||||
int count = 1;
|
||||
if (counts.containsKey(event.getPlayerId())) {
|
||||
count += counts.get(event.getPlayerId());
|
||||
if (count >= 3)
|
||||
condition = true;
|
||||
}
|
||||
counts.put(event.getPlayerId(), count);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
counts.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlternativeCost> {
|
||||
|
@ -135,7 +144,7 @@ class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlte
|
|||
|
||||
@Override
|
||||
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()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -144,9 +153,10 @@ class MindbreakTrapAlternativeCost extends AlternativeCostImpl<MindbreakTrapAlte
|
|||
|
||||
@Override
|
||||
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>{
|
||||
|
||||
MindbreakEffect(MindbreakEffect effect) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import mage.Constants;
|
|||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.AlternativeCostImpl;
|
||||
|
@ -93,7 +94,7 @@ public class SummoningTrap extends CardImpl<SummoningTrap> {
|
|||
class SummoningTrapWatcher extends WatcherImpl<SummoningTrapWatcher> {
|
||||
|
||||
public SummoningTrapWatcher() {
|
||||
super("CreatureSpellCountered");
|
||||
super("CreatureSpellCountered", WatcherScope.PLAYER);
|
||||
}
|
||||
|
||||
public SummoningTrapWatcher(final SummoningTrapWatcher watcher) {
|
||||
|
@ -107,11 +108,7 @@ class SummoningTrapWatcher extends WatcherImpl<SummoningTrapWatcher> {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.END_TURN_STEP_POST) {
|
||||
condition = false;
|
||||
}
|
||||
if (condition == true) // no need to check - condition has already occured
|
||||
{
|
||||
if (condition == true) {// no need to check - condition has already occured
|
||||
return;
|
||||
}
|
||||
if (event.getType() == EventType.COUNTERED
|
||||
|
@ -140,7 +137,7 @@ class SummoningTrapAlternativeCost extends AlternativeCostImpl<SummoningTrapAlte
|
|||
|
||||
@Override
|
||||
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()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -420,6 +420,12 @@ public final class Constants {
|
|||
EQUIPMENT,
|
||||
AURA
|
||||
}
|
||||
|
||||
public enum WatcherScope {
|
||||
GAME,
|
||||
PLAYER,
|
||||
CARD
|
||||
}
|
||||
|
||||
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");}};
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MorbidCondition implements Condition {
|
|||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class NoSpellsWereCastLastTurnCondition implements Condition {
|
|||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TwoOrMoreSpellsWereCastLastTurnCondition implements Condition {
|
|||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.BloodthirstWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,11 +55,14 @@ class BloodthirstEffect extends OneShotEffect<BloodthirstEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents");
|
||||
if (watcher.conditionMet()) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
p.addCounters(CounterType.P1P1.createInstance(amount), game);
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId());
|
||||
if (watcher.conditionMet()) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
p.addCounters(CounterType.P1P1.createInstance(amount), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -54,7 +54,7 @@ public interface Card extends MageObject {
|
|||
public void addWatcher(Watcher watcher);
|
||||
public SpellAbility getSpellAbility();
|
||||
public List<String> getRules();
|
||||
public Watchers getWatchers();
|
||||
public List<Watcher> getWatchers();
|
||||
public String getExpansionSetCode();
|
||||
public void setExpansionSetCode(String expansionSetCode);
|
||||
public void setFaceDown(boolean value);
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObjectImpl;
|
||||
|
@ -50,7 +51,7 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.Watchers;
|
||||
import mage.watchers.WatcherImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
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 int cardNumber;
|
||||
protected Watchers watchers = new Watchers();
|
||||
protected List<Watcher> watchers = new ArrayList<Watcher>();
|
||||
protected String expansionSetCode;
|
||||
protected Rarity rarity;
|
||||
protected boolean faceDown;
|
||||
|
@ -97,7 +98,9 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
cardNumber = card.cardNumber;
|
||||
expansionSetCode = card.expansionSetCode;
|
||||
rarity = card.rarity;
|
||||
watchers = card.watchers.copy();
|
||||
for (Watcher watcher: (List<Watcher>)card.watchers) {
|
||||
this.watchers.add(watcher.copy());
|
||||
}
|
||||
faceDown = card.faceDown;
|
||||
|
||||
canTransform = card.canTransform;
|
||||
|
@ -112,7 +115,6 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
this.objectId = UUID.randomUUID();
|
||||
this.abilities.newOriginalId();
|
||||
this.abilities.setSourceId(objectId);
|
||||
this.watchers.setSourceId(objectId);
|
||||
}
|
||||
|
||||
public static Card createCard(String name) {
|
||||
|
@ -190,10 +192,10 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Watchers getWatchers() {
|
||||
public List<Watcher> getWatchers() {
|
||||
return watchers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void checkTriggers(Zone zone, GameEvent event, Game game) {
|
||||
for (TriggeredAbility ability : abilities.getTriggeredAbilities(zone)) {
|
||||
|
|
|
@ -60,6 +60,7 @@ import mage.watchers.Watcher;
|
|||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import mage.abilities.common.ChancellorAbility;
|
||||
|
||||
import mage.abilities.mana.TriggeredManaAbility;
|
||||
|
@ -159,7 +160,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
gameCards.put(card.getId(), card);
|
||||
state.setZone(card.getId(), Zone.OUTSIDE);
|
||||
for (Watcher watcher: card.getWatchers()) {
|
||||
watcher.setControllerId(ownerId);
|
||||
watcher.setControllerId(ownerId);
|
||||
watcher.setSourceId(card.getId());
|
||||
state.getWatchers().add(watcher);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,4 +78,8 @@ public class ZoneChangeEvent extends GameEvent {
|
|||
public Permanent getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public boolean isDiesEvent() {
|
||||
return (toZone == Zone.GRAVEYARD && fromZone == Zone.BATTLEFIELD);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -323,8 +323,8 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
return card.getRules();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Watchers getWatchers() {
|
||||
@Override
|
||||
public List<Watcher> getWatchers() {
|
||||
return card.getWatchers();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ import mage.game.stack.StackAbility;
|
|||
import mage.players.net.UserData;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetDiscard;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.BloodthirstWatcher;
|
||||
|
||||
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.canGainLife = true;
|
||||
this.canLoseLife = true;
|
||||
Watcher bloodthirst = new BloodthirstWatcher();
|
||||
bloodthirst.setControllerId(playerId);
|
||||
game.getState().getWatchers().add(bloodthirst);
|
||||
game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.watchers;
|
||||
|
||||
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 String key;
|
||||
protected boolean condition;
|
||||
protected WatcherScope scope;
|
||||
|
||||
public WatcherImpl(String key) {
|
||||
public WatcherImpl(String key, WatcherScope scope) {
|
||||
this.key = key;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
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.controllerId = watcher.controllerId;
|
||||
this.sourceId = watcher.sourceId;
|
||||
this.scope = watcher.scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +80,14 @@ public abstract class WatcherImpl<T extends WatcherImpl<T>> implements Watcher<T
|
|||
|
||||
@Override
|
||||
public String getKey() {
|
||||
switch (scope) {
|
||||
case GAME:
|
||||
return key;
|
||||
case PLAYER:
|
||||
return controllerId + key;
|
||||
case CARD:
|
||||
return sourceId + key;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
|
||||
package mage.watchers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -37,46 +38,59 @@ import mage.game.events.GameEvent;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Watchers extends ArrayList<Watcher> {
|
||||
|
||||
public Watchers copy() {
|
||||
Watchers newCopy = new Watchers();
|
||||
for (Watcher watcher: this) {
|
||||
newCopy.add(watcher.copy());
|
||||
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());
|
||||
}
|
||||
return newCopy;
|
||||
}
|
||||
|
||||
public Watchers copy() {
|
||||
return new Watchers(this);
|
||||
}
|
||||
|
||||
|
||||
public void add(Watcher watcher) {
|
||||
if (!this.containsKey(watcher.getKey()))
|
||||
this.put(watcher.getKey(), watcher);
|
||||
}
|
||||
|
||||
public void watch(GameEvent event, Game game) {
|
||||
for (Watcher watcher: this) {
|
||||
for (Watcher watcher: this.values()) {
|
||||
watcher.watch(event, game);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
for (Watcher watcher: this) {
|
||||
for (Watcher watcher: this.values()) {
|
||||
watcher.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSourceId(UUID sourceId) {
|
||||
for (Watcher watcher: this) {
|
||||
watcher.setSourceId(sourceId);
|
||||
}
|
||||
// public void setSourceId(UUID sourceId) {
|
||||
// for (Watcher watcher: this.values()) {
|
||||
// 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) {
|
||||
for (Watcher watcher: this) {
|
||||
watcher.setControllerId(controllerId);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
// public Watcher get(UUID controllerId, UUID sourceId, String key) {
|
||||
// for (Watcher watcher: this) {
|
||||
// if ((watcher.getControllerId() == null || watcher.getControllerId().equals(controllerId)) && watcher.getKey().equals(key) && watcher.getSourceId().equals(sourceId))
|
||||
// return watcher;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -10,8 +12,9 @@ import mage.watchers.WatcherImpl;
|
|||
* @author Loki
|
||||
*/
|
||||
public class BloodthirstWatcher extends WatcherImpl<BloodthirstWatcher> {
|
||||
public BloodthirstWatcher() {
|
||||
super("DamagedOpponents");
|
||||
public BloodthirstWatcher(UUID controllerId) {
|
||||
super("DamagedOpponents", WatcherScope.PLAYER);
|
||||
this.controllerId = controllerId;
|
||||
}
|
||||
|
||||
public BloodthirstWatcher(final BloodthirstWatcher watcher) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
@ -8,7 +9,7 @@ import mage.watchers.WatcherImpl;
|
|||
|
||||
public class CastFromHandWatcher extends WatcherImpl<CastFromHandWatcher> {
|
||||
public CastFromHandWatcher() {
|
||||
super("CastFromHand");
|
||||
super("CastFromHand", WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public CastFromHandWatcher(final CastFromHandWatcher watcher) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.watchers.common;
|
||||
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
@ -42,7 +43,7 @@ public class CastSpellLastTurnWatcher extends WatcherImpl<CastSpellLastTurnWatch
|
|||
private int amountOfSpellsCastOnCurrentTurn;
|
||||
|
||||
public CastSpellLastTurnWatcher() {
|
||||
super("CastSpellLastTurnWatcher");
|
||||
super("CastSpellLastTurnWatcher", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
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.CardType;
|
||||
import mage.Constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
@ -43,7 +44,7 @@ import mage.watchers.WatcherImpl;
|
|||
public class MorbidWatcher extends WatcherImpl<MorbidWatcher> {
|
||||
|
||||
public MorbidWatcher() {
|
||||
super("Morbid");
|
||||
super("Morbid", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public MorbidWatcher(final MorbidWatcher watcher) {
|
||||
|
|
Loading…
Reference in a new issue