diff --git a/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java b/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java new file mode 100644 index 00000000000..93e2bfcbb26 --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java @@ -0,0 +1,111 @@ +/* + * 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.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * + * @author noxx + */ +public class HavengulSkaab extends CardImpl { + + public HavengulSkaab(UUID ownerId) { + super(ownerId, 60, "Havengul Skaab", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{5}{U}"); + this.expansionSetCode = "AVR"; + this.subtype.add("Zombie"); + this.subtype.add("Horror"); + + this.color.setBlue(true); + this.power = new MageInt(4); + this.toughness = new MageInt(5); + + // Whenever Havengul Skaab attacks, return another creature you control to its owner's hand. + this.addAbility(new HavengulSkaabAbility()); + } + + public HavengulSkaab(final HavengulSkaab card) { + super(card); + } + + @Override + public HavengulSkaab copy() { + return new HavengulSkaab(this); + } +} + +class HavengulSkaabAbility extends TriggeredAbilityImpl { + + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature you control"); + + static { + filter.setAnother(true); + } + + public HavengulSkaabAbility() { + super(Constants.Zone.BATTLEFIELD, new DestroyTargetEffect()); + this.addEffect(new ReturnToHandTargetEffect()); + } + + public HavengulSkaabAbility(final HavengulSkaabAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { + TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, filter, false, true); + this.addTarget(target); + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever {this} attacks, return another creature you control to its owner's hand."; + } + + @Override + public HavengulSkaabAbility copy() { + return new HavengulSkaabAbility(this); + } +} diff --git a/Mage.Sets/src/mage/sets/avacynrestored/MassAppeal.java b/Mage.Sets/src/mage/sets/avacynrestored/MassAppeal.java new file mode 100644 index 00000000000..19f18344c1c --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/MassAppeal.java @@ -0,0 +1,69 @@ +/* + * 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.CardType; +import mage.Constants.Rarity; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterControlledPermanent; + +import java.util.UUID; + +/** + * + * @author noxx + */ +public class MassAppeal extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("Human you control"); + + static { + filter.getSubtype().add("Human"); + } + + public MassAppeal(UUID ownerId) { + super(ownerId, 66, "Mass Appeal", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{U}"); + this.expansionSetCode = "AVR"; + + this.color.setBlue(true); + + // Draw a card for each Human you control. + this.getSpellAbility().addEffect(new DrawCardControllerEffect(new PermanentsOnBattlefieldCount(filter))); + } + + public MassAppeal(final MassAppeal card) { + super(card); + } + + @Override + public MassAppeal copy() { + return new MassAppeal(this); + } +} diff --git a/Mage.Sets/src/mage/sets/avacynrestored/RotcrownGhoul.java b/Mage.Sets/src/mage/sets/avacynrestored/RotcrownGhoul.java new file mode 100644 index 00000000000..7c83f343b7d --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/RotcrownGhoul.java @@ -0,0 +1,111 @@ +/* + * 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.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPlayer; + +import java.util.UUID; + +/** + * + * @author noxx + + */ +public class RotcrownGhoul extends CardImpl { + + public RotcrownGhoul(UUID ownerId) { + super(ownerId, 72, "Rotcrown Ghoul", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}"); + this.expansionSetCode = "AVR"; + this.subtype.add("Zombie"); + + this.color.setBlue(true); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // When Rotcrown Ghoul dies, target player puts the top five cards of his or her library into his or her graveyard. + this.addAbility(new SelhoffOccultistTriggeredAbility()); + } + + public RotcrownGhoul(final RotcrownGhoul card) { + super(card); + } + + @Override + public RotcrownGhoul copy() { + return new RotcrownGhoul(this); + } +} + +class SelhoffOccultistTriggeredAbility extends TriggeredAbilityImpl { + + public SelhoffOccultistTriggeredAbility() { + super(Constants.Zone.BATTLEFIELD, new PutLibraryIntoGraveTargetEffect(5), false); + this.addTarget(new TargetPlayer()); + } + + public SelhoffOccultistTriggeredAbility(final SelhoffOccultistTriggeredAbility ability) { + super(ability); + } + + @Override + public SelhoffOccultistTriggeredAbility copy() { + return new SelhoffOccultistTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) { + Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD); + if (permanent != null) { + if (permanent.getId().equals(this.getSourceId())) { + return true; + } + } + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever {this} dies, target player puts the top five cards of his or her library into his or her graveyard."; + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/filters/MassAppealTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/filters/MassAppealTest.java new file mode 100644 index 00000000000..6c6e672818a --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/filters/MassAppealTest.java @@ -0,0 +1,48 @@ +package org.mage.test.cards.filters; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author noxx + */ +public class MassAppealTest extends CardTestPlayerBase { + + @Test + public void testNoDraw() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 3); + addCard(Constants.Zone.HAND, playerA, "Mass Appeal"); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Mass Appeal"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertHandCount(playerA, 0); + assertHandCount(playerB, 0); + } + + @Test + public void testNoDrawCards() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 3); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Ana Disciple", 2); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Alabaster Mage", 3); + addCard(Constants.Zone.HAND, playerA, "Mass Appeal"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Ana Disciple", 6); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Mass Appeal"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertHandCount(playerA, 5); + assertHandCount(playerB, 0); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/RotcrownGhoulTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/RotcrownGhoulTest.java new file mode 100644 index 00000000000..0b3ac8d01d3 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/RotcrownGhoulTest.java @@ -0,0 +1,55 @@ +package org.mage.test.cards.triggers.dies; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author noxx + * + * When Rotcrown Ghoul dies, target player puts the top five cards of his or her library into his or her graveyard. + */ +public class RotcrownGhoulTest extends CardTestPlayerBase { + + @Test + public void testDiesTriggeredAbility() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Rotcrown Ghoul", 1); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Rotcrown Ghoul"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + // Lightning Bolt + 5 cards + assertGraveyardCount(playerA, 6); + // Rotcrown Ghoul + assertGraveyardCount(playerB, 1); + } + + @Test + public void testDiesTriggeredAbilityForTwoCopies() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Rotcrown Ghoul", 2); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Rotcrown Ghoul"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + // Lightning Bolt + 5 cards + assertGraveyardCount(playerA, 6); + // Rotcrown Ghoul + assertGraveyardCount(playerB, 1); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/SelhoffOccultistTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/SelhoffOccultistTest.java new file mode 100644 index 00000000000..0ed6c9e1f08 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/dies/SelhoffOccultistTest.java @@ -0,0 +1,88 @@ +package org.mage.test.cards.triggers.dies; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author noxx + * + * Whenever Selhoff Occultist or another creature dies, target player puts the top card of his or her library into his or her graveyard. + */ +public class SelhoffOccultistTest extends CardTestPlayerBase { + + /** + * Tests Selhoff Occultist's ability triggered + */ + @Test + public void testDiesTriggeredAbility() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Selhoff Occultist", 1); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Selhoff Occultist"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + // Lightning Bolt + 1 card + assertGraveyardCount(playerA, 2); + // Selhoff Occultist + assertGraveyardCount(playerB, 1); + } + + /** + * Tests that both Selhoff Occultist would trigger + */ + @Test + public void testDiesTriggeredAbilityForTwoCopies() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Selhoff Occultist", 2); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Ana Disciple", 1); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Ana Disciple"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + // Lightning Bolt + 2 cards + assertGraveyardCount(playerA, 3); + // Ana Disciple + assertGraveyardCount(playerB, 1); + } + + /** + * Tests that Selhoff Occultist cards in other than battlefield zones don't cause any effect + */ + @Test + public void testDiesTriggeredAbilityInOtherZone() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Constants.Zone.HAND, playerA, "Lightning Bolt"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Selhoff Occultist", 2); + addCard(Constants.Zone.HAND, playerB, "Selhoff Occultist", 1); + addCard(Constants.Zone.GRAVEYARD, playerB, "Selhoff Occultist", 1); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Ana Disciple", 1); + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Ana Disciple"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + // Lightning Bolt + 2 cards + assertGraveyardCount(playerA, 3); + // Selhoff Occultist + Ana Disciple + assertGraveyardCount(playerB, 2); + } + +}