From 56dbd4b284d7b2f7631df7a10e695cf5f8ac5f62 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 5 Aug 2013 15:32:26 +0200 Subject: [PATCH] Fixed that in multiplayer games attacked players could block attacking creatures that attacked other players. --- Mage/src/mage/game/combat/Combat.java | 4 ++-- Mage/src/mage/game/combat/CombatGroup.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Mage/src/mage/game/combat/Combat.java b/Mage/src/mage/game/combat/Combat.java index d4e287f0dd..6171031f3b 100644 --- a/Mage/src/mage/game/combat/Combat.java +++ b/Mage/src/mage/game/combat/Combat.java @@ -404,7 +404,7 @@ public class Combat implements Serializable, Copyable { return; } Permanent defender = game.getPermanent(defenderId); - CombatGroup newGroup = new CombatGroup(defenderId, defender != null); + CombatGroup newGroup = new CombatGroup(defenderId, defender != null, defender != null ? defender.getControllerId(): defenderId); newGroup.attackers.add(attackerId); Permanent attacker = game.getPermanent(attackerId); if (!attacker.getAbilities().containsKey(VigilanceAbility.getInstance().getId())) { @@ -419,7 +419,7 @@ public class Combat implements Serializable, Copyable { Permanent blocker = game.getPermanent(blockerId); if (blockerId != null && blocker != null && blocker.getBlocking() > 1) { if (!blockingGroups.containsKey(blockerId)) { - CombatGroup newGroup = new CombatGroup(playerId, playerId != null); + CombatGroup newGroup = new CombatGroup(playerId, false, playerId); newGroup.blockers.add(blockerId); // add all blocked attackers for (CombatGroup group : groups) { diff --git a/Mage/src/mage/game/combat/CombatGroup.java b/Mage/src/mage/game/combat/CombatGroup.java index 658fa14bae..758f2c10c8 100644 --- a/Mage/src/mage/game/combat/CombatGroup.java +++ b/Mage/src/mage/game/combat/CombatGroup.java @@ -52,12 +52,14 @@ public class CombatGroup implements Serializable, Copyable { protected List attackerOrder = new ArrayList(); protected Map players = new HashMap(); protected boolean blocked; - protected UUID defenderId; + protected UUID defenderId; // planeswalker or player + protected UUID defendingPlayerId; protected boolean defenderIsPlaneswalker; - public CombatGroup(UUID defenderId, boolean defenderIsPlaneswalker) { + public CombatGroup(UUID defenderId, boolean defenderIsPlaneswalker, UUID defendingPlayerId) { this.defenderId = defenderId; this.defenderIsPlaneswalker = defenderIsPlaneswalker; + this.defendingPlayerId = defendingPlayerId; } public CombatGroup(final CombatGroup group) { @@ -379,6 +381,10 @@ public class CombatGroup implements Serializable, Copyable { } public boolean canBlock(Permanent blocker, Game game) { + // you can't block if combat group attacks another player + if (!defendingPlayerId.equals(blocker.getControllerId()) ) { + return false; + } for (UUID attackerId: attackers) { if (!blocker.canBlock(attackerId, game)) { return false;