Merge pull request #8178 from awjackson/csp_booster_fix

Fix Coldsnap booster generation
This commit is contained in:
Oleg Agafonov 2021-09-05 01:34:46 +04:00 committed by GitHub
commit 7ff6e73a19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View file

@ -2,9 +2,15 @@
package mage.sets; package mage.sets;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SetType; import mage.constants.SetType;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author North * @author North
*/ */
@ -20,7 +26,7 @@ public final class Coldsnap extends ExpansionSet {
super("Coldsnap", "CSP", ExpansionSet.buildDate(2006, 6, 21), SetType.EXPANSION); super("Coldsnap", "CSP", ExpansionSet.buildDate(2006, 6, 21), SetType.EXPANSION);
this.blockName = "Ice Age"; this.blockName = "Ice Age";
this.hasBoosters = true; this.hasBoosters = true;
this.numBoosterLands = 1; this.numBoosterLands = 0;
this.numBoosterCommon = 11; this.numBoosterCommon = 11;
this.numBoosterUncommon = 3; this.numBoosterUncommon = 3;
this.numBoosterRare = 1; this.numBoosterRare = 1;
@ -184,4 +190,25 @@ public final class Coldsnap extends ExpansionSet {
cards.add(new SetCardInfo("Zombie Musher", 75, Rarity.COMMON, mage.cards.z.ZombieMusher.class)); cards.add(new SetCardInfo("Zombie Musher", 75, Rarity.COMMON, mage.cards.z.ZombieMusher.class));
cards.add(new SetCardInfo("Zur the Enchanter", 135, Rarity.RARE, mage.cards.z.ZurTheEnchanter.class)); cards.add(new SetCardInfo("Zur the Enchanter", 135, Rarity.RARE, mage.cards.z.ZurTheEnchanter.class));
} }
@Override
public List<CardInfo> getCardsByRarity(Rarity rarity) {
if (rarity != Rarity.COMMON) {
return super.getCardsByRarity(rarity);
}
List<CardInfo> savedCardsInfos = savedCards.get(rarity);
if (savedCardsInfos != null) {
return new ArrayList(savedCardsInfos);
}
CardCriteria criteria = new CardCriteria();
criteria.setCodes(this.code).rarities(rarity);
savedCardsInfos = CardRepository.instance.findCards(criteria);
// Snow basic lands are included in boosters as regular commons, not in a land slot
criteria = new CardCriteria();
criteria.setCodes(this.code).rarities(Rarity.LAND);
savedCardsInfos.addAll(CardRepository.instance.findCards(criteria));
savedCards.put(rarity, savedCardsInfos);
// Return a copy of the saved cards information, as not to modify the original.
return new ArrayList(savedCardsInfos);
}
} }

View file

@ -248,14 +248,6 @@ public class BoosterGenerationTest extends MageTestBase {
} }
} }
@Test
public void testColdSnap_BoosterMustHaveOneSnowLand() {
for (int i = 0; i < 10; i++) {
List<Card> booster = Coldsnap.getInstance().createBooster();
assertTrue("coldsnap's booster must contain 1 snow covered land", booster.stream().anyMatch(card -> card.isBasic() && card.getName().startsWith("Snow-Covered ")));
}
}
@Test @Test
public void testModernHorizons_BoosterMustHaveOneSnowLand() { public void testModernHorizons_BoosterMustHaveOneSnowLand() {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {