From 3231fef13102c11697e8664df3169fd60a266e33 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 17 Nov 2017 23:03:11 +0100 Subject: [PATCH] Final version (hopefully) ...until Banding becomes a thing, at least. Using MageObjectReference instead of UUID for the watcher was buggy in certain fringe scenarios (casting False Orders twice on one blocker - remove blocker then block again, then remove blocker and don't block - would result in a blocked attacker without a blocker) --- Mage.Sets/src/mage/cards/f/FalseOrders.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/cards/f/FalseOrders.java b/Mage.Sets/src/mage/cards/f/FalseOrders.java index 2e1dfd51cc..1e8c97e640 100644 --- a/Mage.Sets/src/mage/cards/f/FalseOrders.java +++ b/Mage.Sets/src/mage/cards/f/FalseOrders.java @@ -32,7 +32,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.UUID; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; import mage.abilities.effects.Effect; @@ -132,7 +131,7 @@ class FalseOrdersUnblockEffect extends OneShotEffect { // Make blocked creatures unblocked BecameBlockedByOnlyOneCreatureWatcher watcher = (BecameBlockedByOnlyOneCreatureWatcher) game.getState().getWatchers().get(BecameBlockedByOnlyOneCreatureWatcher.class.getSimpleName()); if (watcher != null) { - Set combatGroups = watcher.getBlockedOnlyByCreature(new MageObjectReference(permanent.getId(), game)); + Set combatGroups = watcher.getBlockedOnlyByCreature(permanent.getId()); if (combatGroups != null) { for (CombatGroup combatGroup : combatGroups) { if (combatGroup != null) { @@ -182,7 +181,7 @@ class FalseOrdersUnblockEffect extends OneShotEffect { class BecameBlockedByOnlyOneCreatureWatcher extends Watcher { - private final Map blockedByOneCreature = new HashMap<>(); + private final Map blockedByOneCreature = new HashMap<>(); public BecameBlockedByOnlyOneCreatureWatcher() { super(BecameBlockedByOnlyOneCreatureWatcher.class.getSimpleName(), WatcherScope.GAME); @@ -203,7 +202,10 @@ class BecameBlockedByOnlyOneCreatureWatcher extends Watcher { if (combatGroup != null) { if (combatGroup.getBlockers().size() == 1) { if (!blockedByOneCreature.containsKey(combatGroup)) { - blockedByOneCreature.put(combatGroup, new MageObjectReference(combatGroup.getBlockers().get(0), game)); + blockedByOneCreature.put(combatGroup, event.getSourceId()); + } + else if (blockedByOneCreature.get(combatGroup) != event.getSourceId()) { + blockedByOneCreature.put(combatGroup, null); } } else if (combatGroup.getBlockers().size() > 1) { @@ -213,9 +215,9 @@ class BecameBlockedByOnlyOneCreatureWatcher extends Watcher { } } - public Set getBlockedOnlyByCreature(MageObjectReference creature) { + public Set getBlockedOnlyByCreature(UUID creature) { Set combatGroups = new HashSet<>(); - for (Map.Entry entry : blockedByOneCreature.entrySet()) { + for (Map.Entry entry : blockedByOneCreature.entrySet()) { if (entry.getValue() != null) { if (entry.getValue().equals(creature)) { combatGroups.add(entry.getKey());