diff --git a/Mage.Sets/src/mage/sets/Planeshift.java b/Mage.Sets/src/mage/sets/Planeshift.java index 2ae0b873728c..4622cba46e27 100644 --- a/Mage.Sets/src/mage/sets/Planeshift.java +++ b/Mage.Sets/src/mage/sets/Planeshift.java @@ -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 @@ -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, "96", "98", "40", "59", "102", "42", "4", "103", "131", "104", "23", "106", "107", "139", "80", "61", "112", "44", "82", "10", "116", "140", "69", "117", "85", "11", "51", "118", "28", "86", "70", "12", "29", "52", "119", "89", "120", "14", "124", "133", "37", "74", "130", "38"); + + 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 makeBooster() { + List booster = new ArrayList<>(); + booster.addAll(commonRuns.getNext().makeRun()); + booster.addAll(uncommonRuns.getNext().makeRun()); + booster.addAll(rareRuns.getNext().makeRun()); + return booster; + } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Prophecy.java b/Mage.Sets/src/mage/sets/Prophecy.java index fda54f8e3a8a..d84322ff2e14 100644 --- a/Mage.Sets/src/mage/sets/Prophecy.java +++ b/Mage.Sets/src/mage/sets/Prophecy.java @@ -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; /** * @@ -172,4 +180,59 @@ private Prophecy() { cards.add(new SetCardInfo("Withdraw", 54, Rarity.COMMON, mage.cards.w.Withdraw.class)); cards.add(new SetCardInfo("Zerapa Minotaur", 108, Rarity.COMMON, mage.cards.z.ZerapaMinotaur.class)); } + + @Override + public BoosterCollator createCollator() { + return new ProphecyCollator(); + } +} + +// Booster collation info from https://www.lethe.xyz/mtg/collation/pls.html +// Using Striped collation +class ProphecyCollator implements BoosterCollator { + private final CardRun common = new CardRun(10, + "65","118", "99", "54", "16", "78","128", "91", "36", "24", + "100", "35", "26", "58","120", "96", "49", "14", "55","126", + "27", "79","116", "93", "31", "8", "65","121", "87", "50", + "129", "88", "29", "20", "61","118", "99", "46", "2", "79", + "43", "16", "64","134", "84", "45", "11", "81","123", "91", + "6", "73", "98", "42","128", "19", "62", "88", "35","121", + "67", "36","131", "24", "96", "58", "50","129", "8", "84", + "120", "14","108", "81", "31","134", "27", "98", "55", "49", + "104", "78", "43","123", "20","100", "67", "29","131", "19", + "54","110", "6", "87", "64", "46","116", "26","104", "62", + "11", "93", "73", "45", "126", "2","108", "61", "42","110"); + private final CardRun uncommon = new CardRun(12, + "53","138", "7", "85","130", "25", "70", "34", "10","107","141", "53", + "124", "51", "97", "9", "53","132","101", "69", "83","111", "92","117", + "76", "90", "48","125", "80", "85","124", "9","122", "63", "44", "85", + "23", "41","122", "7", "34","136", "38","138", "23", "90", "59", "10", + "135", "71", "83", "70","142", "1", "72", "41", "71", "25","142","111", + "72", "44", "18", "41", "59","107", "18", "76", "51","132", "1", "76", + "38","138","135","141", "44","122", "86","136","101", "38", "80", "86", + "101", "17", "72", "25", "92", "48","130", "33", "70", "83", "33", "18", + "132", "80", "9","117", "34", "10", "69","125", "7", "69", "23", "71", + "63", "97","130", "86","136", "51","107","141", "97","124","142","125", + "90", "33", "59","111", "63","117", "17", "92","135", "1", "48", "17"); + private final CardRun rare = new CardRun(false, "28", "82", "3", "109", "30", "56", "4", "57", "5", "60", "137", "32", "112", "113", "89", "114", "66", "37", "68", "12", "115", "139", "94", "95", "13", "15", "119", "39", "74", "40", "75", "77", "21", "102", "103", "22", "47", "127", "105", "52", "106", "133", "140", "143"); + + 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 makeBooster() { + List booster = new ArrayList<>(); + booster.addAll(uncommonRuns.getNext().makeRun()); + booster.addAll(rareRuns.getNext().makeRun()); + booster.addAll(commonRuns.getNext().makeRun()); + return booster; + } } diff --git a/Mage/src/main/java/mage/collation/CardRun.java b/Mage/src/main/java/mage/collation/CardRun.java index c34876bf9d68..8d16d0d03c87 100644 --- a/Mage/src/main/java/mage/collation/CardRun.java +++ b/Mage/src/main/java/mage/collation/CardRun.java @@ -1,11 +1,43 @@ package mage.collation; +import mage.util.RandomUtil; + /** * @author TheElk801 */ public class CardRun extends Rotater { + private int stripeLen=0,stripeWidth,stripeDepth; public CardRun(boolean keepOrder, String... numbers) { super(keepOrder, numbers); } + + public CardRun(int sLen, String... numbers) { + super(true, numbers); + stripeLen= sLen; + stripeWidth= nextWidth(); + stripeDepth= 1+ RandomUtil.nextInt( stripeWidth ); + } + + // randomly choose a stripe width between 2 & 5 (inclusive) + // ToDo: when data available, use different weightings for different widths + private int nextWidth() { + return 2+ RandomUtil.nextInt(4); + } + + public int iterate() { + if ( stripeLen ==0 ){ + return super.iterate(); + } + if ( stripeDepth < stripeWidth ){ + ++stripeDepth; + return super.iterate(-stripeLen); + } + stripeDepth= 1; + if ( this.isEdge(stripeLen)){ + this.stripeWidth= this.nextWidth(); + return super.iterate(-1); + } + return super.iterate((stripeLen * (stripeWidth-1)) -1); + } } diff --git a/Mage/src/main/java/mage/collation/Rotater.java b/Mage/src/main/java/mage/collation/Rotater.java index 0af5fa77497c..f28f65afc0f0 100644 --- a/Mage/src/main/java/mage/collation/Rotater.java +++ b/Mage/src/main/java/mage/collation/Rotater.java @@ -37,12 +37,23 @@ public Rotater(boolean keepOrder, T... items) { } } - public int iterate() { + public boolean isEdge(int rowLen) { + return (position % rowLen)==0; + } + + public int iterate(int offset) { int i = position; - position++; + position += offset; + while (position <0) { + position += items.size(); + } position %= items.size(); return i; } + + public int iterate() { + return this.iterate(1); + } public T getNext() { return items.get(iterate());