v0.6.0: moved important usages of collections.shuffle into Random

This commit is contained in:
Evan Debenham 2017-04-14 04:55:26 -04:00 committed by Evan Debenham
parent 75f9cd454b
commit 048b5e5f7b
4 changed files with 10 additions and 4 deletions

View File

@ -22,7 +22,9 @@
package com.watabou.utils;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class Random {
@ -156,6 +158,10 @@ public class Random {
(T)collection.toArray()[Int( size )] :
null;
}
public static<T> void shuffle( List<?extends T> list){
Collections.shuffle(list, rand);
}
public static<T> void shuffle( T[] array ) {
for (int i=0; i < array.length - 1; i++) {

View File

@ -74,7 +74,7 @@ public abstract class RegularLevel extends Level {
ArrayList<Room> initRooms = initRooms();
Collections.shuffle(initRooms);
Random.shuffle(initRooms);
do {
for (Room r : initRooms){
@ -340,7 +340,7 @@ public abstract class RegularLevel extends Level {
}
protected Room randomRoom( Class<?extends Room> type ) {
Collections.shuffle( rooms );
Random.shuffle( rooms );
for (Room r : rooms) {
if (type.isInstance(r)
//compatibility with pre-0.6.0 saves

View File

@ -274,7 +274,7 @@ public class ShopRoom extends SpecialRoom {
if (itemsToSpawn.size() > 63)
throw new RuntimeException("Shop attempted to carry more than 63 items!");
Collections.shuffle(itemsToSpawn);
Random.shuffle(itemsToSpawn);
}
private static void ChooseBag(Belongings pack){

View File

@ -85,7 +85,7 @@ public class SpecialRoom extends Room {
}
guaranteedWellDepth = Random.IntRange( 6, 14 );
Collections.shuffle(runSpecials);
Random.shuffle(runSpecials);
}
public static void initForFloor(){