From ffee1ecd7bce57a1570606aa1fde7a59897d8043 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 17 Jun 2021 08:59:18 -0400 Subject: [PATCH] [MH2] implemented automated booster generation (collation info not yet available) --- Mage.Sets/src/mage/sets/ModernHorizons2.java | 41 ++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index 05e81f8fc9..e0461cc4bc 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -1,8 +1,13 @@ package mage.sets; +import mage.cards.Card; import mage.cards.ExpansionSet; +import mage.cards.repository.CardInfo; import mage.constants.Rarity; import mage.constants.SetType; +import mage.util.RandomUtil; + +import java.util.List; /** * @author TheElk801 @@ -20,11 +25,11 @@ public final class ModernHorizons2 extends ExpansionSet { this.blockName = "Modern Horizons 2"; this.hasBasicLands = true; this.hasBoosters = true; - this.numBoosterLands = 1; - this.numBoosterCommon = 11; + this.numBoosterLands = 0; + this.numBoosterCommon = 10; this.numBoosterUncommon = 3; this.numBoosterRare = 1; - this.ratioBoosterMythic = 8; + this.ratioBoosterMythic = 7; this.maxCardNumberInBooster = 303; cards.add(new SetCardInfo("Abiding Grace", 1, Rarity.UNCOMMON, mage.cards.a.AbidingGrace.class)); @@ -335,4 +340,34 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Zabaz, the Glimmerwasp", 243, Rarity.RARE, mage.cards.z.ZabazTheGlimmerwasp.class)); cards.add(new SetCardInfo("Zuran Orb", 300, Rarity.UNCOMMON, mage.cards.z.ZuranOrb.class)); } + + @Override + public List tryBooster() { + List booster = super.tryBooster(); + addReprints(booster); + return booster; + } + + private void addReprints(List booster) { + // TODO: these rarity ratios are probably wrong + final Rarity rarity; + int i = RandomUtil.nextInt(121); + if (i < 2) { + rarity = Rarity.MYTHIC; + } else if (i < 22) { + rarity = Rarity.RARE; + } else { + rarity = Rarity.UNCOMMON; + } + List cards = super.getCardsByRarity(rarity); + cards.removeIf(cardInfo -> cardInfo.getCardNumberAsInt() < 262); + addToBooster(booster, cards); + } + + @Override + public List getCardsByRarity(Rarity rarity) { + List cards = super.getCardsByRarity(rarity); + cards.removeIf(cardInfo -> cardInfo.getCardNumberAsInt() >= 262); + return cards; + } }