mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
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:
parent
8902fb1002
commit
63851b73a1
8 changed files with 52 additions and 9 deletions
|
|
@ -106,8 +106,6 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
switch (zEvent.getToZone()) {
|
||||
case LIBRARY:
|
||||
case HAND:
|
||||
case GRAVEYARD:
|
||||
case EXILED:
|
||||
if (commanderId.equals(zEvent.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1853,6 +1853,41 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
// If a commander is in a graveyard or in exile and that card was put into that zone
|
||||
// since the last time state-based actions were checked, its owner may put it into the command zone.
|
||||
for (Player player : state.getPlayers().values()) {
|
||||
Set<UUID> commanderIds = getCommandersIds(player, CommanderCardType.COMMANDER_OR_OATHBREAKER);
|
||||
if (commanderIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Set<Card> commanders = new HashSet<>();
|
||||
Cards toMove = new CardsImpl();
|
||||
player.getGraveyard()
|
||||
.stream()
|
||||
.filter(commanderIds::contains)
|
||||
.map(this::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(commanders::add);
|
||||
commanderIds
|
||||
.stream()
|
||||
.map(uuid -> getExile().getCard(uuid, this))
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(commanders::add);
|
||||
commanders.removeIf(card -> state.checkCommanderShouldStay(card, this));
|
||||
for (Card card : commanders) {
|
||||
if (player.chooseUse(Outcome.Benefit, "Move " + card.getIdName() + " to the command zone or leave it in its current zone?", "You can only make this choice once", "Move to command", "Leave in current zone", null, this)) {
|
||||
toMove.add(card);
|
||||
} else {
|
||||
state.setCommanderShouldStay(card, this);
|
||||
}
|
||||
}
|
||||
if (toMove.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
player.moveCards(toMove, Zone.COMMAND, null, this);
|
||||
somethingHappened = true;
|
||||
}
|
||||
|
||||
// 704.5e If a copy of a spell is in a zone other than the stack, it ceases to exist. If a copy of a card is in any zone other than the stack or the battlefield, it ceases to exist.
|
||||
// (Isochron Scepter) 12/1/2004: If you don't want to cast the copy, you can choose not to; the copy ceases to exist the next time state-based actions are checked.
|
||||
Iterator<Card> copiedCards = this.getState().getCopiedCards().iterator();
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3879,7 +3879,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
break;
|
||||
case COMMAND:
|
||||
for (Card card : cards) {
|
||||
if (moveCardToCommandWithInfo(card, source.getSourceId(), game, fromZone)) {
|
||||
if (moveCardToCommandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone)) {
|
||||
successfulMovedCards.add(card);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue