From 9970f998add7c26faa690bc0f2a110eb7fe86938 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Mon, 23 Jul 2012 00:33:34 +0400 Subject: [PATCH] [USG] Worship [9ED] Volcanic Hammer --- .../sets/eighthedition/VolcanicHammer.java | 53 ++++++++ .../src/mage/sets/eighthedition/Worship.java | 53 ++++++++ .../sets/ninthedition/VolcanicHammer.java | 64 ++++++++++ .../src/mage/sets/ninthedition/Worship.java | 53 ++++++++ .../src/mage/sets/urzassaga/Worship.java | 120 ++++++++++++++++++ .../DamageSetToXLifeInsteadTest.java | 47 +++++++ 6 files changed, 390 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/eighthedition/VolcanicHammer.java create mode 100644 Mage.Sets/src/mage/sets/eighthedition/Worship.java create mode 100644 Mage.Sets/src/mage/sets/ninthedition/VolcanicHammer.java create mode 100644 Mage.Sets/src/mage/sets/ninthedition/Worship.java create mode 100644 Mage.Sets/src/mage/sets/urzassaga/Worship.java diff --git a/Mage.Sets/src/mage/sets/eighthedition/VolcanicHammer.java b/Mage.Sets/src/mage/sets/eighthedition/VolcanicHammer.java new file mode 100644 index 00000000000..f8061d603e9 --- /dev/null +++ b/Mage.Sets/src/mage/sets/eighthedition/VolcanicHammer.java @@ -0,0 +1,53 @@ +/* + * 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; + +/** + * + * @author magenoxx_at_gmail.com + + */ +public class VolcanicHammer extends mage.sets.ninthedition.VolcanicHammer { + + public VolcanicHammer(UUID ownerId) { + super(ownerId); + this.cardNumber = 231; + this.expansionSetCode = "8ED"; + } + + public VolcanicHammer(final VolcanicHammer card) { + super(card); + } + + @Override + public VolcanicHammer copy() { + return new VolcanicHammer(this); + } +} diff --git a/Mage.Sets/src/mage/sets/eighthedition/Worship.java b/Mage.Sets/src/mage/sets/eighthedition/Worship.java new file mode 100644 index 00000000000..b048a03ca3a --- /dev/null +++ b/Mage.Sets/src/mage/sets/eighthedition/Worship.java @@ -0,0 +1,53 @@ +/* + * 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; + +/** + * + * @author magenoxx_at_gmail.com + + */ +public class Worship extends mage.sets.urzassaga.Worship { + + public Worship(UUID ownerId) { + super(ownerId); + this.cardNumber = 57; + this.expansionSetCode = "8ED"; + } + + public Worship(final Worship card) { + super(card); + } + + @Override + public Worship copy() { + return new Worship(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ninthedition/VolcanicHammer.java b/Mage.Sets/src/mage/sets/ninthedition/VolcanicHammer.java new file mode 100644 index 00000000000..d32bd949222 --- /dev/null +++ b/Mage.Sets/src/mage/sets/ninthedition/VolcanicHammer.java @@ -0,0 +1,64 @@ +/* + * 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.ninthedition; + +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.target.common.TargetCreatureOrPlayer; + +import java.util.UUID; + +/** + * + * @author magenoxx_at_gmail.com + + */ +public class VolcanicHammer extends CardImpl { + + public VolcanicHammer(UUID ownerId) { + super(ownerId, 226, "Volcanic Hammer", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{R}"); + this.expansionSetCode = "9ED"; + + this.color.setRed(true); + + // Volcanic Hammer deals 3 damage to target creature or player. + this.getSpellAbility().addEffect(new DamageTargetEffect(3)); + this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); + } + + public VolcanicHammer(final VolcanicHammer card) { + super(card); + } + + @Override + public VolcanicHammer copy() { + return new VolcanicHammer(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ninthedition/Worship.java b/Mage.Sets/src/mage/sets/ninthedition/Worship.java new file mode 100644 index 00000000000..7ec96a2a0d3 --- /dev/null +++ b/Mage.Sets/src/mage/sets/ninthedition/Worship.java @@ -0,0 +1,53 @@ +/* + * 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.ninthedition; + +import java.util.UUID; + +/** + * + * @author magenoxx_at_gmail.com + + */ +public class Worship extends mage.sets.urzassaga.Worship { + + public Worship(UUID ownerId) { + super(ownerId); + this.cardNumber = 55; + this.expansionSetCode = "9ED"; + } + + public Worship(final Worship card) { + super(card); + } + + @Override + public Worship copy() { + return new Worship(this); + } +} diff --git a/Mage.Sets/src/mage/sets/urzassaga/Worship.java b/Mage.Sets/src/mage/sets/urzassaga/Worship.java new file mode 100644 index 00000000000..614f15d2dec --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/Worship.java @@ -0,0 +1,120 @@ +/* + * 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 mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.CardImpl; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; + +import java.util.UUID; + +/** + * + * @author magenoxx_at_gmail.com + + */ +public class Worship extends CardImpl { + + public Worship(UUID ownerId) { + super(ownerId, 57, "Worship", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}"); + this.expansionSetCode = "USG"; + + this.color.setWhite(true); + + // If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead. + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new WorshipReplacementEffect())); + } + + public Worship(final Worship card) { + super(card); + } + + @Override + public Worship copy() { + return new Worship(this); + } +} + +class WorshipReplacementEffect extends ReplacementEffectImpl { + + public WorshipReplacementEffect() { + super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Benefit); + staticText = "If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead"; + } + + public WorshipReplacementEffect(final WorshipReplacementEffect effect) { + super(effect); + } + + @Override + public WorshipReplacementEffect copy() { + return new WorshipReplacementEffect(this); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType().equals(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS)) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null) { + permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Constants.Zone.BATTLEFIELD); + } + if (permanent != null) { + Player controller = game.getPlayer(permanent.getControllerId()); + if (controller != null + && (controller.getLife() - event.getAmount()) < 1 + && event.getPlayerId().equals(controller.getId()) + && game.getBattlefield().count(new FilterControlledCreaturePermanent(), event.getPlayerId(), game) > 0 + ) { + event.setAmount(controller.getLife() - 1); + } + } + } + + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return false; + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/lifereduce/DamageSetToXLifeInsteadTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/lifereduce/DamageSetToXLifeInsteadTest.java index 07bc91c4b26..234a98138de 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/lifereduce/DamageSetToXLifeInsteadTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/lifereduce/DamageSetToXLifeInsteadTest.java @@ -58,4 +58,51 @@ public class DamageSetToXLifeInsteadTest extends CardTestPlayerBase { assertLife(playerB, 0); } + /** + * Tests Worhsip: + * If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead + */ + @Test + public void testWorshipWithCreature() { + addCard(Constants.Zone.HAND, playerA, "Volcanic Hammer"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 2); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Worship"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Elite Vanguard"); + + setLife(playerB, 2); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Hammer", playerB); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerB, 1); + } + + /** + * Tests Worhsip when there is no creature: + * If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead + */ + @Test + public void testWorshipWithoutCreature() { + addCard(Constants.Zone.HAND, playerA, "Volcanic Hammer", 2); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Llanowar Elves"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Worship"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Elite Vanguard"); + + setLife(playerB, 2); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Hammer", "Elite Vanguard"); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Hammer", playerB); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerB, -1); + } + } +