AI fixes:

* Gain control abilities - fixed wrong target chooses by AI (selects weakest permanent instead most powerful);
* Target of an opponent’s choice abilities - fixed that AI was able to cancel card cast, fixed wrong target chooses (Evangelize, Echo Chamber, Arena, Preacher, etc);
This commit is contained in:
Oleg Agafonov 2020-01-04 22:37:16 +04:00
parent bcb37992cc
commit bb59cedbd9
12 changed files with 137 additions and 93 deletions

View file

@ -0,0 +1,60 @@
package org.mage.test.AI.basic;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class TargetControllerChangeTest extends CardTestPlayerBase {
@Test
public void test_OpponentMakeChooseInsteadPlayer_User() {
// Gain control of target creature of an opponents choice they control.
addCard(Zone.HAND, playerA, "Evangelize", 1); // {4}{W}
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
//
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Spectral Bears", 1); // 3/3
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Evangelize"); // do not call direct target setup
addTarget(playerA, playerB); // choose target opponent
setChoice(playerA, "No"); // no buyback
//
addTarget(playerB, "Balduvian Bears"); // give small bear to A
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Evangelize", 1);
assertPermanentCount(playerA, "Balduvian Bears", 1);
}
@Test
public void test_OpponentMakeChooseInsteadPlayer_AI() {
// Gain control of target creature of an opponents choice they control.
addCard(Zone.HAND, playerA, "Evangelize", 1); // {4}{W}
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
//
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Spectral Bears", 1); // 3/3
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Evangelize"); // do not call direct target setup
//addTarget(playerA, playerB); // choose target opponent - AI must choose itself
//setChoice(playerA, "No"); // no buyback - AI must choose itself
//
//addTarget(playerB, "Balduvian Bears"); // give small bear to A - AI must choose itself
//setStrictChooseMode(true); // AI must choose
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Evangelize", 1);
assertPermanentCount(playerA, "Balduvian Bears", 1); // AI give smallest permanent to A as bad effect for B
}
}