Updated commander zone change rules (ready for review) (#6620)

* updated commander zone change rules

* moved commander tracking into game state

* fixed a zone change error

* fixed some more tests for new commander rule

* updated variable names

* updated a test name
This commit is contained in:
Evan Kranzler 2020-06-12 07:42:36 -04:00 committed by GitHub
parent 8902fb1002
commit 63851b73a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 9 deletions

View file

@ -5,6 +5,7 @@ import java.util.*;
import static java.util.Collections.emptyList;
import java.util.stream.Collectors;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.*;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffects;
@ -98,6 +99,7 @@ public class GameState implements Serializable, Copyable<GameState> {
private Map<UUID, Card> copiedCards = new HashMap<>();
private int permanentOrderNumber;
private Map<UUID, FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = new HashMap<>();
private final Set<MageObjectReference> commandersToStay = new HashSet<>();
private int applyEffectsCounter; // Upcounting number of each applyEffects execution
@ -1225,4 +1227,12 @@ public class GameState implements Serializable, Copyable<GameState> {
.map(usePowerInsteadOfToughnessForDamageLethalityFilters::get)
.collect(Collectors.toList());
}
boolean checkCommanderShouldStay(Card card, Game game) {
return commandersToStay.stream().anyMatch(mor -> mor.refersTo(card, game));
}
void setCommanderShouldStay(Card card, Game game) {
commandersToStay.add(new MageObjectReference(card, game));
}
}