From a7d662d73e1c861b37f9915f34b1e4e1d3ef545d Mon Sep 17 00:00:00 2001 From: L_J Date: Sat, 19 May 2018 08:24:42 +0000 Subject: [PATCH] Changes to menace & Lure interaction --- .../main/java/mage/game/combat/Combat.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/Mage/src/main/java/mage/game/combat/Combat.java b/Mage/src/main/java/mage/game/combat/Combat.java index 31b7fdd76e3..de1bf60ec63 100644 --- a/Mage/src/main/java/mage/game/combat/Combat.java +++ b/Mage/src/main/java/mage/game/combat/Combat.java @@ -970,7 +970,7 @@ public class Combat implements Serializable, Copyable { // check if creatures are forced to block but do not block at all or block creatures they are not forced to block StringBuilder sb = new StringBuilder(); for (Map.Entry> entry : creatureMustBlockAttackers.entrySet()) { - boolean blockIsValid; + boolean blockIsValid = true; Permanent creatureForcedToBlock = game.getPermanent(entry.getKey()); if (creatureForcedToBlock == null) { break; @@ -980,29 +980,6 @@ public class Combat implements Serializable, Copyable { continue; } - // Check if blocker is really able to block one or more attackers (maybe not if the attacker has menace) - if not continue with the next forced blocker - // TODO: Probably there is some potential to abuse the check if forced blockers are assigned to differnt attackers with e.g. menace. - // While if assigned all to one the block is possible -// if (creatureForcedToBlock.getBlocking() = 0) { -// boolean validBlockPossible = false; -// for (UUID possibleAttackerId : entry.getValue()) { -// CombatGroup attackersGroup = findGroup(possibleAttackerId); -// if (attackersGroup.getBlockers().contains(creatureForcedToBlock.getId())) { -// // forcedBlocker blocks a valid blocker, so no problem break check if valid block option exists -// validBlockPossible = true; -// break; -// } -// Permanent attackingCreature = game.getPermanent(possibleAttackerId); -// if (attackingCreature.getMinBlockedBy() > 1) { // e.g. Menace -// if (attackersGroup.getBlockers().size() + 1 >= attackingCreature.getMinBlockedBy()) { -// validBlockPossible = true; -// } -// } -// } -// if (!validBlockPossible) { -// continue; -// } -// } // // check if creature has to pay a cost to block so it's not mandatory to block // boolean removedAttacker = false; @@ -1019,8 +996,24 @@ public class Combat implements Serializable, Copyable { // continue; // } // creature does not block -> not allowed + + // Check if blocker is really able to block one or more attackers (maybe not if the attacker has menace) - if not continue with the next forced blocker + // TODO: Probably there is some potential to abuse the check if forced blockers are assigned to differnt attackers with e.g. menace. + // While if assigned all to one the block is possible if (creatureForcedToBlock.getBlocking() == 0) { - blockIsValid = false; + blockIsValid = entry.getValue().isEmpty(); + for (UUID possibleAttackerId : entry.getValue()) { + CombatGroup attackersGroup = game.getCombat().findGroup(possibleAttackerId); + Permanent attackingCreature = game.getPermanent(possibleAttackerId); + if (attackersGroup == null || attackingCreature == null) { + continue; + } + if (attackingCreature.getMinBlockedBy() > 1) { // e.g. Menace + if (attackersGroup.getBlockers().size() + 1 < attackingCreature.getMinBlockedBy()) { + blockIsValid = true; + } + } + } } else { blockIsValid = false; // which attacker is he blocking