forked from magefree/mage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI, combat: fixed that computer safely blocks the weakest creature in…
…stead most powerfull
- Loading branch information
Showing
3 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
Mage.Tests/src/test/java/org/mage/test/AI/basic/BlockSimulationAITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
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 BlockSimulationAITest extends CardTestPlayerBaseWithAIHelps { | ||
|
||
@Test | ||
public void test_Block_1_small_attacker_vs_1_big_blocker() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Arbor Elf", 1); // 1/1 | ||
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1); // 2/2 | ||
|
||
attack(1, playerA, "Arbor Elf"); | ||
|
||
// ai must block | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20); | ||
assertGraveyardCount(playerA, "Arbor Elf", 1); | ||
} | ||
|
||
@Test | ||
public void test_Block_1_small_attacker_vs_2_big_blockers() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Arbor Elf", 1); // 1/1 | ||
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 2); // 2/2 | ||
|
||
attack(1, playerA, "Arbor Elf"); | ||
|
||
// ai must block | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20); | ||
assertGraveyardCount(playerA, "Arbor Elf", 1); | ||
} | ||
|
||
@Test | ||
public void test_Block_1_small_attacker_vs_1_small_blocker() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Arbor Elf", 1); // 1/1 | ||
addCard(Zone.BATTLEFIELD, playerB, "Arbor Elf", 1); // 1/1 | ||
|
||
attack(1, playerA, "Arbor Elf"); | ||
|
||
// ai must block | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20); | ||
assertGraveyardCount(playerA, "Arbor Elf", 1); | ||
assertGraveyardCount(playerB, "Arbor Elf", 1); | ||
} | ||
|
||
@Test | ||
public void test_Block_1_big_attacker_vs_1_small_blocker() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // 2/2 | ||
addCard(Zone.BATTLEFIELD, playerB, "Arbor Elf", 1); // 1/1 | ||
|
||
attack(1, playerA, "Balduvian Bears"); | ||
|
||
// ai must not block | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20 - 2); | ||
assertGraveyardCount(playerA, "Balduvian Bears", 0); | ||
assertGraveyardCount(playerB, "Arbor Elf", 0); | ||
} | ||
|
||
@Test | ||
public void test_Block_2_big_attackers_vs_1_small_blocker() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // 2/2 | ||
addCard(Zone.BATTLEFIELD, playerA, "Deadbridge Goliath", 1); // 5/5 | ||
addCard(Zone.BATTLEFIELD, playerB, "Arbor Elf", 1); // 1/1 | ||
|
||
attack(1, playerA, "Balduvian Bears"); | ||
attack(1, playerA, "Deadbridge Goliath"); | ||
|
||
// ai must not block | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20 - 2 - 5); | ||
assertGraveyardCount(playerA, "Balduvian Bears", 0); | ||
assertGraveyardCount(playerA, "Deadbridge Goliath", 0); | ||
assertGraveyardCount(playerB, "Arbor Elf", 0); | ||
} | ||
|
||
@Test | ||
public void test_Block_2_big_attackers_vs_1_big_blocker_a() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // 2/2 | ||
addCard(Zone.BATTLEFIELD, playerA, "Deadbridge Goliath", 1); // 5/5 | ||
addCard(Zone.BATTLEFIELD, playerB, "Colossal Dreadmaw", 1); // 6/6 | ||
|
||
attack(1, playerA, "Balduvian Bears"); | ||
attack(1, playerA, "Deadbridge Goliath"); | ||
|
||
// ai must block bigger attacker and survive (6/6 must block 5/5) | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20 - 2); | ||
assertGraveyardCount(playerA, "Balduvian Bears", 0); | ||
assertGraveyardCount(playerA, "Deadbridge Goliath", 1); | ||
assertGraveyardCount(playerB, "Colossal Dreadmaw", 0); | ||
} | ||
|
||
@Test | ||
public void test_Block_2_big_attackers_vs_1_big_blocker_b() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Arbor Elf", 1); // 1/1 | ||
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // 2/2 | ||
addCard(Zone.BATTLEFIELD, playerA, "Deadbridge Goliath", 1); // 5/5 | ||
addCard(Zone.BATTLEFIELD, playerA, "Colossal Dreadmaw", 1); // 6/6 | ||
// | ||
addCard(Zone.BATTLEFIELD, playerB, "Spectral Bears", 1); // 3/3 | ||
|
||
attack(1, playerA, "Arbor Elf"); | ||
attack(1, playerA, "Balduvian Bears"); | ||
attack(1, playerA, "Deadbridge Goliath"); | ||
attack(1, playerA, "Colossal Dreadmaw"); | ||
|
||
// ai must block bigger attacker and survive (3/3 must block 2/2) | ||
aiPlayStep(1, PhaseStep.DECLARE_BLOCKERS, playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertLife(playerA, 20); | ||
assertLife(playerB, 20 - 1 - 5 - 6); | ||
assertGraveyardCount(playerA, "Balduvian Bears", 1); | ||
assertPermanentCount(playerB, "Spectral Bears", 1); | ||
} | ||
|
||
// TODO: add tests for DeathtouchAbility | ||
// TODO: add tests for FirstStrikeAbility | ||
// TODO: add tests for DoubleStrikeAbility | ||
// TODO: add tests for IndestructibleAbility | ||
// TODO: add tests for FlyingAbility | ||
// TODO: add tests for ReachAbility | ||
// TODO: add tests for ExaltedAbility??? | ||
} |