Fixed a bug that no lands were added to sealed/draft decks, if drafted with a set not included in a block and that itself does not include basic lands.

This commit is contained in:
LevelX2 2013-06-08 16:55:09 +02:00
parent 5317239a1b
commit bbfd8de276
2 changed files with 22 additions and 0 deletions

View file

@ -46,6 +46,7 @@ public class ModernMasters extends ExpansionSet {
private ModernMasters() {
super("Modern Masters", "MMA", "", "mage.sets.modernmasters", new GregorianCalendar(2016, 6, 7).getTime(), SetType.REPRINT);
this.hasBasicLands = false;
this.hasBoosters = true;
this.numBoosterLands = 0;
this.numBoosterCommon = 11;

View file

@ -215,6 +215,27 @@ public class Sets extends HashMap<String, ExpansionSet> {
}
}
}
if (landSets.isEmpty()) {
// if set has no lands and also it has no parent or parent has no lands get last set with lands
// select a set with basic lands by random
Random generator = new Random();
int maxRndValue = 0;
String selectedSetCode = null;
for (ExpansionSet set :Sets.getInstance().getSortedByReleaseDate()) {
if (set.hasBasicLands) {
int rndValue = generator.nextInt(100);
if (rndValue >= maxRndValue) {
maxRndValue = rndValue;
selectedSetCode = set.getCode();
}
}
}
if (selectedSetCode != null) {
landSets.add(selectedSetCode);
} else {
throw new IllegalArgumentException("No set with basic land was found");
}
}
return landSets;
}