From bbfd8de276bc64785ce7988c1442a85fd4536bd1 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 8 Jun 2013 16:55:09 +0200 Subject: [PATCH] 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. --- Mage.Sets/src/mage/sets/ModernMasters.java | 1 + Mage/src/mage/cards/Sets.java | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Mage.Sets/src/mage/sets/ModernMasters.java b/Mage.Sets/src/mage/sets/ModernMasters.java index 5ffbcb44d1..72fe20786a 100644 --- a/Mage.Sets/src/mage/sets/ModernMasters.java +++ b/Mage.Sets/src/mage/sets/ModernMasters.java @@ -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; diff --git a/Mage/src/mage/cards/Sets.java b/Mage/src/mage/cards/Sets.java index aea33d0be3..9566f233da 100644 --- a/Mage/src/mage/cards/Sets.java +++ b/Mage/src/mage/cards/Sets.java @@ -215,6 +215,27 @@ public class Sets extends HashMap { } } } + 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; }