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

View file

@ -1,5 +1,7 @@
package mage.players;
import java.io.Serializable;
import java.util.*;
import mage.MageItem;
import mage.MageObject;
import mage.MageObjectReference;
@ -38,9 +40,6 @@ import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import mage.util.Copyable;
import java.io.Serializable;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -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
* to the title bar of the revealed cards window
* <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 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
* the title bar of the lookedAt window
* <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 name
@ -819,6 +820,18 @@ public interface Player extends MageItem, Copyable<Player> {
*/
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
*

View file

@ -1,6 +1,9 @@
package mage.players;
import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import mage.ConditionalMana;
import mage.MageObject;
import mage.MageObjectReference;
@ -65,10 +68,6 @@ import mage.util.GameLog;
import mage.util.RandomUtil;
import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
public abstract class PlayerImpl implements Player, Serializable {
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
@ -3281,7 +3280,6 @@ public abstract class PlayerImpl implements Player, Serializable {
boolean isPlayLand = (ability instanceof PlayLandAbility);
// as original controller
// land restrictions
if (isPlayLand && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(),
@ -3937,6 +3935,13 @@ public abstract class PlayerImpl implements Player, Serializable {
}
}
break;
case COMMAND:
for (Card card : cards) {
if (moveCardToCommandWithInfo(card, source.getSourceId(), game, fromZone)) {
successfulMovedCards.add(card);
}
}
break;
case OUTSIDE:
for (Card card : cards) {
if (card instanceof Permanent) {
@ -4023,7 +4028,7 @@ public abstract class PlayerImpl implements Player, Serializable {
// identify cards from one owner
Cards cards = new CardsImpl();
UUID ownerId = null;
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) {
for (Iterator<Card> it = allCards.iterator(); it.hasNext();) {
Card card = it.next();
if (cards.isEmpty()) {
ownerId = card.getOwnerId();
@ -4148,6 +4153,37 @@ public abstract class PlayerImpl implements Player, Serializable {
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
public boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId,
Game game, Zone fromZone, boolean withName) {