* Leadership Vacuum - Fixed that the movement of the commanders were not reported in the game log.

This commit is contained in:
LevelX2 2020-01-09 22:46:20 +01:00
parent b6b2103b6c
commit 349a2cc612
3 changed files with 139 additions and 91 deletions

View file

@ -1,5 +1,7 @@
package mage.cards.l; package mage.cards.l;
import java.util.HashSet;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
@ -14,8 +16,6 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.UUID;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
@ -70,9 +70,8 @@ class LeadershipVacuumEffect extends OneShotEffect {
if (player == null) { if (player == null) {
return false; return false;
} }
return player.moveCards(
return game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game).stream() new HashSet<>(game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)),
.map(commander -> commander.moveToZone(Zone.COMMAND, source.getId(), game, true)) Zone.COMMAND, source, game);
.reduce(true, Boolean::logicalAnd);
} }
} }

View file

@ -1,5 +1,7 @@
package mage.players; package mage.players;
import java.io.Serializable;
import java.util.*;
import mage.MageItem; import mage.MageItem;
import mage.MageObject; import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
@ -38,9 +40,6 @@ import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.util.Copyable; import mage.util.Copyable;
import java.io.Serializable;
import java.util.*;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
@ -75,7 +74,7 @@ public interface Player extends MageItem, Copyable<Player> {
void setLife(int life, Game game, UUID sourceId); void setLife(int life, Game game, UUID sourceId);
/** /**
* @param amount amount of life loss * @param amount amount of life loss
* @param game * @param game
* @param atCombat was the source combat damage * @param atCombat was the source combat damage
* @return * @return
@ -344,7 +343,7 @@ public interface Player extends MageItem, Copyable<Player> {
* @param source * @param source
* @param game * @param game
* @param targetPlayerId player whose library will be searched * @param targetPlayerId player whose library will be searched
* @param triggerEvents whether searching will trigger any game events * @param triggerEvents whether searching will trigger any game events
* @return true if search was successful * @return true if search was successful
*/ */
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents); boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents);
@ -365,23 +364,23 @@ public interface Player extends MageItem, Copyable<Player> {
/** /**
* Plays a card if possible * Plays a card if possible
* *
* @param card the card that can be cast * @param card the card that can be cast
* @param game * @param game
* @param noMana if it's a spell i can be cast without paying mana * @param noMana if it's a spell i can be cast without paying mana
* @param ignoreTiming if it's cast during the resolution of another spell * @param ignoreTiming if it's cast during the resolution of another spell
* no sorcery or play land timing restriction are checked. For a land it has * no sorcery or play land timing restriction are checked. For a land it has
* to be the turn of the player playing that card. * to be the turn of the player playing that card.
* @param reference mage object that allows to play the card * @param reference mage object that allows to play the card
* @return * @return
*/ */
boolean playCard(Card card, Game game, boolean noMana, boolean ignoreTiming, MageObjectReference reference); boolean playCard(Card card, Game game, boolean noMana, boolean ignoreTiming, MageObjectReference reference);
/** /**
* @param card the land card to play * @param card the land card to play
* @param game * @param game
* @param ignoreTiming false - it won't be checked if the stack is empty and * @param ignoreTiming false - it won't be checked if the stack is empty and
* you are able to play a Sorcery. It's still checked, if you are able to * you are able to play a Sorcery. It's still checked, if you are able to
* play a land concerning the number of lands you already played. * play a land concerning the number of lands you already played.
* @return * @return
*/ */
boolean playLand(Card card, Game game, boolean ignoreTiming); boolean playLand(Card card, Game game, boolean ignoreTiming);
@ -457,7 +456,8 @@ public interface Player extends MageItem, Copyable<Player> {
* Adds the cards to the reveal window and adds the source object's id name * Adds the cards to the reveal window and adds the source object's id name
* to the title bar of the revealed cards window * to the title bar of the revealed cards window
* <p> * <p>
* Warning, if you use it from continuous effect, then check with extra call isCanLookAtNextTopLibraryCard * Warning, if you use it from continuous effect, then check with extra call
* isCanLookAtNextTopLibraryCard
* *
* @param source * @param source
* @param name * @param name
@ -475,7 +475,8 @@ public interface Player extends MageItem, Copyable<Player> {
* Adds the cards to the look window and adds the source object's id name to * Adds the cards to the look window and adds the source object's id name to
* the title bar of the lookedAt window * the title bar of the lookedAt window
* <p> * <p>
* Warning, if you use it from continuous effect, then check with extra call isCanLookAtNextTopLibraryCard * Warning, if you use it from continuous effect, then check with extra call
* isCanLookAtNextTopLibraryCard
* *
* @param source * @param source
* @param name * @param name
@ -528,11 +529,11 @@ public interface Player extends MageItem, Copyable<Player> {
/** /**
* Moves the cards from cards to the bottom of the players library. * Moves the cards from cards to the bottom of the players library.
* *
* @param cards - list of cards that have to be moved * @param cards - list of cards that have to be moved
* @param game - game * @param game - game
* @param anyOrder - true if player can determine the order of the cards * @param anyOrder - true if player can determine the order of the cards
* else random order * else random order
* @param source - source ability * @param source - source ability
* @return * @return
*/ */
boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder); boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
@ -553,10 +554,10 @@ public interface Player extends MageItem, Copyable<Player> {
/** /**
* Moves the cards from cards to the top of players library. * Moves the cards from cards to the top of players library.
* *
* @param cards - list of cards that have to be moved * @param cards - list of cards that have to be moved
* @param game - game * @param game - game
* @param anyOrder - true if player can determine the order of the cards * @param anyOrder - true if player can determine the order of the cards
* @param source - source ability * @param source - source ability
* @return * @return
*/ */
boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder); boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
@ -587,8 +588,8 @@ public interface Player extends MageItem, Copyable<Player> {
/** /**
* Choose the order in which blockers get damage assigned to * Choose the order in which blockers get damage assigned to
* *
* @param blockers list of blockers where to choose the next one from * @param blockers list of blockers where to choose the next one from
* @param combatGroup the concerning combat group * @param combatGroup the concerning combat group
* @param blockerOrder the already set order of blockers * @param blockerOrder the already set order of blockers
* @param game * @param game
* @return blocker next to add to the blocker order * @return blocker next to add to the blocker order
@ -658,7 +659,7 @@ public interface Player extends MageItem, Copyable<Player> {
* @param card * @param card
* @param game * @param game
* @param abilitiesToActivate extra info about abilities that can be * @param abilitiesToActivate extra info about abilities that can be
* activated on NO option * activated on NO option
* @return player looked at the card * @return player looked at the card
*/ */
boolean lookAtFaceDownCard(Card card, Game game, int abilitiesToActivate); boolean lookAtFaceDownCard(Card card, Game game, int abilitiesToActivate);
@ -731,11 +732,11 @@ public interface Player extends MageItem, Copyable<Player> {
* @param toZone * @param toZone
* @param source * @param source
* @param game * @param game
* @param tapped the cards are tapped on the battlefield * @param tapped the cards are tapped on the battlefield
* @param faceDown the cards are face down in the to zone * @param faceDown the cards are face down in the to zone
* @param byOwner the card is moved (or put onto battlefield) by the owner * @param byOwner the card is moved (or put onto battlefield) by the owner
* of the card and if target zone is battlefield controls the permanent * of the card and if target zone is battlefield controls the permanent
* (instead of the controller of the source) * (instead of the controller of the source)
* @param appliedEffects * @param appliedEffects
* @return * @return
*/ */
@ -771,7 +772,7 @@ public interface Player extends MageItem, Copyable<Player> {
* list of applied effects is not saved * list of applied effects is not saved
* *
* @param card * @param card
* @param exileId exile zone id (optional) * @param exileId exile zone id (optional)
* @param exileName name of exile zone (optional) * @param exileName name of exile zone (optional)
* @param sourceId * @param sourceId
* @param game * @param game
@ -813,12 +814,24 @@ public interface Player extends MageItem, Copyable<Player> {
* @param sourceId * @param sourceId
* @param game * @param game
* @param fromZone if null, this info isn't postet * @param fromZone if null, this info isn't postet
* @param toTop to the top of the library else to the bottom * @param toTop to the top of the library else to the bottom
* @param withName show the card name in the log * @param withName show the card name in the log
* @return * @return
*/ */
boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName); boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName);
/**
* Uses card.moveToZone and posts a inform message about moving the card to
* library into the game log
*
* @param card
* @param sourceId
* @param game
* @param fromZone if null, this info isn't postet
* @return
*/
boolean moveCardToCommandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone);
/** /**
* Checks if the playerToCheckId is from an opponent in range * Checks if the playerToCheckId is from an opponent in range
* *
@ -838,10 +851,10 @@ public interface Player extends MageItem, Copyable<Player> {
* without mana (null) or the mana set to manaCosts instead of its normal * without mana (null) or the mana set to manaCosts instead of its normal
* mana costs. * mana costs.
* *
* @param sourceId the source that can be cast without mana * @param sourceId the source that can be cast without mana
* @param manaCosts alternate ManaCost, null if it can be cast without mana * @param manaCosts alternate ManaCost, null if it can be cast without mana
* cost * cost
* @param costs alternate other costs you need to pay * @param costs alternate other costs you need to pay
*/ */
void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts<ManaCost> manaCosts, Costs<Cost> costs); void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts<ManaCost> manaCosts, Costs<Cost> costs);

View file

@ -1,6 +1,9 @@
package mage.players; package mage.players;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import mage.ConditionalMana; import mage.ConditionalMana;
import mage.MageObject; import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
@ -65,10 +68,6 @@ import mage.util.GameLog;
import mage.util.RandomUtil; import mage.util.RandomUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
public abstract class PlayerImpl implements Player, Serializable { public abstract class PlayerImpl implements Player, Serializable {
private static final Logger logger = Logger.getLogger(PlayerImpl.class); private static final Logger logger = Logger.getLogger(PlayerImpl.class);
@ -614,7 +613,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (abilities.containsKey(HexproofAbility.getInstance().getId())) { if (abilities.containsKey(HexproofAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game) if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(), && null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)) { AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)) {
return false; return false;
} }
} }
@ -622,7 +621,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (abilities.containsKey(HexproofFromWhiteAbility.getInstance().getId())) { if (abilities.containsKey(HexproofFromWhiteAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game) if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(), && null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game) AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& source.getColor(game).isWhite()) { && source.getColor(game).isWhite()) {
return false; return false;
} }
@ -631,7 +630,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (abilities.containsKey(HexproofFromBlueAbility.getInstance().getId())) { if (abilities.containsKey(HexproofFromBlueAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game) if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(), && null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game) AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& source.getColor(game).isBlue()) { && source.getColor(game).isBlue()) {
return false; return false;
} }
@ -640,7 +639,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (abilities.containsKey(HexproofFromBlackAbility.getInstance().getId())) { if (abilities.containsKey(HexproofFromBlackAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game) if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(), && null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game) AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& source.getColor(game).isBlack()) { && source.getColor(game).isBlack()) {
return false; return false;
} }
@ -649,7 +648,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (abilities.containsKey(HexproofFromMonocoloredAbility.getInstance().getId())) { if (abilities.containsKey(HexproofFromMonocoloredAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game) if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(), && null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game) AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& !source.getColor(game).isColorless() && !source.getColor(game).isColorless()
&& !source.getColor(game).isMulticolored()) { && !source.getColor(game).isMulticolored()) {
return false; return false;
@ -692,7 +691,7 @@ public abstract class PlayerImpl implements Player, Serializable {
game.informPlayers(getLogName() + " discards down to " game.informPlayers(getLogName() + " discards down to "
+ this.maxHandSize + this.maxHandSize
+ (this.maxHandSize == 1 + (this.maxHandSize == 1
? " hand card" : " hand cards")); ? " hand card" : " hand cards"));
} }
discard(hand.size() - this.maxHandSize, false, null, game); discard(hand.size() - this.maxHandSize, false, null, game);
} }
@ -800,7 +799,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (card != null) { if (card != null) {
GameEvent gameEvent = GameEvent.getEvent(GameEvent.EventType.DISCARD_CARD, GameEvent gameEvent = GameEvent.getEvent(GameEvent.EventType.DISCARD_CARD,
card.getId(), source == null card.getId(), source == null
? null : source.getSourceId(), playerId); ? null : source.getSourceId(), playerId);
gameEvent.setFlag(source != null); // event from effect or from cost (source == null) gameEvent.setFlag(source != null); // event from effect or from cost (source == null)
if (!game.replaceEvent(gameEvent, source)) { if (!game.replaceEvent(gameEvent, source)) {
// write info to game log first so game log infos from triggered or replacement effects follow in the game log // write info to game log first so game log infos from triggered or replacement effects follow in the game log
@ -815,7 +814,7 @@ public abstract class PlayerImpl implements Player, Serializable {
// So discard is also successful if card is moved to another zone by replacement effect! // So discard is also successful if card is moved to another zone by replacement effect!
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD,
card.getId(), source == null card.getId(), source == null
? null : source.getSourceId(), playerId)); ? null : source.getSourceId(), playerId));
return true; return true;
} }
} }
@ -1503,7 +1502,7 @@ public abstract class PlayerImpl implements Player, Serializable {
// Also called on the whole split card but only passing the fuse ability and other whole-split-card shared abilities // Also called on the whole split card but only passing the fuse ability and other whole-split-card shared abilities
// as candidates. // as candidates.
private void getUseableActivatedAbilitiesHalfImpl(MageObject object, Zone zone, Game game, Abilities<Ability> candidateAbilites, private void getUseableActivatedAbilitiesHalfImpl(MageObject object, Zone zone, Game game, Abilities<Ability> candidateAbilites,
LinkedHashMap<UUID, ActivatedAbility> output) { LinkedHashMap<UUID, ActivatedAbility> output) {
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game); boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
ManaOptions availableMana = null; ManaOptions availableMana = null;
// ManaOptions availableMana = getManaAvailable(game); // can only be activated if mana calculation works flawless otherwise player can't play spells they could play if calculation would work correctly // ManaOptions availableMana = getManaAvailable(game); // can only be activated if mana calculation works flawless otherwise player can't play spells they could play if calculation would work correctly
@ -1555,10 +1554,10 @@ public abstract class PlayerImpl implements Player, Serializable {
!= null != null
// if anyone sees an issue with this code, please report it. Worked in my testing. ! // if anyone sees an issue with this code, please report it. Worked in my testing. !
|| game.getContinuousEffects().asThough(object.getId(), || game.getContinuousEffects().asThough(object.getId(),
AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE,
ability, ability,
this.getId(), this.getId(),
game) game)
!= null) { != null) {
if (canUse if (canUse
|| ability.getAbilityType() == AbilityType.SPECIAL_ACTION) { || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
@ -1916,9 +1915,9 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
private List<Permanent> getPermanentsThatCanBeUntapped(Game game, private List<Permanent> getPermanentsThatCanBeUntapped(Game game,
List<Permanent> canBeUntapped, List<Permanent> canBeUntapped,
RestrictionUntapNotMoreThanEffect handledEffect, RestrictionUntapNotMoreThanEffect handledEffect,
Map<Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>>, Integer> notMoreThanEffectsUsage) { Map<Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>>, Integer> notMoreThanEffectsUsage) {
List<Permanent> leftForUntap = new ArrayList<>(); List<Permanent> leftForUntap = new ArrayList<>();
// select permanents that can still be untapped // select permanents that can still be untapped
for (Permanent permanent : canBeUntapped) { for (Permanent permanent : canBeUntapped) {
@ -2626,7 +2625,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, public boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId,
boolean triggerEvents) { boolean triggerEvents) {
//20091005 - 701.14c //20091005 - 701.14c
Library searchedLibrary = null; Library searchedLibrary = null;
String searchInfo = null; String searchInfo = null;
@ -2830,7 +2829,7 @@ public abstract class PlayerImpl implements Player, Serializable {
/** /**
* @param game * @param game
* @param appliedEffects * @param appliedEffects
* @param numSides Number of sides the dice has * @param numSides Number of sides the dice has
* @return the number that the player rolled * @return the number that the player rolled
*/ */
@Override @Override
@ -2867,16 +2866,16 @@ public abstract class PlayerImpl implements Player, Serializable {
/** /**
* @param game * @param game
* @param appliedEffects * @param appliedEffects
* @param numberChaosSides The number of chaos sides the planar die * @param numberChaosSides The number of chaos sides the planar die
* currently has (normally 1 but can be 5) * currently has (normally 1 but can be 5)
* @param numberPlanarSides The number of chaos sides the planar die * @param numberPlanarSides The number of chaos sides the planar die
* currently has (normally 1) * currently has (normally 1)
* @return the outcome that the player rolled. Either ChaosRoll, PlanarRoll * @return the outcome that the player rolled. Either ChaosRoll, PlanarRoll
* or NilRoll * or NilRoll
*/ */
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides, public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides,
int numberPlanarSides) { int numberPlanarSides) {
int result = RandomUtil.nextInt(9) + 1; int result = RandomUtil.nextInt(9) + 1;
PlanarDieRoll roll = PlanarDieRoll.NIL_ROLL; PlanarDieRoll roll = PlanarDieRoll.NIL_ROLL;
if (numberChaosSides + numberPlanarSides > 9) { if (numberChaosSides + numberPlanarSides > 9) {
@ -3033,7 +3032,7 @@ public abstract class PlayerImpl implements Player, Serializable {
/** /**
* @param ability * @param ability
* @param available if null, it won't be checked if enough mana is available * @param available if null, it won't be checked if enough mana is available
* @param sourceObject * @param sourceObject
* @param game * @param game
* @return * @return
@ -3281,7 +3280,6 @@ public abstract class PlayerImpl implements Player, Serializable {
boolean isPlayLand = (ability instanceof PlayLandAbility); boolean isPlayLand = (ability instanceof PlayLandAbility);
// as original controller // as original controller
// land restrictions // land restrictions
if (isPlayLand && game.getContinuousEffects().preventedByRuleModification( if (isPlayLand && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(),
@ -3355,8 +3353,8 @@ public abstract class PlayerImpl implements Player, Serializable {
if (ability instanceof ActivatedAbility) { if (ability instanceof ActivatedAbility) {
if (!(ability instanceof PlayLandAbility) if (!(ability instanceof PlayLandAbility)
|| !game.getContinuousEffects().preventedByRuleModification( || !game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(),
ability.getSourceId(), playerId), ability, game, true)) { ability.getSourceId(), playerId), ability, game, true)) {
if (canPlay((ActivatedAbility) ability, availableMana, card, game)) { if (canPlay((ActivatedAbility) ability, availableMana, card, game)) {
playable.add(ability); playable.add(ability);
} }
@ -3681,7 +3679,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean canPaySacrificeCost(Permanent permanent, UUID sourceId, public boolean canPaySacrificeCost(Permanent permanent, UUID sourceId,
UUID controllerId, Game game UUID controllerId, Game game
) { ) {
return sacrificeCostFilter == null || !sacrificeCostFilter.match(permanent, sourceId, controllerId, game); return sacrificeCostFilter == null || !sacrificeCostFilter.match(permanent, sourceId, controllerId, game);
} }
@ -3834,8 +3832,8 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCards(Card card, Zone toZone, public boolean moveCards(Card card, Zone toZone,
Ability source, Game game, Ability source, Game game,
boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects
) { ) {
Set<Card> cardList = new HashSet<>(); Set<Card> cardList = new HashSet<>();
if (card != null) { if (card != null) {
@ -3846,22 +3844,22 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCards(Cards cards, Zone toZone, public boolean moveCards(Cards cards, Zone toZone,
Ability source, Game game Ability source, Game game
) { ) {
return moveCards(cards.getCards(game), toZone, source, game); return moveCards(cards.getCards(game), toZone, source, game);
} }
@Override @Override
public boolean moveCards(Set<Card> cards, Zone toZone, public boolean moveCards(Set<Card> cards, Zone toZone,
Ability source, Game game Ability source, Game game
) { ) {
return moveCards(cards, toZone, source, game, false, false, false, null); return moveCards(cards, toZone, source, game, false, false, false, null);
} }
@Override @Override
public boolean moveCards(Set<Card> cards, Zone toZone, public boolean moveCards(Set<Card> cards, Zone toZone,
Ability source, Game game, Ability source, Game game,
boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects
) { ) {
if (cards.isEmpty()) { if (cards.isEmpty()) {
return true; return true;
@ -3937,6 +3935,13 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
} }
break; break;
case COMMAND:
for (Card card : cards) {
if (moveCardToCommandWithInfo(card, source.getSourceId(), game, fromZone)) {
successfulMovedCards.add(card);
}
}
break;
case OUTSIDE: case OUTSIDE:
for (Card card : cards) { for (Card card : cards) {
if (card instanceof Permanent) { if (card instanceof Permanent) {
@ -3956,8 +3961,8 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardsToExile(Card card, Ability source, public boolean moveCardsToExile(Card card, Ability source,
Game game, boolean withName, UUID exileId, Game game, boolean withName, UUID exileId,
String exileZoneName String exileZoneName
) { ) {
Set<Card> cards = new HashSet<>(); Set<Card> cards = new HashSet<>();
cards.add(card); cards.add(card);
@ -3966,8 +3971,8 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardsToExile(Set<Card> cards, Ability source, public boolean moveCardsToExile(Set<Card> cards, Ability source,
Game game, boolean withName, UUID exileId, Game game, boolean withName, UUID exileId,
String exileZoneName String exileZoneName
) { ) {
if (cards.isEmpty()) { if (cards.isEmpty()) {
return true; return true;
@ -3983,14 +3988,14 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, public boolean moveCardToHandWithInfo(Card card, UUID sourceId,
Game game Game game
) { ) {
return this.moveCardToHandWithInfo(card, sourceId, game, true); return this.moveCardToHandWithInfo(card, sourceId, game, true);
} }
@Override @Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, public boolean moveCardToHandWithInfo(Card card, UUID sourceId,
Game game, boolean withName Game game, boolean withName
) { ) {
boolean result = false; boolean result = false;
Zone fromZone = game.getState().getZone(card.getId()); Zone fromZone = game.getState().getZone(card.getId());
@ -4015,7 +4020,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public Set<Card> moveCardsToGraveyardWithInfo(Set<Card> allCards, Ability source, public Set<Card> moveCardsToGraveyardWithInfo(Set<Card> allCards, Ability source,
Game game, Zone fromZone Game game, Zone fromZone
) { ) {
UUID sourceId = source == null ? null : source.getSourceId(); UUID sourceId = source == null ? null : source.getSourceId();
Set<Card> movedCards = new LinkedHashSet<>(); Set<Card> movedCards = new LinkedHashSet<>();
@ -4023,7 +4028,7 @@ public abstract class PlayerImpl implements Player, Serializable {
// identify cards from one owner // identify cards from one owner
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
UUID ownerId = null; UUID ownerId = null;
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) { for (Iterator<Card> it = allCards.iterator(); it.hasNext();) {
Card card = it.next(); Card card = it.next();
if (cards.isEmpty()) { if (cards.isEmpty()) {
ownerId = card.getOwnerId(); ownerId = card.getOwnerId();
@ -4086,7 +4091,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId,
Game game, Zone fromZone Game game, Zone fromZone
) { ) {
if (card == null) { if (card == null) {
return false; return false;
@ -4115,8 +4120,8 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, public boolean moveCardToLibraryWithInfo(Card card, UUID sourceId,
Game game, Zone fromZone, Game game, Zone fromZone,
boolean toTop, boolean withName boolean toTop, boolean withName
) { ) {
if (card == null) { if (card == null) {
return false; return false;
@ -4148,9 +4153,40 @@ public abstract class PlayerImpl implements Player, Serializable {
return result; return result;
} }
@Override
public boolean moveCardToCommandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
if (card == null) {
return false;
}
boolean result = false;
if (card.moveToZone(Zone.COMMAND, sourceId, game, true)) {
if (!game.isSimulation()) {
if (card instanceof PermanentCard && game.getCard(card.getId()) != null) {
card = game.getCard(card.getId());
}
StringBuilder sb = new StringBuilder(this.getLogName())
.append(" puts ").append(card.getLogName()).append(' ');
if (fromZone != null) {
sb.append("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(' ');
}
if (card.isOwnedBy(getId())) {
sb.append(" to his or her command zone");
} else {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
sb.append(" to ").append(player.getLogName()).append("'s command zone");
}
}
game.informPlayers(sb.toString());
}
result = true;
}
return result;
}
@Override @Override
public boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId, public boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId,
Game game, Zone fromZone, boolean withName) { Game game, Zone fromZone, boolean withName) {
if (card == null) { if (card == null) {
return false; return false;
} }
@ -4173,7 +4209,7 @@ public abstract class PlayerImpl implements Player, Serializable {
game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName() game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName()
+ (card.isCopy() ? " (Copy)" : "") : "a card face down") + ' ' + (card.isCopy() ? " (Copy)" : "") : "a card face down") + ' '
+ (fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + (fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH)
+ ' ' : "") + "to the exile zone"); + ' ' : "") + "to the exile zone");
} }
result = true; result = true;