[MOR] fixed Knowledge Exploitation not working (fixes #7646)

This commit is contained in:
Evan Kranzler 2021-03-04 14:20:33 -05:00
parent 4a3679285e
commit b1da4d4d79

View file

@ -1,6 +1,5 @@
package mage.cards.k;
import java.util.UUID;
import mage.ApprovingObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -11,14 +10,15 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterInstantOrSorceryCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class KnowledgeExploitation extends CardImpl {
@ -57,7 +57,7 @@ class KnowledgeExploitationEffect extends OneShotEffect {
+ "player shuffles their library";
}
KnowledgeExploitationEffect(final KnowledgeExploitationEffect effect) {
private KnowledgeExploitationEffect(final KnowledgeExploitationEffect effect) {
super(effect);
}
@ -69,21 +69,24 @@ class KnowledgeExploitationEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller != null && opponent != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterInstantOrSorceryCard());
if (controller.searchLibrary(target, source, game, opponent.getId())) {
Card card = opponent.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, true),
game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
opponent.shuffleLibrary(source, game);
return true;
Player opponent = game.getPlayer(source.getFirstTarget());
if (controller == null || opponent == null) {
return false;
}
return false;
TargetCardInLibrary target = new TargetCardInLibrary(
0, 1, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY
);
controller.searchLibrary(target, source, game, opponent.getId());
Card card = opponent.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(
controller.chooseAbilityForCast(card, game, true),
game, true, new ApprovingObject(source, game)
);
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
opponent.shuffleLibrary(source, game);
return true;
}
}