From bb56568ea1454f5cb9f1d03c8466bc231022ee15 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Wed, 22 Nov 2017 02:13:22 +0100 Subject: [PATCH] Implemented Defensive Formation --- .../java/mage/game/combat/CombatGroup.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Mage/src/main/java/mage/game/combat/CombatGroup.java b/Mage/src/main/java/mage/game/combat/CombatGroup.java index fc40f7e958..277233119d 100644 --- a/Mage/src/main/java/mage/game/combat/CombatGroup.java +++ b/Mage/src/main/java/mage/game/combat/CombatGroup.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import mage.abilities.common.ControllerAssignCombatDamageToBlockersAbility; import mage.abilities.common.DamageAsThoughNotBlockedAbility; import mage.abilities.keyword.CantBlockAloneAbility; import mage.abilities.keyword.DeathtouchAbility; @@ -244,6 +245,12 @@ public class CombatGroup implements Serializable, Copyable { blocker.markDamage(damage, attacker.getId(), game, true, true); } else { Player player = game.getPlayer(attacker.getControllerId()); + for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation + if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) { + player = game.getPlayer(defendingPlayerId); + break; + } + } int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game); blocker.markDamage(damageAssigned, attacker.getId(), game, true, true); damage -= damageAssigned; @@ -270,6 +277,12 @@ public class CombatGroup implements Serializable, Copyable { return; } Player player = game.getPlayer(attacker.getControllerId()); + for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation + if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) { + player = game.getPlayer(defendingPlayerId); + break; + } + } int damage = getDamageValueFromPermanent(attacker, game); if (canDamage(attacker, first)) { // must be set before attacker damage marking because of effects like Test of Faith @@ -463,6 +476,12 @@ public class CombatGroup implements Serializable, Copyable { return; } Player player = game.getPlayer(playerId); + for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation + if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) { + player = game.getPlayer(defendingPlayerId); + break; + } + } List blockerList = new ArrayList<>(blockers); blockerOrder.clear(); while (player.canRespond()) {