mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Extra tests for AI;
This commit is contained in:
parent
e02d8a079b
commit
02b1e86f20
2 changed files with 26 additions and 0 deletions
|
@ -841,10 +841,14 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
||||||
int attackerValue = eval.evaluate(attacker, game);
|
int attackerValue = eval.evaluate(attacker, game);
|
||||||
for (Permanent blocker : possibleBlockers) {
|
for (Permanent blocker : possibleBlockers) {
|
||||||
int blockerValue = eval.evaluate(blocker, game);
|
int blockerValue = eval.evaluate(blocker, game);
|
||||||
|
|
||||||
|
// blocker can kill attacker
|
||||||
if (attacker.getPower().getValue() <= blocker.getToughness().getValue()
|
if (attacker.getPower().getValue() <= blocker.getToughness().getValue()
|
||||||
&& attacker.getToughness().getValue() <= blocker.getPower().getValue()) {
|
&& attacker.getToughness().getValue() <= blocker.getPower().getValue()) {
|
||||||
safeToAttack = false;
|
safeToAttack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// kill each other
|
||||||
if (attacker.getToughness().getValue() == blocker.getPower().getValue()
|
if (attacker.getToughness().getValue() == blocker.getPower().getValue()
|
||||||
&& attacker.getPower().getValue() == blocker.getToughness().getValue()) {
|
&& attacker.getPower().getValue() == blocker.getToughness().getValue()) {
|
||||||
if (attackerValue > blockerValue
|
if (attackerValue > blockerValue
|
||||||
|
@ -859,19 +863,26 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
||||||
safeToAttack = false;
|
safeToAttack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attacker can kill by deathtouch
|
||||||
if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())
|
if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())
|
||||||
|| attacker.getAbilities().containsKey(IndestructibleAbility.getInstance().getId())) {
|
|| attacker.getAbilities().containsKey(IndestructibleAbility.getInstance().getId())) {
|
||||||
safeToAttack = true;
|
safeToAttack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attacker can ignore blocker
|
||||||
if (attacker.getAbilities().containsKey(FlyingAbility.getInstance().getId())
|
if (attacker.getAbilities().containsKey(FlyingAbility.getInstance().getId())
|
||||||
&& !blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId())
|
&& !blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId())
|
||||||
&& !blocker.getAbilities().containsKey(ReachAbility.getInstance().getId())) {
|
&& !blocker.getAbilities().containsKey(ReachAbility.getInstance().getId())) {
|
||||||
safeToAttack = true;
|
safeToAttack = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0 damage
|
||||||
if (attacker.getPower().getValue() == 0) {
|
if (attacker.getPower().getValue() == 0) {
|
||||||
safeToAttack = false;
|
safeToAttack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safeToAttack) {
|
if (safeToAttack) {
|
||||||
// undo has to be possible e.g. if not able to pay a attack fee (e.g. Ghostly Prison)
|
// undo has to be possible e.g. if not able to pay a attack fee (e.g. Ghostly Prison)
|
||||||
attackingPlayer.declareAttacker(attacker.getId(), defenderId, game, true);
|
attackingPlayer.declareAttacker(attacker.getId(), defenderId, game, true);
|
||||||
|
|
|
@ -204,4 +204,19 @@ public class AttackAndBlockByAITest extends CardTestPlayerBaseAI {
|
||||||
assertLife(playerA, 20);
|
assertLife(playerA, 20);
|
||||||
assertLife(playerB, 20);
|
assertLife(playerB, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_Attack_1_with_counters_vs_1() {
|
||||||
|
// chainbreaker real stats is 1/1, it's can be saftly attacked
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); // 2/2
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Chainbreaker", 1); // 3/3, but with 2x -1/-1 counters
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20 - 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue