* Thoughtpicker Witch - Fixed a bug that could produce a null pointer exception.

This commit is contained in:
LevelX2 2016-11-06 23:18:47 +01:00
parent 618ee3698b
commit 964bf63524

View file

@ -104,19 +104,15 @@ class ThoughtpickerWitchEffect extends OneShotEffect {
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller != null && opponent != null) {
Cards cards = new CardsImpl();
int numLooked = Math.min(2, opponent.getLibrary().size());
if (numLooked > 0) {
for (int i = 0; i < numLooked; i++) {
cards.add(opponent.getLibrary().removeFromTop(game));
}
cards.addAll(opponent.getLibrary().getTopCards(game, 2));
if (cards.size() > 0) {
TargetCard target = new TargetCardInLibrary(new FilterCard("card to exile"));
controller.choose(Outcome.Exile, cards, target, game);
if (controller.choose(Outcome.Exile, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
opponent.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
if (cards.size() == 1) {
card = cards.get(cards.iterator().next(), game);
opponent.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, true, false);
opponent.moveCards(card, Zone.EXILED, source, game);
}
}
}
return true;