From eeb938af94596d98fda9beac2cf6e602899100aa Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 7 Feb 2018 14:24:17 +0100 Subject: [PATCH] * Fixed a bug that could lock the game if you should pick more cards from shown cards from your library than cards left in your library (e.g. Dig Through Time). --- .../effects/common/LookLibraryAndPickControllerEffect.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java index 99958198d35..359666cd8d0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java @@ -29,6 +29,7 @@ */ package mage.abilities.effects.common; +import static java.lang.Integer.min; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.dynamicvalue.DynamicValue; @@ -186,7 +187,8 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), source, game)) { FilterCard pickFilter = filter.copy(); pickFilter.setMessage(getPickText()); - TargetCard target = new TargetCard((upTo ? 0 : numberToPick.calculate(game, source, this)), numberToPick.calculate(game, source, this), Zone.LIBRARY, pickFilter); + int number = min(cards.size(), numberToPick.calculate(game, source, this)); + TargetCard target = new TargetCard((upTo ? 0 : number), number, Zone.LIBRARY, pickFilter); if (player.choose(Outcome.DrawCard, cards, target, game)) { Cards pickedCards = new CardsImpl(target.getTargets()); cards.removeAll(pickedCards);