From 33449ded83263dd6d39ae90b9b2de8df272389aa Mon Sep 17 00:00:00 2001 From: Backfir3 <backfir3_rage@yahoo.com> Date: Fri, 11 Jan 2013 00:23:26 +0100 Subject: [PATCH] Added [USG] Runes of Protection, Expunge and Urza's Armor --- .../mage/sets/eighthedition/UrzasArmor.java | 54 +++++++ .../src/mage/sets/urzassaga/Expunge.java | 78 ++++++++++ .../sets/urzassaga/RuneOfProtectionBlack.java | 140 ++++++++++++++++++ .../sets/urzassaga/RuneOfProtectionBlue.java | 140 ++++++++++++++++++ .../sets/urzassaga/RuneOfProtectionGreen.java | 140 ++++++++++++++++++ .../sets/urzassaga/RuneOfProtectionRed.java | 140 ++++++++++++++++++ .../sets/urzassaga/RuneOfProtectionWhite.java | 140 ++++++++++++++++++ .../src/mage/sets/urzassaga/UrzasArmor.java | 108 ++++++++++++++ 8 files changed, 940 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/eighthedition/UrzasArmor.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/Expunge.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlack.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlue.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionGreen.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionRed.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionWhite.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/UrzasArmor.java diff --git a/Mage.Sets/src/mage/sets/eighthedition/UrzasArmor.java b/Mage.Sets/src/mage/sets/eighthedition/UrzasArmor.java new file mode 100644 index 0000000000..a7fe6ddf09 --- /dev/null +++ b/Mage.Sets/src/mage/sets/eighthedition/UrzasArmor.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 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.sets.eighthedition; + +import java.util.UUID; +import mage.Constants.Rarity; + +/** + * + * @author Backfir3 + */ +public class UrzasArmor extends mage.sets.urzassaga.UrzasArmor { + + public UrzasArmor(UUID ownerId) { + super(ownerId); + this.cardNumber = 318; + this.expansionSetCode = "8ED"; + this.rarity = Rarity.RARE; + } + + public UrzasArmor(final UrzasArmor card) { + super(card); + } + + @Override + public UrzasArmor copy() { + return new UrzasArmor(this); + } +} diff --git a/Mage.Sets/src/mage/sets/urzassaga/Expunge.java b/Mage.Sets/src/mage/sets/urzassaga/Expunge.java new file mode 100644 index 0000000000..3460ecfc6b --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/Expunge.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.ObjectColor; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author Backfir3 + */ +public class Expunge extends CardImpl<Expunge> { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact, nonblack creature"); + + static { + filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT))); + filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK))); + } + + public Expunge(UUID ownerId) { + super(ownerId, 135, "Expunge", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{B}"); + this.expansionSetCode = "USG"; + this.color.setBlack(true); + + // Destroy target nonartifact, nonblack creature. It can't be regenerated. + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); + this.getSpellAbility().addEffect(new DestroyTargetEffect(true)); + // Cycling {2} ({2}, Discard this card: Draw a card.) + this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); + + } + + public Expunge(final Expunge card) { + super(card); + } + + @Override + public Expunge copy() { + return new Expunge(this); + } +} diff --git a/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlack.java b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlack.java new file mode 100644 index 0000000000..7922c954e4 --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlack.java @@ -0,0 +1,140 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +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.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.filter.FilterObject; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.TargetSource; + +/** + * + * @author Backfir3 + */ +public class RuneOfProtectionBlack extends CardImpl<RuneOfProtectionBlack> { + + public RuneOfProtectionBlack(UUID ownerId) { + super(ownerId, 36, "Rune of Protection: Black", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.expansionSetCode = "USG"; + this.color.setWhite(true); + + // {W}: The next time a black source of your choice would deal damage to you this turn, prevent that damage. + this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RuneOfProtectionBlackEffect() , new ManaCostsImpl("W"))); + // Cycling {2} ({2}, Discard this card: Draw a card.) + this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); + } + + public RuneOfProtectionBlack(final RuneOfProtectionBlack card) { + super(card); + } + + @Override + public RuneOfProtectionBlack copy() { + return new RuneOfProtectionBlack(this); + } +} + +class RuneOfProtectionBlackEffect extends PreventionEffectImpl<RuneOfProtectionBlackEffect> { + + private static final FilterObject filter = new FilterObject("black source"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLACK)); + } + + private TargetSource target; + + public RuneOfProtectionBlackEffect() { + super(Constants.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 RuneOfProtectionBlackEffect(final RuneOfProtectionBlackEffect effect) { + super(effect); + this.target = effect.target.copy(); + } + + @Override + public RuneOfProtectionBlackEffect copy() { + return new RuneOfProtectionBlackEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public void init(Ability source, Game game) { + this.target.choose(Constants.Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { + preventDamage(event, source, target.getFirstTarget(), game); + return true; + } + return false; + } + + private void preventDamage(GameEvent event, Ability source, UUID target, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + this.used = true; + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, target, source.getId(), source.getControllerId(), damage)); + } + } + + @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/urzassaga/RuneOfProtectionBlue.java b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlue.java new file mode 100644 index 0000000000..5342c160f8 --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionBlue.java @@ -0,0 +1,140 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +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.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.filter.FilterObject; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.TargetSource; + +/** + * + * @author Backfir3 + */ +public class RuneOfProtectionBlue extends CardImpl<RuneOfProtectionBlue> { + + public RuneOfProtectionBlue(UUID ownerId) { + super(ownerId, 37, "Rune of Protection: Blue", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.expansionSetCode = "USG"; + this.color.setWhite(true); + + // {W}: The next time a blue source of your choice would deal damage to you this turn, prevent that damage. + this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RuneOfProtectionBlueEffect() , new ManaCostsImpl("W"))); + // Cycling {2} ({2}, Discard this card: Draw a card.) + this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); + } + + public RuneOfProtectionBlue(final RuneOfProtectionBlue card) { + super(card); + } + + @Override + public RuneOfProtectionBlue copy() { + return new RuneOfProtectionBlue(this); + } +} + +class RuneOfProtectionBlueEffect extends PreventionEffectImpl<RuneOfProtectionBlueEffect> { + + private static final FilterObject filter = new FilterObject("blue source"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLUE)); + } + + private TargetSource target; + + public RuneOfProtectionBlueEffect() { + super(Constants.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 RuneOfProtectionBlueEffect(final RuneOfProtectionBlueEffect effect) { + super(effect); + this.target = effect.target.copy(); + } + + @Override + public RuneOfProtectionBlueEffect copy() { + return new RuneOfProtectionBlueEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public void init(Ability source, Game game) { + this.target.choose(Constants.Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { + preventDamage(event, source, target.getFirstTarget(), game); + return true; + } + return false; + } + + private void preventDamage(GameEvent event, Ability source, UUID target, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + this.used = true; + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, target, source.getId(), source.getControllerId(), damage)); + } + } + + @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/urzassaga/RuneOfProtectionGreen.java b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionGreen.java new file mode 100644 index 0000000000..aea0908ee5 --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionGreen.java @@ -0,0 +1,140 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +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.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.filter.FilterObject; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.TargetSource; + +/** + * + * @author Backfir3 + */ +public class RuneOfProtectionGreen extends CardImpl<RuneOfProtectionGreen> { + + public RuneOfProtectionGreen(UUID ownerId) { + super(ownerId, 38, "Rune of Protection: Green", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.expansionSetCode = "USG"; + this.color.setWhite(true); + + // {W}: The next time a green source of your choice would deal damage to you this turn, prevent that damage. + this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RuneOfProtectionGreenEffect() , new ManaCostsImpl("W"))); + // Cycling {2} ({2}, Discard this card: Draw a card.) + this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); + } + + public RuneOfProtectionGreen(final RuneOfProtectionGreen card) { + super(card); + } + + @Override + public RuneOfProtectionGreen copy() { + return new RuneOfProtectionGreen(this); + } +} + +class RuneOfProtectionGreenEffect extends PreventionEffectImpl<RuneOfProtectionGreenEffect> { + + private static final FilterObject filter = new FilterObject("green source"); + + static { + filter.add(new ColorPredicate(ObjectColor.GREEN)); + } + + private TargetSource target; + + public RuneOfProtectionGreenEffect() { + super(Constants.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 RuneOfProtectionGreenEffect(final RuneOfProtectionGreenEffect effect) { + super(effect); + this.target = effect.target.copy(); + } + + @Override + public RuneOfProtectionGreenEffect copy() { + return new RuneOfProtectionGreenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public void init(Ability source, Game game) { + this.target.choose(Constants.Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { + preventDamage(event, source, target.getFirstTarget(), game); + return true; + } + return false; + } + + private void preventDamage(GameEvent event, Ability source, UUID target, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + this.used = true; + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, target, source.getId(), source.getControllerId(), damage)); + } + } + + @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/urzassaga/RuneOfProtectionRed.java b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionRed.java new file mode 100644 index 0000000000..cc3a146c2a --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionRed.java @@ -0,0 +1,140 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +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.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.filter.FilterObject; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.TargetSource; + +/** + * + * @author Backfir3 + */ +public class RuneOfProtectionRed extends CardImpl<RuneOfProtectionRed> { + + public RuneOfProtectionRed(UUID ownerId) { + super(ownerId, 40, "Rune of Protection: Red", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.expansionSetCode = "USG"; + this.color.setWhite(true); + + // {W}: The next time a red source of your choice would deal damage to you this turn, prevent that damage. + this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RuneOfProtectionRedEffect() , new ManaCostsImpl("W"))); + // Cycling {2} ({2}, Discard this card: Draw a card.) + this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); + } + + public RuneOfProtectionRed(final RuneOfProtectionRed card) { + super(card); + } + + @Override + public RuneOfProtectionRed copy() { + return new RuneOfProtectionRed(this); + } +} + +class RuneOfProtectionRedEffect extends PreventionEffectImpl<RuneOfProtectionRedEffect> { + + private static final FilterObject filter = new FilterObject("red source"); + + static { + filter.add(new ColorPredicate(ObjectColor.RED)); + } + + private TargetSource target; + + public RuneOfProtectionRedEffect() { + super(Constants.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 RuneOfProtectionRedEffect(final RuneOfProtectionRedEffect effect) { + super(effect); + this.target = effect.target.copy(); + } + + @Override + public RuneOfProtectionRedEffect copy() { + return new RuneOfProtectionRedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public void init(Ability source, Game game) { + this.target.choose(Constants.Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { + preventDamage(event, source, target.getFirstTarget(), game); + return true; + } + return false; + } + + private void preventDamage(GameEvent event, Ability source, UUID target, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + this.used = true; + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, target, source.getId(), source.getControllerId(), damage)); + } + } + + @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/urzassaga/RuneOfProtectionWhite.java b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionWhite.java new file mode 100644 index 0000000000..02f86aab2f --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/RuneOfProtectionWhite.java @@ -0,0 +1,140 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +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.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.filter.FilterObject; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.TargetSource; + +/** + * + * @author Backfir3 + */ +public class RuneOfProtectionWhite extends CardImpl<RuneOfProtectionWhite> { + + public RuneOfProtectionWhite(UUID ownerId) { + super(ownerId, 41, "Rune of Protection: White", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.expansionSetCode = "USG"; + this.color.setWhite(true); + + // {W}: The next time a white source of your choice would deal damage to you this turn, prevent that damage. + this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RuneOfProtectionWhiteEffect() , new ManaCostsImpl("W"))); + // Cycling {2} ({2}, Discard this card: Draw a card.) + this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); + } + + public RuneOfProtectionWhite(final RuneOfProtectionWhite card) { + super(card); + } + + @Override + public RuneOfProtectionWhite copy() { + return new RuneOfProtectionWhite(this); + } +} + +class RuneOfProtectionWhiteEffect extends PreventionEffectImpl<RuneOfProtectionWhiteEffect> { + + private static final FilterObject filter = new FilterObject("white source"); + + static { + filter.add(new ColorPredicate(ObjectColor.WHITE)); + } + + private TargetSource target; + + public RuneOfProtectionWhiteEffect() { + super(Constants.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 RuneOfProtectionWhiteEffect(final RuneOfProtectionWhiteEffect effect) { + super(effect); + this.target = effect.target.copy(); + } + + @Override + public RuneOfProtectionWhiteEffect copy() { + return new RuneOfProtectionWhiteEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public void init(Ability source, Game game) { + this.target.choose(Constants.Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { + preventDamage(event, source, target.getFirstTarget(), game); + return true; + } + return false; + } + + private void preventDamage(GameEvent event, Ability source, UUID target, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + this.used = true; + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, target, source.getId(), source.getControllerId(), damage)); + } + } + + @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/urzassaga/UrzasArmor.java b/Mage.Sets/src/mage/sets/urzassaga/UrzasArmor.java new file mode 100644 index 0000000000..5d6059b537 --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/UrzasArmor.java @@ -0,0 +1,108 @@ +/* + * Copyright 2010 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.sets.urzassaga; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.PreventionEffectImpl; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author Backfir3 + */ +public class UrzasArmor extends CardImpl<UrzasArmor> { + + public UrzasArmor(UUID ownerId) { + super(ownerId, 313, "Urza's Armor", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{6}"); + this.expansionSetCode = "USG"; + + // If a source would deal damage to you, prevent 1 of that damage. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new UrzasArmorEffect())); + } + + public UrzasArmor(final UrzasArmor card) { + super(card); + } + + @Override + public UrzasArmor copy() { + return new UrzasArmor(this); + } +} + +class UrzasArmorEffect extends PreventionEffectImpl<UrzasArmorEffect> { + + public UrzasArmorEffect() { + super(Duration.WhileOnBattlefield); + this.staticText = "If a source would deal damage to you, prevent 1 of that damage"; + } + + public UrzasArmorEffect(UrzasArmorEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), 1, false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + if (damage > 0) { + event.setAmount(damage - 1); + game.informPlayers("1 damage has been prevented."); + } + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), 1)); + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER) && event.getTargetId().equals(source.getControllerId())) { + return super.applies(event, source, game); + } + return false; + } + + @Override + public UrzasArmorEffect copy() { + return new UrzasArmorEffect(this); + } +}