Implement new way to generate boosters using box mapping info (WIP) (#7529)

* [THB] added initial common/uncommon collation mechanism

* [THB] added rare/mythic and lands to pack generation

* fixed some card names

* broke out collation into its own separate classes

* built collation into ExpansionSet

* added note about collation information

* [KHM] added collation info

* updated collation to use collector number rather than name

* added shuffle to set constructor

* added some notes on collation methods
This commit is contained in:
Evan Kranzler 2021-02-12 17:35:28 -05:00 committed by GitHub
parent 10e557b873
commit 8a16eda062
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 500 additions and 3 deletions

View file

@ -0,0 +1,50 @@
package mage.collation;
import mage.util.RandomUtil;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* A class for shuffling a list by choosing a random starting point and looping through it
*
* @author TheElk801
*/
public class Rotater<T> {
protected final List<T> items;
private final boolean keepOrder;
private int position = 0;
public Rotater(T item) {
this(true, item);
}
public Rotater(T item1, T item2) {
this(true, item1, item2);
}
public Rotater(boolean keepOrder, T... items) {
this.items = Arrays.asList(items);
this.keepOrder = keepOrder;
}
public int iterate() {
int i = position;
position++;
position %= items.size();
return i;
}
public T getNext() {
return items.get(iterate());
}
public void shuffle() {
position = RandomUtil.nextInt(items.size());
if (!keepOrder) {
Collections.shuffle(items, RandomUtil.getRandom());
}
}
}