Additional tests and fix for God-Eternal Kefnet (#7397);

This commit is contained in:
Oleg Agafonov 2021-01-18 04:23:46 +04:00
parent e05875c7e5
commit 639c68cd76
2 changed files with 90 additions and 10 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.g;
import java.awt.*;
import java.util.UUID;
import mage.ApprovingObject;
import mage.MageInt;
import mage.abilities.Ability;
@ -11,18 +9,17 @@ import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
import mage.abilities.hint.HintUtils;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.cards.*;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.watchers.common.CardsAmountDrawnThisTurnWatcher;
import java.awt.*;
import java.util.UUID;
/**
* @author JayDi85
*/
@ -93,17 +90,21 @@ class GodEternalKefnetDrawCardReplacementEffect extends ReplacementEffectImpl {
you.setTopCardRevealed(true);
// cast copy
if (topCard.isInstantOrSorcery() && you.chooseUse(outcome, "Would you like to copy " + topCard.getName()
+ " and cast it for {2} less?", source, game)) {
if (topCard.isInstantOrSorcery()
&& you.chooseUse(outcome, "Would you like to copy " + topCard.getName() + " and cast it for {2} less?", source, game)) {
Card blueprint = topCard.copy();
if (blueprint instanceof SplitCard) {
((SplitCard) blueprint).getLeftHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
((SplitCard) blueprint).getRightHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
} else if (blueprint instanceof ModalDoubleFacesCard) {
((ModalDoubleFacesCard) blueprint).getLeftHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
((ModalDoubleFacesCard) blueprint).getRightHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
} else {
blueprint.addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
}
Card copiedCard = game.copyCard(blueprint, source, source.getControllerId());
you.moveCardToHandWithInfo(copiedCard, source, game, true); // The copy is created in and cast from your hand.
you.moveCardToHandWithInfo(copiedCard, source, game, true); // The copy is created in and cast from your hand. (2019-05-03)
you.cast(you.chooseAbilityForCast(copiedCard, game, false), game, false, new ApprovingObject(source, game));
}

View file

@ -0,0 +1,79 @@
package org.mage.test.cards.single.war;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class GodEternalKefnetTest extends CardTestPlayerBase {
@Test
public void test_Reduce_NormalSpell() {
removeAllCardsFromHand(playerA);
removeAllCardsFromLibrary(playerA);
skipInitShuffling();
// You may reveal the first card you draw each turn as you draw it. Whenever you reveal an instant or sorcery
// card this way, copy that card and you may cast the copy. That copy costs {2} less to cast.
addCard(Zone.BATTLEFIELD, playerA, "God-Eternal Kefnet");
//
// Precision Bolt deals 3 damage to any target.
addCard(Zone.LIBRARY, playerA, "Precision Bolt"); // sorcery {2}{R}
addCard(Zone.LIBRARY, playerA, "Grizzly Bears"); // creature
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
// draw on tune 3 - bear - ignore
setChoice(playerA, "Yes");
// draw on tune 5 - bolt - reveal and cast
setChoice(playerA, "Yes"); // reveal
setChoice(playerA, "Yes"); // cast
addTarget(playerA, playerB);
setStrictChooseMode(true);
setStopAt(5, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertHandCount(playerA, "Precision Bolt", 1);
assertGraveyardCount(playerA, "Precision Bolt", 0);
assertLife(playerB, 20 - 3);
}
@Test
public void test_Reduce_Split() {
removeAllCardsFromHand(playerA);
removeAllCardsFromLibrary(playerA);
skipInitShuffling();
// You may reveal the first card you draw each turn as you draw it. Whenever you reveal an instant or sorcery
// card this way, copy that card and you may cast the copy. That copy costs {2} less to cast.
addCard(Zone.BATTLEFIELD, playerA, "God-Eternal Kefnet");
//
// Fire {1}{R}
// Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
// Ice {1}{U}
// Tap target permanent.
// Draw a card.
addCard(Zone.LIBRARY, playerA, "Fire // Ice");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
showAvailableMana("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
setChoice(playerA, "Yes"); // reveal
setChoice(playerA, "Yes"); // cast
setChoice(playerA, "Cast Fire");
addTargetAmount(playerA, playerB, 2);
setStrictChooseMode(true);
setStopAt(3, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertHandCount(playerA, "Fire // Ice", 1);
assertGraveyardCount(playerA, "Fire // Ice", 0);
assertLife(playerB, 20 - 2);
}
}