* Some more fixed/reworked card movement handling.

This commit is contained in:
LevelX2 2018-05-11 00:52:09 +02:00
parent 7d7b13d5dd
commit 75c8ee35f6
95 changed files with 969 additions and 2192 deletions

View file

@ -35,7 +35,6 @@ import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
@ -150,6 +149,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
FilterCard pickFilter, Zone targetZoneLookedCards, boolean putOnTop,
boolean reveal, boolean upTo, Zone targetZonePickedCards,
boolean optional) {
this(numberOfCards, mayShuffleAfter, numberToPick, pickFilter,
targetZoneLookedCards, putOnTop, reveal, upTo,
targetZonePickedCards, optional, true, true);
@ -207,16 +207,10 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
}
@Override
protected void cardLooked(Card card, Game game, Ability source) {
if (numberToPick.calculate(game, source, this) > 0 && filter.match(card, game)) {
++foundCardsToPick;
}
}
@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && foundCardsToPick > 0) {
if (player != null && numberToPick.calculate(game, source, this) > 0
&& cards.count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), source, game)) {
FilterCard pickFilter = filter.copy();
pickFilter.setMessage(getPickText());
@ -231,7 +225,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
player.moveCards(pickedCards.getCards(game), targetPickedCards, source, game);
}
if (revealPickedCards) {
player.revealCards(windowName, pickedCards, game);
player.revealCards(source, pickedCards, game);
}
}
@ -346,7 +340,14 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
}
sb.append(" order");
} else if (targetZoneLookedCards == Zone.GRAVEYARD) {
sb.append(" and the other into your graveyard");
sb.append(" and the");
if (numberOfCards instanceof StaticValue && numberToPick instanceof StaticValue
&& ((StaticValue) numberToPick).getValue() + 1 == ((StaticValue) numberOfCards).getValue()) {
sb.append(" other");
} else {
sb.append(" rest");
}
sb.append(" into your graveyard");
}
}
// get text frame from super class and inject action text

View file

@ -29,18 +29,15 @@ package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
@ -105,46 +102,25 @@ public class LookLibraryControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
String windowName = "Reveal";
if (source instanceof SpellAbility) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) {
windowName = sourceCard.getIdName();
}
} else {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
windowName = sourcePermanent.getIdName();
}
}
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// take cards from library and look at them
boolean topCardRevealed = player.isTopCardRevealed();
player.setTopCardRevealed(false);
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), this.numberOfCards.calculate(game, source, this));
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
this.cardLooked(card, game, source);
}
}
player.lookAtCards(windowName, cards, game);
boolean topCardRevealed = controller.isTopCardRevealed();
controller.setTopCardRevealed(false);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, this.numberOfCards.calculate(game, source, this)));
this.actionWithSelectedCards(cards, game, source, windowName);
controller.lookAtCards(source, null, cards, game);
this.putCardsBack(source, player, cards, game);
this.actionWithSelectedCards(cards, game, source);
player.setTopCardRevealed(topCardRevealed);
this.putCardsBack(source, controller, cards, game);
this.mayShuffle(player, source, game);
controller.setTopCardRevealed(topCardRevealed);
this.mayShuffle(controller, source, game);
return true;
}
@ -158,10 +134,7 @@ public class LookLibraryControllerEffect extends OneShotEffect {
return this;
}
protected void cardLooked(Card card, Game game, Ability source) {
}
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
}
/**

View file

@ -58,7 +58,7 @@ public class CantBeBlockedByAllSourceEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return source.getSourceId().equals(permanent.getId());
return permanent.equals(source.getSourcePermanentIfItStillExists(game));
}
@Override

View file

@ -109,6 +109,13 @@ public final class StaticFilters {
static {
FILTER_PERMANENT.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_ARTIFACT_AN = new FilterArtifactPermanent("an artifact");
static {
FILTER_PERMANENT_ARTIFACT_AN.setLockedFilter(true);
}
public static final FilterArtifactOrEnchantmentPermanent FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT = new FilterArtifactOrEnchantmentPermanent();
static {