added support for special lands in M20

This commit is contained in:
Evan Kranzler 2019-06-21 22:47:35 -04:00
parent bfda3b2790
commit 094ead3649

View file

@ -1,9 +1,16 @@
package mage.sets;
import mage.cards.ExpansionSet;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.SetType;
import java.util.ArrayList;
import java.util.List;
/**
* @author TheElk801
*/
@ -15,6 +22,9 @@ public final class CoreSet2020 extends ExpansionSet {
return instance;
}
List<CardInfo> savedSpecialCommon = new ArrayList<>();
protected final List<CardInfo> savedSpecialLand = new ArrayList<>();
private CoreSet2020() {
super("Core Set 2020", "M20", ExpansionSet.buildDate(2019, 7, 12), SetType.CORE);
this.hasBoosters = true;
@ -27,6 +37,11 @@ public final class CoreSet2020 extends ExpansionSet {
this.ratioBoosterMythic = 8;
this.maxCardNumberInBooster = 280;
// Core 2020 boosters have a 5/12 chance of basic land being replaced
// with the common taplands, which DO NOT appear in the common slot.
this.ratioBoosterSpecialLand = 12;
this.ratioBoosterSpecialLandNumerator = 5;
cards.add(new SetCardInfo("Aerial Assault", 1, Rarity.COMMON, mage.cards.a.AerialAssault.class));
cards.add(new SetCardInfo("Agent of Treachery", 43, Rarity.RARE, mage.cards.a.AgentOfTreachery.class));
cards.add(new SetCardInfo("Ajani, Strength of the Pride", 2, Rarity.MYTHIC, mage.cards.a.AjaniStrengthOfThePride.class));
@ -155,4 +170,40 @@ public final class CoreSet2020 extends ExpansionSet {
cards.add(new SetCardInfo("Yarok's Fenlurker", 123, Rarity.UNCOMMON, mage.cards.y.YaroksFenlurker.class));
cards.add(new SetCardInfo("Yarok, the Desecrated", 220, Rarity.MYTHIC, mage.cards.y.YarokTheDesecrated.class));
}
@Override
public List<CardInfo> getCardsByRarity(Rarity rarity) {
// Common cards retrievement of Core Set 2020 boosters - prevent the retrievement of the common lands
if (rarity == Rarity.COMMON) {
List<CardInfo> savedCardsInfos = savedCards.get(rarity);
if (savedCardsInfos == null) {
CardCriteria criteria = new CardCriteria();
criteria.rarities(Rarity.COMMON);
criteria.setCodes(this.code).notTypes(CardType.LAND);
savedCardsInfos = CardRepository.instance.findCards(criteria);
if (maxCardNumberInBooster != Integer.MAX_VALUE) {
savedCardsInfos.removeIf(next -> next.getCardNumberAsInt() > maxCardNumberInBooster && rarity != Rarity.LAND);
}
savedCards.put(rarity, savedCardsInfos);
}
// Return a copy of the saved cards information, as not to let modify the original.
return new ArrayList<>(savedCardsInfos);
} else {
return super.getCardsByRarity(rarity);
}
}
@Override
// the common taplands replacing the basic land
public List<CardInfo> getSpecialLand() {
if (savedSpecialLand.isEmpty()) {
CardCriteria criteria = new CardCriteria();
criteria.setCodes(this.code);
criteria.rarities(Rarity.COMMON);
criteria.types(CardType.LAND);
savedSpecialLand.addAll(CardRepository.instance.findCards(criteria));
}
return new ArrayList<>(savedSpecialLand);
}
}