* 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).

This commit is contained in:
LevelX2 2018-02-07 14:24:17 +01:00
parent 557ac244d3
commit eeb938af94

View file

@ -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);