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

Fix 15 card booster generation #13206

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Mage/src/main/java/mage/cards/ExpansionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you adding this? what does it have to do with your change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops thought I had taken that one out. Was part of something else.


protected final EnumMap<Rarity, List<CardInfo>> savedCards = new EnumMap<>(Rarity.class);
protected final EnumMap<Rarity, List<CardInfo>> savedSpecialCards = new EnumMap<>(Rarity.class);
Expand Down Expand Up @@ -220,9 +221,15 @@ public List<Card> 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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this.Booster is not correct

Copy link
Contributor Author

@tiera3 tiera3 Jan 7, 2025

Choose a reason for hiding this comment

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

That's what I get for rushing to submit just before the tournament started - fixed now.

As for your first question, the only one I know of is CLB, but there could be others. For CLB, the last four cards (that this protects from being eliminated) are Background, Legendary, Rare, and Foil (which could be any rarity). So the uncommons are at risk. (Edit - changed code so now the uncommons are protected also.)

(According to lethe, 2X2 comes in 16card boosters, with Cryptic Spires being the 16th card. So that is another potential one to trigger this in the future.)

I had considered a slightly more complicated approach of multistep processing.

List<Card> foundCards = [find all basiclands in booster] ;
if (theBooster.size() - foundCards.size() >= 15 ) {
  theBooster.remove(foundCards);
  foundCards = [find all commons in booster] ;
  if (theBooster.size() - foundCards.size() >= 15 ) {
    theBooster.remove(foundCards);
    foundCards = [find all uncommons in booster] ;
  }
}
if (theBooster.size() < 15 ) {
  [raise an error]
}
while (theBooster.size() -  foundCards.size() < 15 ) {
  foundCards.remove( RandomUtil.nextInt( foundCards.size()) );
}
theBooster.remove( foundCards );
// if still greater than 15 and removed all basics, lands, and uncommons, just go ahead with positional removal
while (theBooster.size() > 15) {
  theBooster.remove(0);
}

theBooster.remove(0);
}
while (theBooster.size() > 15) {
theBooster.remove(RandomUtil.nextInt(theBooster.size() - 4));
}

return theBooster;
}
Expand Down
Loading