mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
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:
parent
5317239a1b
commit
bbfd8de276
2 changed files with 22 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue