* Replicate abilities - fixed that AI can freeze the game after play card with replicate (AI don't use it now);

This commit is contained in:
Oleg Agafonov 2020-01-04 20:22:49 +04:00
parent a249dcffd8
commit 1ae9fc883e
4 changed files with 74 additions and 23 deletions

View file

@ -1,14 +1,12 @@
package org.mage.test.cards.abilities.keywords;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class ReplicateTest extends CardTestPlayerBase {
@ -24,17 +22,16 @@ public class ReplicateTest extends CardTestPlayerBase {
* replicate cost follows the rules for paying additional costs in rules 601.2b and 601.2eg.
* 702.55b If a spell has multiple instances of replicate, each is paid separately and triggers based on
* the payments made for it, not any other instance of replicate.
*
*/
/**
* Train of Thought
* Sorcery, 1U (2)
* Replicate {1}{U} (When you cast this spell, copy it for each time you paid its replicate cost.)
* Draw a card.
*
*/
/**
* Train of Thought
* Sorcery, 1U (2)
* Replicate {1}{U} (When you cast this spell, copy it for each time you paid its replicate cost.)
* Draw a card.
*/
@Test
public void testReplicate1Time() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 6);
@ -49,9 +46,8 @@ public class ReplicateTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Train of Thought", 1);
assertHandCount(playerA, 2);
}
@Test
public void testReplicate2Times() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 6);
@ -67,7 +63,6 @@ public class ReplicateTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Train of Thought", 1);
assertHandCount(playerA, 3);
}
@Test
@ -83,7 +78,55 @@ public class ReplicateTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Train of Thought", 1);
assertHandCount(playerA, 1);
}
@Test
public void testReplicate_User() {
// Replicate {1}{R} (When you cast this spell, copy it for each time you paid its replicate cost. You may choose new targets for the copies.)
// Pyromatics deals 1 damage to any target.
addCard(Zone.HAND, playerA, "Pyromatics", 1); // {1}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pyromatics");
addTarget(playerA, playerB);
setChoice(playerA, "Yes"); // replicate 1
setChoice(playerA, "Yes"); // replicate 2
setChoice(playerA, "No"); // stop
//
setChoice(playerA, "No"); // don't change target 1
setChoice(playerA, "No"); // don't change target 2
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertLife(playerB, 20 - 3); // 1 + 2 replicates
}
@Test
@Ignore // TODO: enable test after replicate ability will be supported by AI
public void testReplicate_AI() {
// Replicate {1}{R} (When you cast this spell, copy it for each time you paid its replicate cost. You may choose new targets for the copies.)
// Pyromatics deals 1 damage to any target.
addCard(Zone.HAND, playerA, "Pyromatics", 1); // {1}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pyromatics");
addTarget(playerA, playerB);
//setChoice(playerA, "Yes"); // replicate 1 - AI must choice max possible
//setChoice(playerA, "Yes"); // replicate 2 - AI must choice max possible
//setChoice(playerA, "No"); // stop - AI must choice max possible
//
//setChoice(playerA, "No"); // don't change target 1
//setChoice(playerA, "No"); // don't change target 2
//setStrictChooseMode(true); - AI must choice
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertLife(playerB, 20 - 3); // 1 + 2 replicates
}
}