mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
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)
This commit is contained in:
parent
8154f04550
commit
3231fef131
1 changed files with 8 additions and 6 deletions
|
@ -32,7 +32,6 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageObjectReference;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
|
@ -132,7 +131,7 @@ class FalseOrdersUnblockEffect extends OneShotEffect {
|
||||||
// Make blocked creatures unblocked
|
// Make blocked creatures unblocked
|
||||||
BecameBlockedByOnlyOneCreatureWatcher watcher = (BecameBlockedByOnlyOneCreatureWatcher) game.getState().getWatchers().get(BecameBlockedByOnlyOneCreatureWatcher.class.getSimpleName());
|
BecameBlockedByOnlyOneCreatureWatcher watcher = (BecameBlockedByOnlyOneCreatureWatcher) game.getState().getWatchers().get(BecameBlockedByOnlyOneCreatureWatcher.class.getSimpleName());
|
||||||
if (watcher != null) {
|
if (watcher != null) {
|
||||||
Set<CombatGroup> combatGroups = watcher.getBlockedOnlyByCreature(new MageObjectReference(permanent.getId(), game));
|
Set<CombatGroup> combatGroups = watcher.getBlockedOnlyByCreature(permanent.getId());
|
||||||
if (combatGroups != null) {
|
if (combatGroups != null) {
|
||||||
for (CombatGroup combatGroup : combatGroups) {
|
for (CombatGroup combatGroup : combatGroups) {
|
||||||
if (combatGroup != null) {
|
if (combatGroup != null) {
|
||||||
|
@ -182,7 +181,7 @@ class FalseOrdersUnblockEffect extends OneShotEffect {
|
||||||
|
|
||||||
class BecameBlockedByOnlyOneCreatureWatcher extends Watcher {
|
class BecameBlockedByOnlyOneCreatureWatcher extends Watcher {
|
||||||
|
|
||||||
private final Map<CombatGroup, MageObjectReference> blockedByOneCreature = new HashMap<>();
|
private final Map<CombatGroup, UUID> blockedByOneCreature = new HashMap<>();
|
||||||
|
|
||||||
public BecameBlockedByOnlyOneCreatureWatcher() {
|
public BecameBlockedByOnlyOneCreatureWatcher() {
|
||||||
super(BecameBlockedByOnlyOneCreatureWatcher.class.getSimpleName(), WatcherScope.GAME);
|
super(BecameBlockedByOnlyOneCreatureWatcher.class.getSimpleName(), WatcherScope.GAME);
|
||||||
|
@ -203,7 +202,10 @@ class BecameBlockedByOnlyOneCreatureWatcher extends Watcher {
|
||||||
if (combatGroup != null) {
|
if (combatGroup != null) {
|
||||||
if (combatGroup.getBlockers().size() == 1) {
|
if (combatGroup.getBlockers().size() == 1) {
|
||||||
if (!blockedByOneCreature.containsKey(combatGroup)) {
|
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) {
|
else if (combatGroup.getBlockers().size() > 1) {
|
||||||
|
@ -213,9 +215,9 @@ class BecameBlockedByOnlyOneCreatureWatcher extends Watcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<CombatGroup> getBlockedOnlyByCreature(MageObjectReference creature) {
|
public Set<CombatGroup> getBlockedOnlyByCreature(UUID creature) {
|
||||||
Set<CombatGroup> combatGroups = new HashSet<>();
|
Set<CombatGroup> combatGroups = new HashSet<>();
|
||||||
for (Map.Entry<CombatGroup, MageObjectReference> entry : blockedByOneCreature.entrySet()) {
|
for (Map.Entry<CombatGroup, UUID> entry : blockedByOneCreature.entrySet()) {
|
||||||
if (entry.getValue() != null) {
|
if (entry.getValue() != null) {
|
||||||
if (entry.getValue().equals(creature)) {
|
if (entry.getValue().equals(creature)) {
|
||||||
combatGroups.add(entry.getKey());
|
combatGroups.add(entry.getKey());
|
||||||
|
|
Loading…
Reference in a new issue