Test for Copied Gilded Drake reverting control when killed (#9198)

This commit is contained in:
Alex Vasile 2022-07-27 08:05:10 -04:00 committed by GitHub
parent 5d11bab6dd
commit c34c6a59df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 30 deletions

View file

@ -28,7 +28,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
private boolean withSecondTarget;
private boolean destroyAttachedAuras;
private Map<UUID, Integer> zoneChangeCounter = new HashMap<>();
private Map<UUID, UUID> lockedControllers = new HashMap<>();
private Map<UUID, UUID> lockedControllers = new HashMap<>(); // Controllers for each permanent that is enforced by this effect
public ExchangeControlTargetEffect(Duration duration, String rule) {
this(duration, rule, false);
@ -102,9 +102,11 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
discard();
return;
}
// Meant to be swapped since this enforced the
this.lockedControllers.put(permanent1.getId(), permanent2.getControllerId());
this.zoneChangeCounter.put(permanent1.getId(), permanent1.getZoneChangeCounter(game));
this.lockedControllers.put(permanent2.getId(), permanent1.getControllerId());
this.zoneChangeCounter.put(permanent1.getId(), permanent1.getZoneChangeCounter(game));
this.zoneChangeCounter.put(permanent2.getId(), permanent2.getZoneChangeCounter(game));
} else {
// discard if there are less than 2 permanents
@ -118,7 +120,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
for (Map.Entry<UUID, Integer> entry : zoneChangeCounter.entrySet()) {
Permanent permanent = game.getPermanent(entry.getKey());
if (permanent == null || permanent.getZoneChangeCounter(game) != entry.getValue()) {
// controll effect cease if the same permanent is no longer on the battlefield
// Control effect cease if the same permanent is no longer on the battlefield
toDelete.add(entry.getKey());
continue;
}
@ -138,6 +140,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
if (!toDelete.isEmpty()) {
for (UUID uuid : toDelete) {
zoneChangeCounter.remove(uuid);
lockedControllers.remove(uuid);
}
if (zoneChangeCounter.isEmpty()) {
discard();