Added a test and some minor changes.

This commit is contained in:
LevelX2 2016-12-11 23:10:20 +01:00
parent eadadd591a
commit 79c80fe24b
4 changed files with 45 additions and 20 deletions

View file

@ -27,10 +27,9 @@
*/
package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -39,6 +38,9 @@ import mage.abilities.keyword.IntimidateAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.other.OwnerIdPredicate;
@ -75,7 +77,7 @@ public class SepulchralPrimordial extends CardImpl {
for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterCard filter = new FilterCreatureCard("creature card from " + opponent.getLogName() + "'s graveyard");
FilterCard filter = new FilterCreatureCard("creature card from " + opponent.getName() + "'s graveyard");
filter.add(new OwnerIdPredicate(opponentId));
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(0, 1, filter);
ability.addTarget(target);
@ -114,14 +116,18 @@ class SepulchralPrimordialEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> cardsToBattlefield = new HashSet<>();
for (Target target : source.getTargets()) {
if (target instanceof TargetCardInOpponentsGraveyard) {
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
targetCard.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
cardsToBattlefield.add(targetCard);
}
}
}
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
}
return true;
}
return false;

View file

@ -91,10 +91,7 @@ class TrinisphereEffect extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)) {
Permanent permanent = game.getPermanent(source.getSourceId());
if(permanent != null && !permanent.isTapped())
{
return true;
}
return permanent != null && !permanent.isTapped();
}
return false;
}

View file

@ -30,8 +30,9 @@ public class CostModificationTest extends CardTestPlayerBase {
}
@Test
public void testCard1() {
addCard(Zone.BATTLEFIELD, playerA, "Trinisphere"); // Set mana cost to min 3
public void testCardTrinisphere() {
// As long as Trinisphere is untapped, each spell that would cost less than three mana to cast costs three mana to cast.
addCard(Zone.BATTLEFIELD, playerA, "Trinisphere");
addCard(Zone.BATTLEFIELD, playerA, "Thalia, Guardian of Thraben"); //+1
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Zone.HAND, playerA, "Lightning Bolt");
@ -45,6 +46,27 @@ public class CostModificationTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, 1);
}
// Trinisphere interacts incorrectly with Phyrexian mana. As implemented, Gitaxian Probe gets a required cost of {2}{U/P},
// which allows paying 2 life and only 2 mana. This is incorrect: Trinisphere requires that at least 3 mana be paid, and
// payment through life doesn't count. (Source: http://blogs.magicjudges.org/rulestips/2012/08/how-trinisphere-works-with-phyrexian-mana/)
@Test
public void testCardTrinispherePhyrexianMana() {
// As long as Trinisphere is untapped, each spell that would cost less than three mana to cast costs three mana to cast.
addCard(Zone.BATTLEFIELD, playerA, "Trinisphere");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
// Look at target player's hand.
// Draw a card.
addCard(Zone.HAND, playerB, "Gitaxian Probe"); // Sorcery {UP}
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Gitaxian Probe", playerA);
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerB, "Gitaxian Probe", 1);
assertGraveyardCount(playerB, "Gitaxian Probe", 0);
}
/**
* Test that cost reduction also works with mana source restriction Myr
* Superion Spend only mana produced by creatures to cast Myr Superion

View file

@ -57,7 +57,7 @@ public class PhyrexianManaCost extends ColoredManaCost {
@Override
public String getText() {
return new StringBuilder("{").append(mana.toString()).append("P}").toString();
return "{" + mana.toString() + "P}";
}
@Override