Fixed shuffle algorithm.
*/
package mage.players;
+import java.io.Serializable;
+import java.util.*;
+import java.util.stream.Collectors;
import mage.cards.Card;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.util.RandomUtil;
-import java.io.Serializable;
-import java.util.*;
-import java.util.stream.Collectors;
-
/**
* @author BetaSteward_at_googlemail.com
*/
@@ -64,7 +63,7 @@ public class Library implements Serializable {
public void shuffle() {
UUID[] shuffled = library.toArray(new UUID[0]);
for (int n = shuffled.length - 1; n > 0; n--) {
- int r = RandomUtil.nextInt(n);
+ int r = RandomUtil.nextInt(n + 1);
UUID temp = shuffled[n];
shuffled[n] = shuffled[r];
shuffled[r] = temp;
@@ -235,7 +234,6 @@ public class Library implements Serializable {
return null;
}
-
public boolean hasCards() {
return size() > 0;
}
