Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLS] Planeshift - Striped Collation #12960

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
63 changes: 63 additions & 0 deletions Mage.Sets/src/mage/sets/Planeshift.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import mage.cards.ExpansionSet;
import mage.constants.Rarity;
import mage.constants.SetType;
import mage.collation.BoosterCollator;
import mage.collation.BoosterStructure;
import mage.collation.CardRun;
import mage.collation.RarityConfiguration;
import mage.util.RandomUtil;

import java.util.ArrayList;
import java.util.List;

/**
* @author North
Expand Down Expand Up @@ -175,4 +183,59 @@ private Planeshift() {
cards.add(new SetCardInfo("Warped Devotion", 57, Rarity.UNCOMMON, mage.cards.w.WarpedDevotion.class));
cards.add(new SetCardInfo("Waterspout Elemental", 38, Rarity.RARE, mage.cards.w.WaterspoutElemental.class));
}

@Override
public BoosterCollator createCollator() {
return new PlaneshiftCollator();
}
}

// Booster collation info from https://www.lethe.xyz/mtg/collation/pls.html
// Using Striped collation
class PlaneshiftCollator implements BoosterCollator {
private final CardRun common = new CardRun(10,
"111", "76", "81", "17", "33", "48","111", "95", "1", "21",
"90", "97", "31", "39", "65", "79", "15","125", "50", "76",
"34", "41","110", "88", "3", "27", "53", "66","114", "7",
"58", "87", "2","109", "54", "67", "93", "8", "30","110",
"17", "25", "56", "71", "97", "6", "36", "46", "72", "79",
"128", "15", "63", "22", "95","101", "13", "65", "31", "87",
"64","127", "91", "45", "7", "58","125", "78", "41", "6",
"81", "39","113", "72", "34", "90", "53","128", "64", "27",
"3", "66", "21","114", "50", "2", "63", "25","113", "46",
"33", "88", "48", "1","127", "22", "93", "45", "13","109",
"8", "54", "30", "67", "78","101", "56", "36", "71", "91")
private final CardRun uncommon = new CardRun(12,
"138", "43","115", "19","136", "32","121", "73","136", "92","105", "55",
"5", "32", "75","129", "92", "47", "9","115", "35","137", "62","126",
"99", "94","141", "57","108", "18","142", "24", "99", "73","135", "84",
"47","105", "9","135", "26","123", "68","138", "77","123", "49","142",
"137", "16","126", "20","143", "62","105", "83","132", "57","129", "5",
"26","134", "68","115", "84","137", "47","100", "16", "20", "75","100",
"123", "83","138", "55","126", "5","141", "32","122", "60","136", "77",
"43","122", "18","134", "24", "99", "62","143", "94","121", "43","132",
"143", "19", "35", "60","132", "77", "49", "19","134", "24", "83", "75",
"121", "57","142", "9","122", "35", "60", "92","129", "55", "18", "26",
"73","108", "84", "49", "16","100", "20","135", "68","108", "94","141")
private final CardRun rare = new CardRun(false, "58", "1", "61", "2", "174", "286", "9", "10", "69", "229", "116", "179", "117", "180", "120", "121", "231", "13", "297", "73", "75", "182", "298", "234", "77", "318", "79", "126", "319", "127", "287", "17", "320", "18", "82", "19", "20", "187", "21", "132", "192", "85", "24", "141", "242", "142", "143", "243", "197", "288", "245", "300", "198", "26", "28", "248", "29", "204", "32", "149", "205", "303", "207", "152", "321", "208", "33", "290", "255", "256", "209", "153", "257", "259", "210", "305", "212", "89", "90", "92", "323", "39", "157", "218", "220", "267", "326", "294", "101", "327", "271", "273", "163", "276", "328", "164", "329", "278", "105", "108", "165", "110", "166", "112", "113", "296", "280", "227", "57", "285");

private final BoosterStructure C11 = new BoosterStructure(
common, common, common, common, common, common,
common, common, common, common, common
);
private final BoosterStructure U3 = new BoosterStructure(uncommon, uncommon, uncommon);
private final BoosterStructure R1 = new BoosterStructure(rare);

private final RarityConfiguration commonRuns = new RarityConfiguration(C11);
private final RarityConfiguration uncommonRuns = new RarityConfiguration(U3);
private final RarityConfiguration rareRuns = new RarityConfiguration(R1);

@Override
public List<String> makeBooster() {
List<String> booster = new ArrayList<>();
booster.addAll(commonRuns.getNext().makeRun());
booster.addAll(uncommonRuns.getNext().makeRun());
booster.addAll(rareRuns.getNext().makeRun());
return booster;
}
}
45 changes: 42 additions & 3 deletions Mage/src/main/java/mage/collation/Rotater.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class Rotater<T> {

private final List<T> items;
private int position;
private int position, stripeLen = 0, stripeWidth, stripeDepth;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code to implement striped collation almost certainly needs to be a separate class, perhaps both implementing a common interface.

You're going to have a hard time getting this to work without a dev environment for testing.


public Rotater(T item) {
this(true, item);
Expand All @@ -37,10 +37,49 @@ public Rotater(boolean keepOrder, T... items) {
}
}

// for striped collation
public Main(int sLen, String... items) {
// should there be an error check?
// assert ( items.size() % sLen ) == 0;
this.stripeLen = sLen;
this.items = Arrays.asList(items);
this.position = RandomUtil.nextInt(this.items.size());
this.stripeWidth= this.nextWidth();
this.stripeDepth= 1+ RandomUtil.nextInt(this.stripeWidth);
}

// choose a stripe width between 2 & 5 inclusive
// ToDo when data available: enable different widths to have different likelihoods
public int nextWidth() {
return 2+ RandomUtil.nextInt(4);
}

public int iterate() {
int i = position;
position++;
position %= items.size();
if( stripeLen >0 ){
if( stripeDepth < stripeWidth ){
++stripeDepth;
position -= 10;
if (position <0 ){
position += items.size();
}
}else{
stripeDepth= 1;
if( (position % stripeLen) >0 ){
position += stripeLen * (stripeWidth-1);
position %= items.size();
}else{
this.stripeWidth= this.nextWidth();
}
position -= 1;
if (position <0 ){
position += items.size();
}
}
}else{
position++;
position %= items.size();
}
return i;
}

Expand Down
Loading