mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Move empty init exception into BagRandomizer
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package forge.item.generation;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import forge.card.CardEdition;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.PaperCard;
|
||||
@@ -11,10 +10,7 @@ import java.util.List;
|
||||
public class ChaosBoosterSupplier implements IUnOpenedProduct {
|
||||
private BagRandomizer<CardEdition> randomizer;
|
||||
|
||||
public ChaosBoosterSupplier(Iterable<CardEdition> sets) throws Exception {
|
||||
if (Iterables.size(sets) <= 0) {
|
||||
throw new Exception("At least one set needed to generate chaos draft!");
|
||||
}
|
||||
public ChaosBoosterSupplier(Iterable<CardEdition> sets) throws IllegalArgumentException {
|
||||
randomizer = new BagRandomizer<>(sets);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,22 @@ public class BagRandomizer<T > implements Iterable<T>{
|
||||
private T[] bag;
|
||||
private int currentPosition = 0;
|
||||
|
||||
public BagRandomizer(T[] items) {
|
||||
public BagRandomizer(T[] items) throws IllegalArgumentException {
|
||||
if (items.length == 0) {
|
||||
throw new IllegalArgumentException("Must include at least one item!");
|
||||
}
|
||||
bag = items;
|
||||
shuffleBag();
|
||||
}
|
||||
|
||||
public BagRandomizer(Iterable<T> items) {
|
||||
public BagRandomizer(Iterable<T> items) throws IllegalArgumentException {
|
||||
ArrayList<T> list = new ArrayList<>();
|
||||
for (T item : items) {
|
||||
list.add(item);
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
throw new IllegalArgumentException("Must include at least one item!");
|
||||
}
|
||||
bag = (T[]) list.toArray();
|
||||
shuffleBag();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user