mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
* Added some tests.
This commit is contained in:
parent
1ef99e775f
commit
d79776e589
4 changed files with 149 additions and 20 deletions
|
|
@ -28,11 +28,6 @@
|
|||
package mage.sets.magic2013;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.DiscardTargetCost;
|
||||
|
|
@ -45,10 +40,12 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
|||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterArtifactCard;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.common.FilterControlledArtifactPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.game.permanent.token.GoatToken;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
|
@ -60,14 +57,6 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*/
|
||||
public class TradingPost extends CardImpl {
|
||||
|
||||
final static FilterControlledPermanent filter = new FilterControlledPermanent("creature");
|
||||
final static FilterControlledPermanent filter2 = new FilterControlledPermanent("artifact");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.CREATURE));
|
||||
filter2.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
}
|
||||
|
||||
public TradingPost(UUID ownerId) {
|
||||
super(ownerId, 220, "Trading Post", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
this.expansionSetCode = "M13";
|
||||
|
|
@ -86,15 +75,15 @@ public class TradingPost extends CardImpl {
|
|||
|
||||
// {1}, {tap}, Sacrifice a creature: Return target artifact card from your graveyard to your hand.
|
||||
Ability ability3 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnFromGraveyardToHandTargetEffect(), new GenericManaCost(1));
|
||||
ability3.addTarget(new TargetCardInGraveyard(new FilterArtifactCard("artifact card in your graveyard")));
|
||||
ability3.addTarget(new TargetCardInGraveyard(new FilterArtifactCard("an artifact card in your graveyard")));
|
||||
ability3.addCost(new TapSourceCost());
|
||||
ability3.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter)));
|
||||
ability3.addCost(new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledCreaturePermanent("a creature"))));
|
||||
this.addAbility(ability3);
|
||||
|
||||
// {1}, {tap}, Sacrifice an artifact: Draw a card.
|
||||
Ability ability4 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new GenericManaCost(1));
|
||||
ability4.addCost(new TapSourceCost());
|
||||
ability4.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter2)));
|
||||
ability4.addCost(new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledArtifactPermanent("an artifact"))));
|
||||
this.addAbility(ability4);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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 org.mage.test.cards.abilities.oneshot.sacrifice;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TradingPostTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Trading Post doesn't let me sacrifice a creature owned by my opponent,
|
||||
* but controlled by me. I get an error message saying You cannot sacrifice
|
||||
* this creature.
|
||||
*/
|
||||
@Test
|
||||
public void testSacrifice() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||
// {1}, {T}, Discard a card: You gain 4 life.
|
||||
// {1}, {T}, Pay 1 life: Put a 0/1 white Goat creature token onto the battlefield.
|
||||
// {1}, {T}, Sacrifice a creature: Return target artifact card from your graveyard to your hand.
|
||||
// {1}, {T}, Sacrifice an artifact: Draw a card.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Trading Post", 1);
|
||||
// Gain control of target creature until end of turn. Untap that creature. It gains haste until end of turn. (It can attack and this turn.)
|
||||
addCard(Zone.HAND, playerA, "Act of Treason"); // Sorcery {2}{R}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Helm of Possession");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Savannah Lions");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Act of Treason", "Savannah Lions");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1},{T}, Sacrifice a creature", "Helm of Possession", "Act of Treason", StackClause.WHILE_NOT_ON_STACK);
|
||||
setChoice(playerA, "Savannah Lions");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Act of Treason", 1);
|
||||
|
||||
assertPermanentCount(playerB, "Savannah Lions", 0);
|
||||
assertGraveyardCount(playerB, "Savannah Lions", 1);
|
||||
|
||||
assertTapped("Trading Post", true);
|
||||
assertHandCount(playerA, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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 org.mage.test.cards.replacement.entersBattlefield;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class LivingLoreTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* That the +1/+1 counters are added to Living Lore before state based
|
||||
* actions take place
|
||||
*/
|
||||
@Test
|
||||
public void testCountersAdded() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
|
||||
addCard(Zone.HAND, playerA, "Living Lore"); //{3}{U}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Natural Connection", 1); // {2}{G}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Living Lore");
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Living Lore", 1);
|
||||
assertPowerToughness(playerA, "Living Lore", 3, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -994,6 +994,10 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
player.addAction(turnNum, step, "activate:" + ability + "$target=" + targetName);
|
||||
}
|
||||
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack) {
|
||||
this.activateAbility(turnNum, step, player, ability, targetName, spellOnStack, StackClause.WHILE_ON_STACK);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param turnNum
|
||||
|
|
@ -1004,13 +1008,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* NO_TARGET
|
||||
* @param spellOnStack
|
||||
*/
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack) {
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack, StackClause clause) {
|
||||
StringBuilder sb = new StringBuilder("activate:").append(ability);
|
||||
if (targetName != null && !targetName.isEmpty()) {
|
||||
sb.append("$target=").append(targetName);
|
||||
}
|
||||
if (spellOnStack != null && !spellOnStack.isEmpty()) {
|
||||
sb.append("$spellOnStack=").append(spellOnStack);
|
||||
sb.append("$").append(StackClause.WHILE_ON_STACK.equals(clause) ? "" : "!").append("spellOnStack=").append(spellOnStack);
|
||||
}
|
||||
player.addAction(turnNum, step, sb.toString());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue