From e98f0c184a72f656c9ed0d6621fa3b3c4c0a49ff Mon Sep 17 00:00:00 2001 From: Loki Date: Thu, 17 May 2012 00:21:22 +0300 Subject: [PATCH] [AVR] 2 cards, fix Cryptoplasm self-targeting, add test for it --- .../FalkenrathExterminator.java | 79 +++++++++++++++++++ .../sets/avacynrestored/ScrollOfAvacyn.java | 78 ++++++++++++++++++ .../sets/mirrodinbesieged/Cryptoplasm.java | 8 +- .../mage/test/cards/copy/CryptoplasmTest.java | 21 +++++ 4 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/sets/avacynrestored/FalkenrathExterminator.java create mode 100644 Mage.Sets/src/mage/sets/avacynrestored/ScrollOfAvacyn.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/copy/CryptoplasmTest.java diff --git a/Mage.Sets/src/mage/sets/avacynrestored/FalkenrathExterminator.java b/Mage.Sets/src/mage/sets/avacynrestored/FalkenrathExterminator.java new file mode 100644 index 00000000000..1f44b478ea9 --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/FalkenrathExterminator.java @@ -0,0 +1,79 @@ +/* + * 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 java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.CountersCount; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author Loki + */ +public class FalkenrathExterminator extends CardImpl { + + public FalkenrathExterminator(UUID ownerId) { + super(ownerId, 134, "Falkenrath Exterminator", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{R}"); + this.expansionSetCode = "AVR"; + this.subtype.add("Vampire"); + this.subtype.add("Archer"); + + this.color.setRed(true); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Whenever Falkenrath Exterminator deals combat damage to a player, put a +1/+1 counter on it. + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false)); + // {2}{R}: Falkenrath Exterminator deals damage to target creature equal to the number of +1/+1 counters on Falkenrath Exterminator. + Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new DamageTargetEffect(new CountersCount(CounterType.P1P1)), new ManaCostsImpl("{2}{R}")); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public FalkenrathExterminator(final FalkenrathExterminator card) { + super(card); + } + + @Override + public FalkenrathExterminator copy() { + return new FalkenrathExterminator(this); + } +} diff --git a/Mage.Sets/src/mage/sets/avacynrestored/ScrollOfAvacyn.java b/Mage.Sets/src/mage/sets/avacynrestored/ScrollOfAvacyn.java new file mode 100644 index 00000000000..adc5bd7052d --- /dev/null +++ b/Mage.Sets/src/mage/sets/avacynrestored/ScrollOfAvacyn.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.avacynrestored; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.condition.common.ControlsPermanentCondition; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.filter.Filter; +import mage.filter.FilterPermanent; + +/** + * + * @author Loki + */ +public class ScrollOfAvacyn extends CardImpl { + private static FilterPermanent filter = new FilterPermanent("an Angel"); + + static { + filter.getSubtype().add("Angel"); + filter.setScopeSubtype(Filter.ComparisonScope.Any); + } + + public ScrollOfAvacyn(UUID ownerId) { + super(ownerId, 220, "Scroll of Avacyn", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{1}"); + this.expansionSetCode = "AVR"; + + // {1}, Sacrifice Scroll of Avacyn: Draw a card. If you control an Angel, you gain 5 life. + Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new DrawCardControllerEffect(1), new GenericManaCost(1)); + ability.addCost(new SacrificeSourceCost()); + ability.addEffect(new ConditionalOneShotEffect(new GainLifeEffect(5), new ControlsPermanentCondition(filter), "If you control an Angel, you gain 5 life")); + this.addAbility(ability); + } + + public ScrollOfAvacyn(final ScrollOfAvacyn card) { + super(card); + } + + @Override + public ScrollOfAvacyn copy() { + return new ScrollOfAvacyn(this); + } +} diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java index 097440e5a70..6d315c7a694 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java @@ -39,6 +39,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.cards.Card; import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; @@ -48,6 +49,11 @@ import mage.util.CardUtil; * @author Loki */ public class Cryptoplasm extends CardImpl { + final static FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + static { + filter.setAnother(true); + } public Cryptoplasm(UUID ownerId) { super(ownerId, 23, "Cryptoplasm", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); @@ -57,7 +63,7 @@ public class Cryptoplasm extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); Ability ability = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmTransformEffect(), Constants.TargetController.YOU, true); - ability.addTarget(new TargetCreaturePermanent()); + ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/CryptoplasmTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/CryptoplasmTest.java new file mode 100644 index 00000000000..9dd2a57c332 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/CryptoplasmTest.java @@ -0,0 +1,21 @@ +package org.mage.test.cards.copy; + +import mage.Constants; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +public class CryptoplasmTest extends CardTestPlayerBase { + + @Test + public void testTransform() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Cryptoplasm", 1); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Craw Wurm", 1); + + setStopAt(2, Constants.PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertPermanentCount(playerA, "Craw Wurm", 2); + } +}