mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
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.
This commit is contained in:
parent
e120932bb4
commit
85948bf028
1 changed files with 14 additions and 2 deletions
|
|
@ -226,10 +226,22 @@ public abstract class ExpansionSet implements Serializable {
|
||||||
if (theBooster.size() > 15 && theBooster.get(0).getRarity() == Rarity.LAND) {
|
if (theBooster.size() > 15 && theBooster.get(0).getRarity() == Rarity.LAND) {
|
||||||
theBooster.remove(0);
|
theBooster.remove(0);
|
||||||
}
|
}
|
||||||
|
int keepCards = 4;
|
||||||
|
ArrayList<rarity> dontRemove = new ArrayList<>(Arrays.asList(Rarity.UNCOMMON, Rarity.RARE, Rarity.MYTHIC));
|
||||||
|
int toRemove;
|
||||||
while (theBooster.size() > 15) {
|
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;
|
return theBooster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue