Refactor set's legality

This commit is contained in:
Oleg Agafonov 2019-03-04 02:31:51 +04:00
parent 106a5d94b2
commit 8df43cfbb6
8 changed files with 110 additions and 150 deletions

View file

@ -1,4 +1,3 @@
package mage.cards;
import mage.ObjectColor;
@ -255,9 +254,7 @@ public abstract class ExpansionSet implements Serializable {
}
if (needsLegendCreature) {
if (booster.stream().noneMatch(card -> card.isLegendary() && card.isCreature())) {
return false;
}
return booster.stream().anyMatch(card -> card.isLegendary() && card.isCreature());
}
// TODO: add partner check
@ -311,9 +308,7 @@ public abstract class ExpansionSet implements Serializable {
// check that we don't have 3 or more uncommons/rares of the same color
if (magicColors.stream().anyMatch(color -> uncommonWeight.get(color) >= 180)) {
// reject only part of the boosters
if (RandomUtil.nextDouble() < rejectSameColorUncommonsProbability) {
return false;
}
return !(RandomUtil.nextDouble() < rejectSameColorUncommonsProbability);
}
return true;
@ -610,8 +605,13 @@ public abstract class ExpansionSet implements Serializable {
}
public boolean isEternalLegal() {
return setType != SetType.CUSTOM_SET
&& setType != SetType.JOKESET;
// any official sets except un-sets
return setType != SetType.CUSTOM_SET && setType != SetType.JOKESET;
}
public boolean isStandardLegal() {
// any official sets that was in standard
return setType == SetType.CORE || setType == SetType.EXPANSION || setType == SetType.SUPPLEMENTAL_STANDARD_LEGAL;
}
public void removeSavedCards() {