mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
Fixed shuffle algorithm.
This commit is contained in:
parent
c731a10360
commit
d1fd69f685
1 changed files with 4 additions and 6 deletions
|
@ -27,16 +27,15 @@
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue