mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
moved shuffle to Player, deprecated GameAction.shuffle, and redirected to Player
This commit is contained in:
@@ -2469,7 +2469,10 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: shuffling seems to change a card's unique number but i'm not 100% sure
|
//TODO: shuffling seems to change a card's unique number but i'm not 100% sure
|
||||||
|
@Deprecated
|
||||||
public void shuffle(Player player) {
|
public void shuffle(Player player) {
|
||||||
|
player.shuffle();
|
||||||
|
/*
|
||||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
|
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
|
||||||
Card c[] = library.getCards();
|
Card c[] = library.getCards();
|
||||||
|
|
||||||
@@ -2485,8 +2488,6 @@ public class GameAction {
|
|||||||
Collections.shuffle(list, random);
|
Collections.shuffle(list, random);
|
||||||
Collections.shuffle(list, random);
|
Collections.shuffle(list, random);
|
||||||
|
|
||||||
// random = java.security.SecureRandom.getInstance("SHA1PRNG");
|
|
||||||
|
|
||||||
Object o;
|
Object o;
|
||||||
for(int i = 0; i < list.size(); i++) {
|
for(int i = 0; i < list.size(); i++) {
|
||||||
o = list.remove(random.nextInt(list.size()));
|
o = list.remove(random.nextInt(list.size()));
|
||||||
@@ -2503,6 +2504,7 @@ public class GameAction {
|
|||||||
|
|
||||||
list.toArray(c);
|
list.toArray(c);
|
||||||
library.setCards(c);
|
library.setCards(c);
|
||||||
|
*/
|
||||||
}//shuffle
|
}//shuffle
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Player extends MyObservable{
|
public abstract class Player extends MyObservable{
|
||||||
@@ -304,6 +307,42 @@ public abstract class Player extends MyObservable{
|
|||||||
|
|
||||||
throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " + c.getName());
|
throw new RuntimeException("Input_Draw : getDredgeNumber() card doesn't have dredge - " + c.getName());
|
||||||
}//getDredgeNumber()
|
}//getDredgeNumber()
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
public void shuffle() {
|
||||||
|
PlayerZone library = AllZone.getZone(Constant.Zone.Library, this);
|
||||||
|
Card c[] = library.getCards();
|
||||||
|
|
||||||
|
if(c.length <= 1) return;
|
||||||
|
|
||||||
|
ArrayList<Object> list = new ArrayList<Object>(Arrays.asList(c));
|
||||||
|
//overdone but wanted to make sure it was really random
|
||||||
|
Random random = new Random();
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
|
||||||
|
Object o;
|
||||||
|
for(int i = 0; i < list.size(); i++) {
|
||||||
|
o = list.remove(random.nextInt(list.size()));
|
||||||
|
list.add(random.nextInt(list.size()), o);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
Collections.shuffle(list, random);
|
||||||
|
|
||||||
|
|
||||||
|
list.toArray(c);
|
||||||
|
library.setCards(c);
|
||||||
|
}//shuffle
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user