AI: added support to attack/kill any opponent in multiplayer, not only first one;
@@ -3,6 +3,7 @@ package mage.player.ai;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
+import mage.abilities.StaticAbility;
import mage.abilities.common.PassAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.SearchEffect;
@@ -36,7 +37,6 @@ import org.apache.log4j.Logger;
import java.io.File;
import java.util.*;
import java.util.concurrent.*;
-import mage.abilities.StaticAbility;
/**
* @author nantuko
@@ -794,19 +794,22 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
private void declareAttackers(Game game, UUID activePlayerId) {
game.fireEvent(new GameEvent(GameEvent.EventType.DECLARE_ATTACKERS_STEP_PRE, null, null, activePlayerId));
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, activePlayerId, activePlayerId))) {
-
Player attackingPlayer = game.getPlayer(activePlayerId);
- // TODO: this works only in two player game, also no attack of Planeswalker
- UUID defenderId = game.getOpponents(playerId).iterator().next();
+
+ // TODO: add attack of Planeswalker
+
+ // 1. check alpha strike first (all in attack to kill)
+ for (UUID defenderId : game.getOpponents(playerId)) {
Player defender = game.getPlayer(defenderId);
+ if (!defender.isInGame()) {
+ continue;
+ }
List<Permanent> attackersList = super.getAvailableAttackers(defenderId, game);
if (attackersList.isEmpty()) {
- return;
+ continue;
}
-
List<Permanent> possibleBlockers = defender.getAvailableBlockers(game);
-
List<Permanent> killers = CombatUtil.canKillOpponent(game, attackersList, possibleBlockers, defender);
if (!killers.isEmpty()) {
for (Permanent attacker : killers) {
@@ -814,6 +817,19 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
}
return;
}
+ }
+
+ // 2. check all other actions
+ for (UUID defenderId : game.getOpponents(playerId)) {
+ Player defender = game.getPlayer(defenderId);
+ if (!defender.isInGame()) {
+ continue;
+ }
+ List<Permanent> attackersList = super.getAvailableAttackers(defenderId, game);
+ if (attackersList.isEmpty()) {
+ continue;
+ }
+ List<Permanent> possibleBlockers = defender.getAvailableBlockers(game);
// The AI will now attack more sanely. Simple, but good enough for now.
// The sim minmax does not work at the moment.
@@ -863,6 +879,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
}
}
}
+ }
@Override
public void selectAttackers(Game game, UUID attackingPlayerId) {
