* See the Truth - Fixed some problems of the implementation (#6646).

This commit is contained in:
LevelX2 2020-06-16 10:42:33 +02:00
parent 98feb0dd95
commit 146c9571ca

View file

@ -1,7 +1,6 @@
package mage.cards.s;
import mage.abilities.Ability;
import mage.abilities.condition.common.CastFromHandSourceCondition;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -13,9 +12,10 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
import mage.filter.FilterCard;
import mage.game.stack.Spell;
/**
* @author TheElk801
@ -27,7 +27,6 @@ public final class SeeTheTruth extends CardImpl {
// Look at the top three cards of your library. Put one of those cards into your hand and the rest on the bottom of your library in any order. If this spell was cast from anywhere other than your hand, put each of those cards into your hand instead.
this.getSpellAbility().addEffect(new SeeTheTruthEffect());
this.getSpellAbility().addWatcher(new CastFromHandWatcher());
}
private SeeTheTruth(final SeeTheTruth card) {
@ -44,10 +43,10 @@ class SeeTheTruthEffect extends OneShotEffect {
SeeTheTruthEffect() {
super(Outcome.Benefit);
staticText = "Look at the top three cards of your library. " +
"Put one of those cards into your hand and the rest on the bottom of your library in any order. " +
"If this spell was cast from anywhere other than your hand, " +
"put each of those cards into your hand instead.";
staticText = "Look at the top three cards of your library. "
+ "Put one of those cards into your hand and the rest on the bottom of your library in any order. "
+ "If this spell was cast from anywhere other than your hand, "
+ "put each of those cards into your hand instead.";
}
private SeeTheTruthEffect(final SeeTheTruthEffect effect) {
@ -62,22 +61,22 @@ class SeeTheTruthEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Spell sourceSpell = game.getStack().getSpell(source.getId()); // Use id to get the correct spell in case of copied spells
if (player == null || sourceSpell == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
if (cards.size() < 1) {
return false;
}
if (CastFromHandSourceCondition.instance.apply(game, source)) {
TargetCardInLibrary target = new TargetCardInLibrary();
player.choose(outcome, cards, target, game);
if (!cards.isEmpty()) {
if (sourceSpell.isCopy() || Zone.HAND.equals(sourceSpell.getFromZone())) { // A copied spell was NOT cast at all
TargetCardInLibrary target = new TargetCardInLibrary(new FilterCard("card to put into your hand"));
player.chooseTarget(outcome, cards, target, source, game);
cards.removeIf(target.getFirstTarget()::equals);
player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
} else {
player.moveCards(cards, Zone.HAND, source, game);
}
}
return true;
}
}