* AI: fixed wrong targeting for gain control abilities (#6340);

This commit is contained in:
Oleg Agafonov 2020-03-11 18:22:58 +04:00
parent 3cd5682db7
commit 14ddb6eb28
7 changed files with 99 additions and 24 deletions

View file

@ -0,0 +1,75 @@
package org.mage.test.AI.basic;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
/**
* @author JayDi85
*/
public class GainControlAITest extends CardTestPlayerBaseWithAIHelps {
@Test
public void test_GainControl_Manual() {
// You control enchanted land.
addCard(Zone.HAND, playerA, "Annex", 1); // {2}{U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
// take control
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Annex", "Swamp");
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Island", 4);
assertPermanentCount(playerA, "Swamp", 1);
assertPermanentCount(playerB, "Swamp", 0);
}
@Test
public void test_GainControl_AI_Single() {
// You control enchanted land.
addCard(Zone.HAND, playerA, "Annex", 1); // {2}{U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
// take control by AI
aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA);
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Island", 4);
assertPermanentCount(playerA, "Swamp", 1);
assertPermanentCount(playerB, "Swamp", 0);
}
@Test
public void test_GainControl_AI_MostValuable() {
// You control enchanted land.
addCard(Zone.HAND, playerA, "Annex", 1); // {2}{U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerB, "Badlands", 1);
// take control by AI (selects most valueable enemy card)
aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA);
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Island", 4);
assertPermanentCount(playerA, "Swamp", 0);
assertPermanentCount(playerA, "Badlands", 1);
assertPermanentCount(playerB, "Swamp", 1);
assertPermanentCount(playerB, "Badlands", 0);
}
}

View file

@ -55,6 +55,6 @@ public class TargetControllerChangeTest extends CardTestPlayerBase {
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Evangelize", 1);
assertPermanentCount(playerA, "Balduvian Bears", 1); // AI give smallest permanent to A as bad effect for B
assertPermanentCount(playerA, "Balduvian Bears", 1); // AI give smallest permanent to A as bad effect for target (target control change)
}
}