From 6318dbc309bb605947f235900c21c7563cbe30b8 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sun, 20 May 2012 18:45:21 +0400 Subject: [PATCH] [AVR] Sigarda, Host of Herons + test --- .../avacynrestored/SigardaHostOfHerons.java | 125 ++++++++++++++++++ .../replacement/SigardaHostOfHeronsTest.java | 70 ++++++++++ 2 files changed, 195 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/avacynrestored/SigardaHostOfHerons.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/replacement/SigardaHostOfHeronsTest.java diff --git a/Mage.Sets/src/mage/sets/avacynrestored/SigardaHostOfHerons.java b/Mage.Sets/src/mage/sets/avacynrestored/SigardaHostOfHerons.java new file mode 100644 index 00000000000..9dc62fc0ab9 --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/SigardaHostOfHerons.java @@ -0,0 +1,125 @@ +/* + * 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.avacynrestored; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HexproofAbility; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.PermanentCard; +import mage.game.stack.Spell; + +import java.util.UUID; + +/** + * @author noxx + */ +public class SigardaHostOfHerons extends CardImpl { + + public SigardaHostOfHerons(UUID ownerId) { + super(ownerId, 210, "Sigarda, Host of Herons", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{2}{G}{W}{W}"); + this.expansionSetCode = "AVR"; + this.supertype.add("Legendary"); + this.subtype.add("Angel"); + + this.color.setGreen(true); + this.color.setWhite(true); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + this.addAbility(FlyingAbility.getInstance()); + this.addAbility(HexproofAbility.getInstance()); + + // Spells and abilities your opponents control can't cause you to sacrifice permanents. + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new SigardaHostOfHeronsEffect())); + } + + public SigardaHostOfHerons(final SigardaHostOfHerons card) { + super(card); + } + + @Override + public SigardaHostOfHerons copy() { + return new SigardaHostOfHerons(this); + } +} + +class SigardaHostOfHeronsEffect extends ReplacementEffectImpl { + + public SigardaHostOfHeronsEffect() { + super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Benefit); + staticText = "Spells and abilities your opponents control can't cause you to sacrifice permanents"; + } + + public SigardaHostOfHeronsEffect(final SigardaHostOfHeronsEffect effect) { + super(effect); + } + + @Override + public SigardaHostOfHeronsEffect copy() { + return new SigardaHostOfHeronsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT) { + MageObject object = game.getObject(event.getSourceId()); + if (object instanceof PermanentCard) { + if (game.getOpponents(source.getControllerId()).contains(((PermanentCard)object).getControllerId())) { + return true; + } + } + if (object instanceof Spell) { + if (game.getOpponents(source.getControllerId()).contains(((Spell)object).getControllerId())) { + return true; + } + } + } + return false; + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/SigardaHostOfHeronsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/SigardaHostOfHeronsTest.java new file mode 100644 index 00000000000..ee5037baa6c --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/SigardaHostOfHeronsTest.java @@ -0,0 +1,70 @@ +package org.mage.test.cards.replacement; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * Sigarda, Host of Herons: + * Spells and abilities your opponents control can't cause you to sacrifice permanents. + * + * @author noxx + */ +public class SigardaHostOfHeronsTest extends CardTestPlayerBase { + + /** + * Tests that spells don't work for opponents but still work for controller + */ + @Test + public void testCard() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Sigarda, Host of Herons"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Devout Chaplain"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Corpse Traders"); + addCard(Constants.Zone.HAND, playerA, "Diabolic Edict"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 2); + + addCard(Constants.Zone.HAND, playerB, "Diabolic Edict"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Swamp", 2); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Sheoldred, Whispering One"); + + castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Diabolic Edict", playerA); + castSpell(3, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Diabolic Edict", playerB); + + setStopAt(3, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Sigarda, Host of Herons", 1); + assertPermanentCount(playerA, "Devout Chaplain", 1); + assertPermanentCount(playerA, "Corpse Traders", 1); + assertGraveyardCount(playerA, 1); + + assertPermanentCount(playerB, "Sheoldred, Whispering One", 0); + assertGraveyardCount(playerB, 2); + } + + /** + * Tests that sacrifice cost works. + */ + @Test + public void testSacrificeCost() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Sigarda, Host of Herons"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Devout Chaplain"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Corpse Traders"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 3); + + activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{2}{B}"); + + setStopAt(1, Constants.PhaseStep.END_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Devout Chaplain", 0); + assertPermanentCount(playerA, "Corpse Traders", 1); + } + +}