mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Fixed the handling of comparing characteristics concerning split cards (related to the recent rule changes).
This commit is contained in:
parent
4b421fa722
commit
0b827b239c
6 changed files with 67 additions and 31 deletions
|
@ -73,18 +73,48 @@ public class TransmuteTest extends CardTestPlayerBase {
|
|||
@Test
|
||||
public void searchSplittedCardOneManaCmcSpell() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
addCard(Zone.HAND, playerA, "Dizzy Spell");
|
||||
// Target creature gets -3/-0 until end of turn.
|
||||
// Transmute {1}{U}{U} ({1}{U}{U}, Discard this card: Search your library for a card with the same converted mana cost as this card, reveal it, and put it into your hand. Then shuffle your library. Transmute only as a sorcery.)
|
||||
addCard(Zone.HAND, playerA, "Dizzy Spell"); // Instant {U}
|
||||
|
||||
// Wear {1}{R}
|
||||
// Destroy target artifact.
|
||||
// Tear {W}
|
||||
// Destroy target enchantment.
|
||||
addCard(Zone.LIBRARY, playerA, "Wear // Tear");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Transmute {1}{U}{U}");
|
||||
setChoice(playerA, "Wear // Tear");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Dizzy Spell", 1);
|
||||
assertHandCount(playerA, "Wear", 1); // Filter search can only search for one side of a split card
|
||||
assertHandCount(playerA, "Tear", 1); // Filter search can only search for one side of a split card
|
||||
assertHandCount(playerA, "Wear // Tear", 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchSplittedCardThreeManaCmcSpell() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||
// Counter target spell unless its controller discards his or her hand.
|
||||
// Transmute {1}{U}{B}
|
||||
addCard(Zone.HAND, playerA, "Perplex"); // Instant {1}{U}{B}
|
||||
|
||||
// Wear {1}{R}
|
||||
// Destroy target artifact.
|
||||
// Tear {W}
|
||||
// Destroy target enchantment.
|
||||
addCard(Zone.LIBRARY, playerA, "Wear // Tear");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Transmute {1}{U}{B}");
|
||||
setChoice(playerA, "Wear // Tear");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Perplex", 1);
|
||||
assertHandCount(playerA, "Wear // Tear", 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public class SplitCardCmcTest extends CardTestPlayerBase {
|
|||
public void testSplitCardCmcInHand() {
|
||||
// Total CMC of Failure // Comply is 3, so should be exiled by Transgress the Mind.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
// Devoid
|
||||
// Target player reveals his or her hand. You may choose a card from it with converted mana cost 3 or greater and exile that card.
|
||||
addCard(Zone.HAND, playerA, "Transgress the Mind");
|
||||
addCard(Zone.HAND, playerB, "Failure // Comply");
|
||||
|
||||
|
@ -42,11 +44,17 @@ public class SplitCardCmcTest extends CardTestPlayerBase {
|
|||
public void testSplitCardCmcOnStack() {
|
||||
// Counterbalance revealing Wear // Tear counters a spell with converted mana cost 3, but not 1 or 2.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||
addCard(Zone.HAND, playerA, "Typhoid Rats");
|
||||
addCard(Zone.HAND, playerA, "Typhoid Rats"); // Creature 1/1 {B}
|
||||
|
||||
// Whenever an opponent casts a spell, you may reveal the top card of your library. If you do, counter that spell
|
||||
// if it has the same converted mana cost as the revealed card.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Counterbalance");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
|
||||
// Wear {1}{R}
|
||||
// Destroy target artifact.
|
||||
// Tear {W}
|
||||
// Destroy target enchantment.
|
||||
addCard(Zone.LIBRARY, playerB, "Wear // Tear"); // CMC now 3
|
||||
skipInitShuffling(); // so the set to top card stays at top
|
||||
|
||||
|
|
|
@ -65,12 +65,16 @@ public class DuskDawnTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerA, "Dusk // Dawn", 0);
|
||||
}
|
||||
|
||||
// Fail to cast Dawn (Aftermath part) from hand
|
||||
@Test
|
||||
public void testCastDawnFail() {
|
||||
// Fail to cast dawn from hand
|
||||
// Dusk {2}{W}{W}
|
||||
// Destroy all creatures with power 3 or greater.
|
||||
// Dawn {3}{W}{W}
|
||||
// Return all creature cards with power less than or equal to 2 from your graveyard to your hand.
|
||||
addCard(Zone.HAND, playerA, "Dusk // Dawn");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||
addCard(Zone.GRAVEYARD, playerA, "Devoted Hero");
|
||||
addCard(Zone.GRAVEYARD, playerA, "Devoted Hero"); // Creature 1/2 {W}
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dawn");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
|
|
|
@ -805,9 +805,19 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param count Expected count.
|
||||
*/
|
||||
public void assertHandCount(Player player, String cardName, int count) throws AssertionError {
|
||||
FilterCard filter = new FilterCard();
|
||||
filter.add(new NamePredicate(cardName));
|
||||
int actual = currentGame.getPlayer(player.getId()).getHand().count(filter, player.getId(), currentGame);
|
||||
int actual;
|
||||
if (cardName.contains("//")) { // special logic for cheched split cards, because in game logic of card name filtering is different than for test
|
||||
actual = 0;
|
||||
for (Card card : currentGame.getPlayer(player.getId()).getHand().getCards(currentGame)) {
|
||||
if (card.getName().equals(cardName)) {
|
||||
actual++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FilterCard filter = new FilterCard();
|
||||
filter.add(new NamePredicate(cardName));
|
||||
actual = currentGame.getPlayer(player.getId()).getHand().count(filter, player.getId(), currentGame);
|
||||
}
|
||||
Assert.assertEquals("(Hand) Card counts for card " + cardName + " for " + player.getName() + " are not equal ", count, actual);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,11 @@
|
|||
package mage.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.filter.predicate.ObjectPlayer;
|
||||
import mage.filter.predicate.ObjectPlayerPredicate;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
|
@ -78,12 +75,7 @@ public class FilterCard extends FilterObject<Card> {
|
|||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
if (card.isSplitCard()) {
|
||||
return super.match(((SplitCard) card).getLeftHalfCard(), game)
|
||||
|| super.match(((SplitCard) card).getRightHalfCard(), game);
|
||||
} else {
|
||||
return super.match(card, game);
|
||||
}
|
||||
return super.match(card, game);
|
||||
}
|
||||
|
||||
public boolean match(Card card, UUID playerId, Game game) {
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
*/
|
||||
package mage.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
|
@ -36,7 +40,6 @@ import mage.abilities.SpellAbility;
|
|||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.filter.FilterMana;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -44,11 +47,6 @@ import mage.game.permanent.token.Token;
|
|||
import mage.game.stack.Spell;
|
||||
import mage.util.functions.CopyTokenFunction;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
|
@ -540,13 +538,7 @@ public final class CardUtil {
|
|||
cmcObject.add(object.getConvertedManaCost());
|
||||
} else if (object instanceof Card) {
|
||||
Card card = (Card) object;
|
||||
if (card instanceof SplitCard) {
|
||||
SplitCard splitCard = (SplitCard) card;
|
||||
cmcObject.add(splitCard.getLeftHalfCard().getConvertedManaCost());
|
||||
cmcObject.add(splitCard.getRightHalfCard().getConvertedManaCost());
|
||||
} else {
|
||||
cmcObject.add(card.getConvertedManaCost());
|
||||
}
|
||||
cmcObject.add(card.getConvertedManaCost());
|
||||
}
|
||||
return cmcObject;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue