From 808625fa3e81098ecdbf23c97a0624e5f2fe5abf Mon Sep 17 00:00:00 2001 From: tiera3 <87589219+tiera3@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:11:05 +1000 Subject: [PATCH 1/4] Fix 15 card booster generation I noticed the code for reducing boosters to 15 cards and realised it wouldn't work well with collated boosters, or with boosters with fixing in the first slot. --- Mage/src/main/java/mage/cards/ExpansionSet.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/cards/ExpansionSet.java b/Mage/src/main/java/mage/cards/ExpansionSet.java index 3e7077f11a7e..0b59e1d1223d 100644 --- a/Mage/src/main/java/mage/cards/ExpansionSet.java +++ b/Mage/src/main/java/mage/cards/ExpansionSet.java @@ -145,6 +145,7 @@ public static ExpansionSetComparator getComparator() { protected boolean hasAlternateBoosterPrintings = true; // not counting basic lands; e.g. Fallen Empires true, but Tenth Edition false protected int maxCardNumberInBooster; // used to omit cards with collector numbers beyond the regular cards in a set for boosters + protected int maxCardNumberBasePrint; // used to omit limit boosters to only contain cards with a base printing protected final EnumMap> savedCards = new EnumMap<>(Rarity.class); protected final EnumMap> savedSpecialCards = new EnumMap<>(Rarity.class); @@ -220,9 +221,15 @@ public List create15CardBooster() { } } - while (theBooster.size() > 15) { + // removing positional cards from collated boosters is going to mess with balancing and as-fan + // also for sets with common lands in the land slot, this may eliminate the majority of fixing from a pack + // instead removing a random card that is not in the last four (where rare and uncommons usually are - though some uncommons may be displayed by cards with special collation - eg DFC or bonus sheet). + if (this.Booster.size() > 15 && this.Booster.get(0).getRarity() == Rarity.LAND) { theBooster.remove(0); } + while (theBooster.size() > 15) { + theBooster.remove(RandomUtil.nextInt(theBooster.size() - 4)); + } return theBooster; } From e120932bb44a3026aee2f2ea7b6d8ae7c094fe4b Mon Sep 17 00:00:00 2001 From: tiera3 <87589219+tiera3@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:23:29 +1000 Subject: [PATCH 2/4] Add files via upload --- Mage/src/main/java/mage/cards/ExpansionSet.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Mage/src/main/java/mage/cards/ExpansionSet.java b/Mage/src/main/java/mage/cards/ExpansionSet.java index 0b59e1d1223d..60803d64eb12 100644 --- a/Mage/src/main/java/mage/cards/ExpansionSet.java +++ b/Mage/src/main/java/mage/cards/ExpansionSet.java @@ -145,7 +145,6 @@ public static ExpansionSetComparator getComparator() { protected boolean hasAlternateBoosterPrintings = true; // not counting basic lands; e.g. Fallen Empires true, but Tenth Edition false protected int maxCardNumberInBooster; // used to omit cards with collector numbers beyond the regular cards in a set for boosters - protected int maxCardNumberBasePrint; // used to omit limit boosters to only contain cards with a base printing protected final EnumMap> savedCards = new EnumMap<>(Rarity.class); protected final EnumMap> savedSpecialCards = new EnumMap<>(Rarity.class); @@ -224,7 +223,7 @@ public List create15CardBooster() { // removing positional cards from collated boosters is going to mess with balancing and as-fan // also for sets with common lands in the land slot, this may eliminate the majority of fixing from a pack // instead removing a random card that is not in the last four (where rare and uncommons usually are - though some uncommons may be displayed by cards with special collation - eg DFC or bonus sheet). - if (this.Booster.size() > 15 && this.Booster.get(0).getRarity() == Rarity.LAND) { + if (theBooster.size() > 15 && theBooster.get(0).getRarity() == Rarity.LAND) { theBooster.remove(0); } while (theBooster.size() > 15) { From 85948bf0286af06bcfd38cd7113a8e0d53ddbf65 Mon Sep 17 00:00:00 2001 From: tiera3 <87589219+tiera3@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:05:00 +1000 Subject: [PATCH 3/4] Ensures first group of commons gets removed first Tested with 20 card packs containing 13 commons followed by 5 uncommons, a rare, then a card of any rarity. Also tested with 20 card packs containing 3 commons followed by 15 uncommons, a rare, then a card of any rarity. ------- In the first scenario, only commons from the group of 13 were removed. In the second scenario, the first three commons got removed, then the first two uncommons in the pack. That was expected behaviour. Note - second scenario not expected to occur. --- Mage/src/main/java/mage/cards/ExpansionSet.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Mage/src/main/java/mage/cards/ExpansionSet.java b/Mage/src/main/java/mage/cards/ExpansionSet.java index 60803d64eb12..76a75c1ac4f4 100644 --- a/Mage/src/main/java/mage/cards/ExpansionSet.java +++ b/Mage/src/main/java/mage/cards/ExpansionSet.java @@ -226,10 +226,22 @@ public List create15CardBooster() { if (theBooster.size() > 15 && theBooster.get(0).getRarity() == Rarity.LAND) { theBooster.remove(0); } + int keepCards = 4; + ArrayList dontRemove = new ArrayList<>(Arrays.asList(Rarity.UNCOMMON, Rarity.RARE, Rarity.MYTHIC)); + int toRemove; while (theBooster.size() > 15) { - theBooster.remove(RandomUtil.nextInt(theBooster.size() - 4)); + if (theBooster.size() > keepCards) { + toRemove = RandomUtil.nextInt(theBooster.size() - keepCards); + if( dontRemove.contains( theBooster.get(toRemove).getRarity() )) { + keepCards = theBooster.size() - toRemove ; + } else { + theBooster.remove(toRemove); + } + } else { + theBooster.remove(0); + } } - + return theBooster; } From d559914205daf7f054193c43f8b17a59d303eb44 Mon Sep 17 00:00:00 2001 From: tiera3 <87589219+tiera3@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:13:44 +1000 Subject: [PATCH 4/4] Add files via upload --- Mage/src/main/java/mage/cards/ExpansionSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/cards/ExpansionSet.java b/Mage/src/main/java/mage/cards/ExpansionSet.java index 76a75c1ac4f4..b140f5701148 100644 --- a/Mage/src/main/java/mage/cards/ExpansionSet.java +++ b/Mage/src/main/java/mage/cards/ExpansionSet.java @@ -227,7 +227,7 @@ public List create15CardBooster() { theBooster.remove(0); } int keepCards = 4; - ArrayList dontRemove = new ArrayList<>(Arrays.asList(Rarity.UNCOMMON, Rarity.RARE, Rarity.MYTHIC)); + ArrayList dontRemove = new ArrayList<>(Arrays.asList(Rarity.UNCOMMON, Rarity.RARE, Rarity.MYTHIC)); int toRemove; while (theBooster.size() > 15) { if (theBooster.size() > keepCards) {