diff --git a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlack.java b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlack.java index 159c371c60..d07e829fe3 100644 --- a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlack.java +++ b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlack.java @@ -29,24 +29,30 @@ package mage.sets.iceage; import java.util.UUID; -import mage.constants.*; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToYouEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterObject; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.target.TargetSource; /** * * @author Plopman */ public class CircleOfProtectionBlack extends CardImpl { + + private static final FilterObject filter = new FilterObject("black source"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLACK)); + } public CircleOfProtectionBlack(UUID ownerId) { super(ownerId, 236, "Circle of Protection: Black", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); @@ -55,7 +61,8 @@ public class CircleOfProtectionBlack extends CardImpl { this.color.setWhite(true); // {1}: The next time a black source of your choice would deal damage to you this turn, prevent that damage. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CircleOfProtectionBlackEffect() , new ManaCostsImpl("1"))); + Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("1"))); } public CircleOfProtectionBlack(final CircleOfProtectionBlack card) { @@ -67,54 +74,3 @@ public class CircleOfProtectionBlack extends CardImpl { return new CircleOfProtectionBlack(this); } } - -class CircleOfProtectionBlackEffect extends PreventionEffectImpl { - - private static final FilterObject filter = new FilterObject("black source"); - - static{ - filter.add(new ColorPredicate(ObjectColor.BLACK)); - } - - private final TargetSource target; - - public CircleOfProtectionBlackEffect() { - super(Duration.EndOfTurn); - target = new TargetSource(filter); - - staticText = "The next time a black source of your choice would deal damage to you this turn, prevent that damage"; - } - - public CircleOfProtectionBlackEffect(final CircleOfProtectionBlackEffect effect) { - super(effect); - this.target = effect.target.copy(); - } - - @Override - public CircleOfProtectionBlackEffect copy() { - return new CircleOfProtectionBlackEffect(this); - } - - @Override - public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - preventDamageAction(event, source, game); - this.used = true; - return false; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (!this.used && super.applies(event, source, game)) { - if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { - return true; - } - } - return false; - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlue.java b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlue.java index 30045c5428..80edb517ba 100644 --- a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlue.java +++ b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionBlue.java @@ -29,18 +29,18 @@ package mage.sets.iceage; import java.util.UUID; -import mage.constants.*; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToYouEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterObject; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.target.TargetSource; /** * @@ -48,6 +48,12 @@ import mage.target.TargetSource; */ public class CircleOfProtectionBlue extends CardImpl { + private static final FilterObject filter = new FilterObject("blue source"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLUE)); + } + public CircleOfProtectionBlue(UUID ownerId) { super(ownerId, 237, "Circle of Protection: Blue", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); this.expansionSetCode = "ICE"; @@ -55,8 +61,8 @@ public class CircleOfProtectionBlue extends CardImpl { this.color.setWhite(true); // {1}: The next time a blue source of your choice would deal damage to you this turn, prevent that damage. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CircleOfProtectionBlueEffect() , new ManaCostsImpl("1"))); - + Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("1"))); } public CircleOfProtectionBlue(final CircleOfProtectionBlue card) { @@ -68,51 +74,3 @@ public class CircleOfProtectionBlue extends CardImpl { return new CircleOfProtectionBlue(this); } } -class CircleOfProtectionBlueEffect extends PreventionEffectImpl { - - private static final FilterObject filter = new FilterObject("blue source"); - static{ - filter.add(new ColorPredicate(ObjectColor.BLUE)); - } - private final TargetSource target; - - public CircleOfProtectionBlueEffect() { - super(Duration.EndOfTurn); - target = new TargetSource(filter); - - staticText = "The next time a blue source of your choice would deal damage to you this turn, prevent that damage"; - } - - public CircleOfProtectionBlueEffect(final CircleOfProtectionBlueEffect effect) { - super(effect); - this.target = effect.target.copy(); - } - - @Override - public CircleOfProtectionBlueEffect copy() { - return new CircleOfProtectionBlueEffect(this); - } - - @Override - public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - preventDamageAction(event, source, game); - this.used = true; - return false; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (!this.used && super.applies(event, source, game)) { - if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { - return true; - } - } - return false; - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionGreen.java b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionGreen.java index a0342331c1..39636c03ec 100644 --- a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionGreen.java +++ b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionGreen.java @@ -29,18 +29,18 @@ package mage.sets.iceage; import java.util.UUID; -import mage.constants.*; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToYouEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterObject; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.target.TargetSource; /** * @@ -48,6 +48,12 @@ import mage.target.TargetSource; */ public class CircleOfProtectionGreen extends CardImpl { + private static final FilterObject filter = new FilterObject("green source"); + + static { + filter.add(new ColorPredicate(ObjectColor.GREEN)); + } + public CircleOfProtectionGreen(UUID ownerId) { super(ownerId, 238, "Circle of Protection: Green", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); this.expansionSetCode = "ICE"; @@ -55,8 +61,8 @@ public class CircleOfProtectionGreen extends CardImpl { this.color.setWhite(true); // {1}: The next time a green source of your choice would deal damage to you this turn, prevent that damage. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CircleOfProtectionGreenEffect() , new ManaCostsImpl("1"))); - + Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("1"))); } public CircleOfProtectionGreen(final CircleOfProtectionGreen card) { @@ -68,52 +74,3 @@ public class CircleOfProtectionGreen extends CardImpl { return new CircleOfProtectionGreen(this); } } - -class CircleOfProtectionGreenEffect extends PreventionEffectImpl { - - private static final FilterObject filter = new FilterObject("green source"); - static{ - filter.add(new ColorPredicate(ObjectColor.GREEN)); - } - private final TargetSource target; - - public CircleOfProtectionGreenEffect() { - super(Duration.EndOfTurn); - target = new TargetSource(filter); - - staticText = "The next time a green source of your choice would deal damage to you this turn, prevent that damage"; - } - - public CircleOfProtectionGreenEffect(final CircleOfProtectionGreenEffect effect) { - super(effect); - this.target = effect.target.copy(); - } - - @Override - public CircleOfProtectionGreenEffect copy() { - return new CircleOfProtectionGreenEffect(this); - } - - @Override - public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - preventDamageAction(event, source, game); - this.used = true; - return false; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (!this.used && super.applies(event, source, game)) { - if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { - return true; - } - } - return false; - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionRed.java b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionRed.java index 001d3203b7..b617605881 100644 --- a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionRed.java +++ b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionRed.java @@ -29,18 +29,18 @@ package mage.sets.iceage; import java.util.UUID; -import mage.constants.*; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToYouEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterObject; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.target.TargetSource; /** * @@ -48,6 +48,12 @@ import mage.target.TargetSource; */ public class CircleOfProtectionRed extends CardImpl { + private static final FilterObject filter = new FilterObject("red source"); + + static { + filter.add(new ColorPredicate(ObjectColor.RED)); + } + public CircleOfProtectionRed(UUID ownerId) { super(ownerId, 239, "Circle of Protection: Red", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); this.expansionSetCode = "ICE"; @@ -55,8 +61,8 @@ public class CircleOfProtectionRed extends CardImpl { this.color.setWhite(true); // {1}: The next time a red source of your choice would deal damage to you this turn, prevent that damage. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CircleOfProtectionRedEffect() , new ManaCostsImpl("1"))); - + Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("1"))); } public CircleOfProtectionRed(final CircleOfProtectionRed card) { @@ -68,54 +74,3 @@ public class CircleOfProtectionRed extends CardImpl { return new CircleOfProtectionRed(this); } } - -class CircleOfProtectionRedEffect extends PreventionEffectImpl { - - private static final FilterObject filter = new FilterObject("red source"); - - static{ - filter.add(new ColorPredicate(ObjectColor.RED)); - } - - private final TargetSource target; - - public CircleOfProtectionRedEffect() { - super(Duration.EndOfTurn); - target = new TargetSource(filter); - - staticText = "The next time a red source of your choice would deal damage to you this turn, prevent that damage"; - } - - public CircleOfProtectionRedEffect(final CircleOfProtectionRedEffect effect) { - super(effect); - this.target = effect.target.copy(); - } - - @Override - public CircleOfProtectionRedEffect copy() { - return new CircleOfProtectionRedEffect(this); - } - - @Override - public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - preventDamageAction(event, source, game); - this.used = true; - return false; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (!this.used && super.applies(event, source, game)) { - if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { - return true; - } - } - return false; - } - -} diff --git a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionWhite.java b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionWhite.java index 344c329e2e..a5fac1ca3b 100644 --- a/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionWhite.java +++ b/Mage.Sets/src/mage/sets/iceage/CircleOfProtectionWhite.java @@ -29,18 +29,18 @@ package mage.sets.iceage; import java.util.UUID; -import mage.constants.*; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToYouEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterObject; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.target.TargetSource; /** * @@ -48,6 +48,12 @@ import mage.target.TargetSource; */ public class CircleOfProtectionWhite extends CardImpl { + private static final FilterObject filter = new FilterObject("white source"); + + static { + filter.add(new ColorPredicate(ObjectColor.WHITE)); + } + public CircleOfProtectionWhite(UUID ownerId) { super(ownerId, 240, "Circle of Protection: White", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); this.expansionSetCode = "ICE"; @@ -55,8 +61,8 @@ public class CircleOfProtectionWhite extends CardImpl { this.color.setWhite(true); // {1}: The next time a white source of your choice would deal damage to you this turn, prevent that damage. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CircleOfProtectionWhiteEffect() , new ManaCostsImpl("1"))); - + Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("1")));; } public CircleOfProtectionWhite(final CircleOfProtectionWhite card) { @@ -68,52 +74,3 @@ public class CircleOfProtectionWhite extends CardImpl { return new CircleOfProtectionWhite(this); } } - -class CircleOfProtectionWhiteEffect extends PreventionEffectImpl { - - private static final FilterObject filter = new FilterObject("white source"); - static{ - filter.add(new ColorPredicate(ObjectColor.WHITE)); - } - private final TargetSource target; - - public CircleOfProtectionWhiteEffect() { - super(Duration.EndOfTurn); - target = new TargetSource(filter); - - staticText = "The next time a white source of your choice would deal damage to you this turn, prevent that damage"; - } - - public CircleOfProtectionWhiteEffect(final CircleOfProtectionWhiteEffect effect) { - super(effect); - this.target = effect.target.copy(); - } - - @Override - public CircleOfProtectionWhiteEffect copy() { - return new CircleOfProtectionWhiteEffect(this); - } - - @Override - public void init(Ability source, Game game) { - this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - preventDamageAction(event, source, game); - this.used = true; - return false; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (!this.used && super.applies(event, source, game)) { - if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { - return true; - } - } - return false; - } - -}