Skip to content

Commit

Permalink
added support for special lands in M20
Browse files Browse the repository at this point in the history
  • Loading branch information
theelk801 committed Jun 22, 2019
1 parent bfda3b2 commit 094ead3
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Mage.Sets/src/mage/sets/CoreSet2020.java
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -15,6 +22,9 @@ public static CoreSet2020 getInstance() {
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;
Expand All @@ -27,6 +37,11 @@ private CoreSet2020() {
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));
Expand Down Expand Up @@ -155,4 +170,40 @@ private CoreSet2020() {
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);
}
}

0 comments on commit 094ead3

Please sign in to comment.