use of mage.player.ai.util.CombatInfo in project mage by magefree.
the class ComputerPlayer6 method declareBlockers.
private void declareBlockers(Game game, UUID activePlayerId) {
game.fireEvent(new GameEvent(GameEvent.EventType.DECLARE_BLOCKERS_STEP_PRE, null, null, activePlayerId));
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_BLOCKERS, activePlayerId, activePlayerId))) {
List<Permanent> attackers = getAttackers(game);
if (attackers == null) {
return;
}
List<Permanent> possibleBlockers = super.getAvailableBlockers(game);
possibleBlockers = filterOutNonblocking(game, attackers, possibleBlockers);
if (possibleBlockers.isEmpty()) {
return;
}
attackers = filterOutUnblockable(game, attackers, possibleBlockers);
if (attackers.isEmpty()) {
return;
}
CombatUtil.sortByPower(attackers, false);
CombatInfo combatInfo = CombatUtil.blockWithGoodTrade2(game, attackers, possibleBlockers);
Player player = game.getPlayer(playerId);
boolean blocked = false;
for (Map.Entry<Permanent, List<Permanent>> entry : combatInfo.getCombat().entrySet()) {
UUID attackerId = entry.getKey().getId();
List<Permanent> blockers = entry.getValue();
if (blockers != null) {
for (Permanent blocker : blockers) {
player.declareBlocker(player.getId(), blocker.getId(), attackerId, game);
blocked = true;
}
}
}
if (blocked) {
game.getPlayers().resetPassed();
}
}
}
Aggregations