diff --git a/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java b/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java index 96e257674a4..f53ad8ba403 100644 --- a/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java +++ b/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java @@ -22,9 +22,12 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Random; import java.util.UUID; +import mage.Constants; +import mage.cards.ExpansionSet; /** * Generates random card pool and builds a deck. @@ -39,7 +42,7 @@ public class DeckGenerator { private static final int SPELL_CARD_POOL_SIZE = 180; - private static final int DECK_LANDS = 16; + private static final int DECK_LANDS = 17; private static final int MAX_NON_BASIC_SOURCE = DECK_LANDS / 2; private static final int MAX_TRIES = 4096; @@ -159,21 +162,15 @@ public class DeckGenerator { final List setsToUseFinal = setsToUse; - deck = DeckBuilder.buildDeck(spellCardPool, allowedColors, landCardPool, new RateCallback() { + deck = DeckBuilder.buildDeck(spellCardPool, allowedColors, setsToUseFinal, landCardPool, new RateCallback() { @Override public int rateCard(Card card) { return 6; } @Override - public Card getBestBasicLand(ColoredManaSymbol color) { - int tries = 100; - Card land; - do { - land = DeckGenerator.getBestBasicLand(color); - tries--; - } while (!setsToUseFinal.contains(land.getExpansionSetCode()) && tries >= 0); - return land; + public Card getBestBasicLand(ColoredManaSymbol color, List setsToUse) { + return DeckGenerator.getBestBasicLand(color, setsToUseFinal); } }); } @@ -336,29 +333,52 @@ public class DeckGenerator { * @param color * @return */ - private static Card getBestBasicLand(ColoredManaSymbol color) { - if (color.equals(ColoredManaSymbol.G)) { - CardInfo cardInfo = CardRepository.instance.findCard("Forest"); - return cardInfo != null ? cardInfo.getCard() : null; - } - if (color.equals(ColoredManaSymbol.R)) { - CardInfo cardInfo = CardRepository.instance.findCard("Mountain"); - return cardInfo != null ? cardInfo.getCard() : null; - } - if (color.equals(ColoredManaSymbol.B)) { - CardInfo cardInfo = CardRepository.instance.findCard("Swamp"); - return cardInfo != null ? cardInfo.getCard() : null; - } - if (color.equals(ColoredManaSymbol.U)) { - CardInfo cardInfo = CardRepository.instance.findCard("Island"); - return cardInfo != null ? cardInfo.getCard() : null; - } - if (color.equals(ColoredManaSymbol.W)) { - CardInfo cardInfo = CardRepository.instance.findCard("Plains"); - return cardInfo != null ? cardInfo.getCard() : null; + private static Card getBestBasicLand(ColoredManaSymbol color, List setsToUse) { + String cardName = ""; + switch(color) { + case G: + cardName = "Forest"; + break; + case W: + cardName = "Plains"; + break; + case R: + cardName = "Mountain"; + break; + case B: + cardName = "Swamp"; + break; + case U: + cardName = "Island"; + break; } - return null; + List landSets = new LinkedList(); + if (!setsToUse.isEmpty()) { + // Add parent sets with the basic lands if the setlist don't include them + for (String setCode: setsToUse) { + ExpansionSet expansionSet = Sets.findSet(setCode); + if (expansionSet.hasBasicLands()) { + landSets.add(setCode); + } else if (expansionSet.getParentSet() != null && !landSets.contains(expansionSet.getParentSet().getCode())) { + landSets.add(expansionSet.getParentSet().getCode()); + } + } + } + CardCriteria criteria = new CardCriteria(); + if (!landSets.isEmpty()) { + criteria.setCodes(landSets.toArray(new String[landSets.size()])); + } + criteria.rarities(Constants.Rarity.LAND).name(cardName); + List cards = CardRepository.instance.findCards(criteria); + + if (cards.isEmpty() && !setsToUse.isEmpty()) { + cards = CardRepository.instance.findCards(cardName); + } + + int randomInt = new Random().nextInt(cards.size()); + return cards.get(randomInt).getCard(); + } protected static boolean isColoredMana(String symbol) { diff --git a/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java b/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java index f4df539250a..0d4a25c057e 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java @@ -34,11 +34,16 @@ package mage.client.dialog; +import java.util.LinkedList; import java.util.List; import java.util.Random; import javax.swing.JLayeredPane; +import mage.Constants; import mage.cards.Card; +import mage.cards.ExpansionSet; +import mage.cards.Sets; import mage.cards.decks.Deck; +import mage.cards.repository.CardCriteria; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; import mage.client.MageFrame; @@ -50,6 +55,7 @@ import mage.client.MageFrame; public class AddLandDialog extends MageDialog { private Deck deck; + private List setCodesland; /** Creates new form AddLandDialog */ public AddLandDialog() { @@ -59,13 +65,46 @@ public class AddLandDialog extends MageDialog { public void showDialog(Deck deck) { this.deck = deck; + + // find setCodes with basic lands from cards of the deck + List setCodes = new LinkedList(); + for (Card card: this.deck.getCards()) { + if (!setCodes.contains(card.getExpansionSetCode())) { + setCodes.add(card.getExpansionSetCode()); + } + } + for (Card card: this.deck.getSideboard()) { + if (!setCodes.contains(card.getExpansionSetCode())) { + setCodes.add(card.getExpansionSetCode()); + } + } + List landSets = new LinkedList(); + if (!setCodes.isEmpty()) { + // Add parent sets with the basic lands if the setlist don't include them + for (String setCode: setCodes) { + ExpansionSet expansionSet = Sets.findSet(setCode); + if (expansionSet.hasBasicLands()) { + landSets.add(setCode); + } else if (expansionSet.getParentSet() != null && !landSets.contains(expansionSet.getParentSet().getCode())) { + landSets.add(expansionSet.getParentSet().getCode()); + } + } + } + this.setCodesland = landSets; + + MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); this.setVisible(true); } private void addLands(String landName, int number) { Random random = new Random(); - List cards = CardRepository.instance.findCards(landName); + CardCriteria criteria = new CardCriteria(); + if (!setCodesland.isEmpty()) { + criteria.setCodes(setCodesland.toArray(new String[setCodesland.size()])); + } + criteria.rarities(Constants.Rarity.LAND).name(landName); + List cards = CardRepository.instance.findCards(criteria); if (cards.isEmpty()) { return; } diff --git a/Mage.Common/src/mage/interfaces/rate/RateCallback.java b/Mage.Common/src/mage/interfaces/rate/RateCallback.java index e8621a2c2c0..61f3b4fc07c 100644 --- a/Mage.Common/src/mage/interfaces/rate/RateCallback.java +++ b/Mage.Common/src/mage/interfaces/rate/RateCallback.java @@ -1,5 +1,6 @@ package mage.interfaces.rate; +import java.util.List; import mage.Constants; import mage.cards.Card; @@ -10,5 +11,5 @@ import mage.cards.Card; */ public interface RateCallback { int rateCard(Card card); - Card getBestBasicLand(Constants.ColoredManaSymbol color); + Card getBestBasicLand(Constants.ColoredManaSymbol color, List setsToUse); } \ No newline at end of file diff --git a/Mage.Common/src/mage/utils/DeckBuilder.java b/Mage.Common/src/mage/utils/DeckBuilder.java index 26b45c6874c..7a3a1d8b6a3 100644 --- a/Mage.Common/src/mage/utils/DeckBuilder.java +++ b/Mage.Common/src/mage/utils/DeckBuilder.java @@ -22,8 +22,8 @@ public class DeckBuilder { private static final int DECK_COUNT[] = {3, 6, 6, 4, 3, 2}; private static final int DECK_COST[] = {1, 2, 3, 4, 6, 10}; - private static final int DECK_SPELLS = 24; - private static final int DECK_LANDS = 16; + private static final int DECK_SPELLS = 23; + private static final int DECK_LANDS = 17; private static final int DECK_SIZE = DECK_SPELLS + DECK_LANDS; private static final int MIN_CARD_SCORE = 25; private static final int MIN_SOURCE = 16; @@ -35,7 +35,7 @@ public class DeckBuilder { private DeckBuilder() { } - public synchronized static Deck buildDeck(List spellCardPool, List allowedColors, List landCardPool, RateCallback callback) { + public synchronized static Deck buildDeck(List spellCardPool, List allowedColors, List setsToUse, List landCardPool, RateCallback callback) { deck = new Deck(); final Collection remainingCards = new ArrayList(); @@ -55,7 +55,7 @@ public class DeckBuilder { } addCardsToDeck(remainingCards, 0, 4, DECK_SPELLS - deck.getCards().size()); addCardsToDeck(remainingCards, 5, 10, DECK_SPELLS - deck.getCards().size()); - addLandsToDeck(allowedColors, landCardPool, callback); + addLandsToDeck(allowedColors, setsToUse, landCardPool, callback); return deck; } @@ -121,7 +121,7 @@ public class DeckBuilder { * @param landCardPool * @param callback */ - private static void addLandsToDeck(List allowedColors, List landCardPool, RateCallback callback) { + private static void addLandsToDeck(List allowedColors, List setsToUse, List landCardPool, RateCallback callback) { // Calculate statistics per color. final Map colorCount = new HashMap(); @@ -190,7 +190,7 @@ public class DeckBuilder { } } } - final Card landCard = callback.getBestBasicLand(bestColor); + final Card landCard = callback.getBestBasicLand(bestColor, setsToUse); Integer count = colorSource.get(bestColor.toString()); count++; colorSource.put(bestColor.toString(), count); diff --git a/Mage.Sets/src/mage/sets/AlaraReborn.java b/Mage.Sets/src/mage/sets/AlaraReborn.java index 44feccaa97f..5e6e5503bd9 100644 --- a/Mage.Sets/src/mage/sets/AlaraReborn.java +++ b/Mage.Sets/src/mage/sets/AlaraReborn.java @@ -48,6 +48,7 @@ public class AlaraReborn extends ExpansionSet { super("Alara Reborn", "ARB", "seticon_mtgarb", "mage.sets.alarareborn", new GregorianCalendar(2009, 3, 25).getTime(), SetType.EXPANSION); this.blockName = "Shards of Alara"; this.parentSet = ShardsOfAlara.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Alliances.java b/Mage.Sets/src/mage/sets/Alliances.java index d22cb59071a..8343a639dad 100644 --- a/Mage.Sets/src/mage/sets/Alliances.java +++ b/Mage.Sets/src/mage/sets/Alliances.java @@ -15,6 +15,8 @@ public class Alliances extends ExpansionSet { private Alliances() { super("Alliances", "ALL", "", "mage.sets.alliances", new GregorianCalendar(1996, 6, 10).getTime(), Constants.SetType.EXPANSION); this.blockName = "Ice Age"; + this.parentSet = IceAge.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 8; diff --git a/Mage.Sets/src/mage/sets/Antiquities.java b/Mage.Sets/src/mage/sets/Antiquities.java index b68c8444342..32b997992eb 100644 --- a/Mage.Sets/src/mage/sets/Antiquities.java +++ b/Mage.Sets/src/mage/sets/Antiquities.java @@ -45,6 +45,7 @@ public class Antiquities extends ExpansionSet { private Antiquities() { super("Antiquities", "ATQ", "", "mage.sets.antiquities", new GregorianCalendar(1994, 2, 1).getTime(), Constants.SetType.EXPANSION); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Apocalypse.java b/Mage.Sets/src/mage/sets/Apocalypse.java index 2049d8720b1..a342bdfaedc 100644 --- a/Mage.Sets/src/mage/sets/Apocalypse.java +++ b/Mage.Sets/src/mage/sets/Apocalypse.java @@ -1,9 +1,9 @@ package mage.sets; +import java.util.GregorianCalendar; import mage.Constants; import mage.cards.ExpansionSet; -import java.util.GregorianCalendar; public class Apocalypse extends ExpansionSet { private static final Apocalypse fINSTANCE = new Apocalypse(); @@ -15,6 +15,8 @@ public class Apocalypse extends ExpansionSet { private Apocalypse() { super("Apocalypse", "APC", "", "mage.sets.apocalypse", new GregorianCalendar(2001, 5, 1).getTime(), Constants.SetType.EXPANSION); this.blockName = "Invasion"; + this.parentSet = Invasion.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/ArabianNights.java b/Mage.Sets/src/mage/sets/ArabianNights.java index 231354fb6cb..3f7d5825558 100644 --- a/Mage.Sets/src/mage/sets/ArabianNights.java +++ b/Mage.Sets/src/mage/sets/ArabianNights.java @@ -45,6 +45,7 @@ public class ArabianNights extends ExpansionSet { private ArabianNights() { super("Arabian Nights", "ARN", "", "mage.sets.arabiannights", new GregorianCalendar(1993, 11, 1).getTime(), Constants.SetType.EXPANSION); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/AvacynRestored.java b/Mage.Sets/src/mage/sets/AvacynRestored.java index d24c5c12f39..8977ba80143 100644 --- a/Mage.Sets/src/mage/sets/AvacynRestored.java +++ b/Mage.Sets/src/mage/sets/AvacynRestored.java @@ -46,6 +46,7 @@ public class AvacynRestored extends ExpansionSet { private AvacynRestored() { super("Avacyn Restored", "AVR", "seticon_mtgavr", "mage.sets.avacynrestored", new GregorianCalendar(2012, 4, 4).getTime(), SetType.EXPANSION); this.blockName = "Innistrad"; + this.parentSet = Innistrad.getInstance(); this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/BetrayersOfKamigawa.java b/Mage.Sets/src/mage/sets/BetrayersOfKamigawa.java index d724920f78c..1c3a00757f1 100644 --- a/Mage.Sets/src/mage/sets/BetrayersOfKamigawa.java +++ b/Mage.Sets/src/mage/sets/BetrayersOfKamigawa.java @@ -46,6 +46,8 @@ public class BetrayersOfKamigawa extends ExpansionSet { private BetrayersOfKamigawa() { super("Betrayers of Kamigawa", "BOK", "", "mage.sets.betrayersofkamigawa", new GregorianCalendar(2005, 1, 4).getTime(), SetType.EXPANSION); this.blockName = "Kamigawa"; + this.parentSet = ChampionsOfKamigawa.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Coldsnap.java b/Mage.Sets/src/mage/sets/Coldsnap.java index cb575db7dea..702a9f34773 100644 --- a/Mage.Sets/src/mage/sets/Coldsnap.java +++ b/Mage.Sets/src/mage/sets/Coldsnap.java @@ -52,5 +52,7 @@ public class Coldsnap extends ExpansionSet { this.numBoosterUncommon = 3; this.numBoosterRare = 1; this.ratioBoosterMythic = 8; + this.parentSet = IceAge.getInstance(); + this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/Conflux.java b/Mage.Sets/src/mage/sets/Conflux.java index 8ccbacdafc4..c3a2e94848d 100644 --- a/Mage.Sets/src/mage/sets/Conflux.java +++ b/Mage.Sets/src/mage/sets/Conflux.java @@ -48,6 +48,7 @@ public class Conflux extends ExpansionSet { super("Conflux", "CON", "seticon_conflux", "mage.sets.conflux", new GregorianCalendar(2009, 0, 31).getTime(), SetType.EXPANSION); this.blockName = "Shards of Alara"; this.parentSet = ShardsOfAlara.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/DarkAscension.java b/Mage.Sets/src/mage/sets/DarkAscension.java index 384bc80f124..8addd54499a 100644 --- a/Mage.Sets/src/mage/sets/DarkAscension.java +++ b/Mage.Sets/src/mage/sets/DarkAscension.java @@ -52,5 +52,7 @@ public class DarkAscension extends ExpansionSet { this.numBoosterUncommon = 3; this.numBoosterRare = 1; this.ratioBoosterMythic = 8; + this.parentSet = Innistrad.getInstance(); + this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Darksteel.java b/Mage.Sets/src/mage/sets/Darksteel.java index b0a9f6765a8..4cb8f530bbe 100644 --- a/Mage.Sets/src/mage/sets/Darksteel.java +++ b/Mage.Sets/src/mage/sets/Darksteel.java @@ -17,6 +17,7 @@ public class Darksteel extends ExpansionSet { super("Darksteel", "DST", "", "mage.sets.darksteel", new GregorianCalendar(2004, 1, 6).getTime(), Constants.SetType.EXPANSION); this.blockName = "Mirrodin"; this.parentSet = Mirrodin.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Dissension.java b/Mage.Sets/src/mage/sets/Dissension.java index e7e080fc034..22f0044128e 100644 --- a/Mage.Sets/src/mage/sets/Dissension.java +++ b/Mage.Sets/src/mage/sets/Dissension.java @@ -49,6 +49,8 @@ public class Dissension extends ExpansionSet { private Dissension() { super("Dissension", "DIS", "", "mage.sets.dissension", new GregorianCalendar(2006, 4, 5).getTime(), Constants.SetType.EXPANSION); this.blockName = "Ravnika"; + this.parentSet = RavnicaCityOfGuilds.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Eventide.java b/Mage.Sets/src/mage/sets/Eventide.java index 643c3c14450..bd6ce65834f 100644 --- a/Mage.Sets/src/mage/sets/Eventide.java +++ b/Mage.Sets/src/mage/sets/Eventide.java @@ -15,6 +15,8 @@ public class Eventide extends ExpansionSet { private Eventide() { super("Eventide", "EVE", "", "mage.sets.eventide", new GregorianCalendar(2008, 6, 25).getTime(), Constants.SetType.EXPANSION); this.blockName = "Shadowmoor"; + this.parentSet = Shadowmoor.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Exodus.java b/Mage.Sets/src/mage/sets/Exodus.java index 805d36500b1..58b39e22633 100644 --- a/Mage.Sets/src/mage/sets/Exodus.java +++ b/Mage.Sets/src/mage/sets/Exodus.java @@ -46,6 +46,8 @@ public class Exodus extends ExpansionSet { private Exodus() { super("Exodus", "EXO", "", "mage.sets.exodus", new GregorianCalendar(1998, 5, 6).getTime(), Constants.SetType.EXPANSION); this.blockName = "Tempest"; + this.parentSet = Tempest.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/FallenEmpires.java b/Mage.Sets/src/mage/sets/FallenEmpires.java index 053f84923e5..305a19dcc72 100644 --- a/Mage.Sets/src/mage/sets/FallenEmpires.java +++ b/Mage.Sets/src/mage/sets/FallenEmpires.java @@ -45,6 +45,7 @@ public class FallenEmpires extends ExpansionSet { private FallenEmpires() { super("Fallen Empires", "FEM", "", "mage.sets.fallenempires", new GregorianCalendar(1994, 10, 1).getTime(), Constants.SetType.EXPANSION); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/FifthDawn.java b/Mage.Sets/src/mage/sets/FifthDawn.java index f52d507e624..ef38ba6bd7d 100644 --- a/Mage.Sets/src/mage/sets/FifthDawn.java +++ b/Mage.Sets/src/mage/sets/FifthDawn.java @@ -46,6 +46,8 @@ public class FifthDawn extends ExpansionSet { private FifthDawn() { super("Fifth Dawn", "5DN", "", "mage.sets.fifthdawn", new GregorianCalendar(2004, 5, 4).getTime(), SetType.EXPANSION); this.blockName = "Mirrodin"; + this.parentSet = Mirrodin.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/FutureSight.java b/Mage.Sets/src/mage/sets/FutureSight.java index 9cc91e1fc5b..296abdd034c 100644 --- a/Mage.Sets/src/mage/sets/FutureSight.java +++ b/Mage.Sets/src/mage/sets/FutureSight.java @@ -46,6 +46,8 @@ public class FutureSight extends ExpansionSet { private FutureSight() { super("Future Sight", "FUT", "", "mage.sets.futuresight", new GregorianCalendar(2007, 4, 4).getTime(), SetType.EXPANSION); this.blockName = "Time Spiral"; + this.parentSet = TimeSpiral.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Gatecrash.java b/Mage.Sets/src/mage/sets/Gatecrash.java index 738154c8b5d..2f0606e21f3 100644 --- a/Mage.Sets/src/mage/sets/Gatecrash.java +++ b/Mage.Sets/src/mage/sets/Gatecrash.java @@ -52,5 +52,7 @@ public class Gatecrash extends ExpansionSet { this.numBoosterUncommon = 3; this.numBoosterRare = 1; this.ratioBoosterMythic = 8; + this.parentSet = ReturnToRavnica.getInstance(); + this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/Guildpact.java b/Mage.Sets/src/mage/sets/Guildpact.java index d414c324ac2..67bec1bb491 100644 --- a/Mage.Sets/src/mage/sets/Guildpact.java +++ b/Mage.Sets/src/mage/sets/Guildpact.java @@ -49,6 +49,8 @@ public class Guildpact extends ExpansionSet { private Guildpact() { super("Guildpact", "GPT", "", "mage.sets.guildpact", new GregorianCalendar(2006, 1, 3).getTime(), Constants.SetType.EXPANSION); this.blockName = "Ravnika"; + this.parentSet = RavnicaCityOfGuilds.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Homelands.java b/Mage.Sets/src/mage/sets/Homelands.java index 593de388e70..a1e58a64802 100644 --- a/Mage.Sets/src/mage/sets/Homelands.java +++ b/Mage.Sets/src/mage/sets/Homelands.java @@ -45,6 +45,7 @@ public class Homelands extends ExpansionSet { private Homelands() { super("Homelands", "HML", "", "mage.sets.homelands", new GregorianCalendar(1995, 9, 1).getTime(), Constants.SetType.EXPANSION); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Judgment.java b/Mage.Sets/src/mage/sets/Judgment.java index 9b27ef1d8b8..888681603a7 100644 --- a/Mage.Sets/src/mage/sets/Judgment.java +++ b/Mage.Sets/src/mage/sets/Judgment.java @@ -46,6 +46,8 @@ public class Judgment extends ExpansionSet { private Judgment() { super("Judgment", "JUD", "exp_symbol_mtgjud", "mage.sets.judgment", new GregorianCalendar(2002, 5, 27).getTime(), SetType.EXPANSION); this.blockName = "Odyssey"; + this.parentSet = Odyssey.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Legends.java b/Mage.Sets/src/mage/sets/Legends.java index e0fcd982fad..03a5324fee0 100644 --- a/Mage.Sets/src/mage/sets/Legends.java +++ b/Mage.Sets/src/mage/sets/Legends.java @@ -45,6 +45,7 @@ public class Legends extends ExpansionSet { private Legends() { super("Legends", "LEG", "", "mage.sets.legends", new GregorianCalendar(1994, 5, 1).getTime(), Constants.SetType.EXPANSION); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Legions.java b/Mage.Sets/src/mage/sets/Legions.java index 4cf5c26e0de..9bc97b08691 100644 --- a/Mage.Sets/src/mage/sets/Legions.java +++ b/Mage.Sets/src/mage/sets/Legions.java @@ -46,6 +46,8 @@ public class Legions extends ExpansionSet { private Legions() { super("Legions", "LGN", "", "mage.sets.legions", new GregorianCalendar(2003, 0, 25).getTime(), Constants.SetType.EXPANSION); this.blockName = "Onslaught"; + this.parentSet = Onslaught.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/MirrodinBesieged.java b/Mage.Sets/src/mage/sets/MirrodinBesieged.java index 26eeff4087d..2199817504c 100644 --- a/Mage.Sets/src/mage/sets/MirrodinBesieged.java +++ b/Mage.Sets/src/mage/sets/MirrodinBesieged.java @@ -28,10 +28,11 @@ package mage.sets; +import java.util.GregorianCalendar; import mage.Constants.SetType; import mage.cards.ExpansionSet; -import java.util.GregorianCalendar; + /** * @@ -47,7 +48,9 @@ public class MirrodinBesieged extends ExpansionSet { private MirrodinBesieged() { super("Mirrodin Besieged", "MBS", "seticon_mtgmbs", "mage.sets.mirrodinbesieged", new GregorianCalendar(2011, 1, 4).getTime(), SetType.EXPANSION); - this.blockName = "Mirrodin Besieged"; + this.blockName = "Scars of Mirrodin"; + this.parentSet = ScarsOfMirrodin.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Morningtide.java b/Mage.Sets/src/mage/sets/Morningtide.java index 2e4760b769b..58f9a734fc1 100644 --- a/Mage.Sets/src/mage/sets/Morningtide.java +++ b/Mage.Sets/src/mage/sets/Morningtide.java @@ -46,6 +46,8 @@ public class Morningtide extends ExpansionSet { private Morningtide() { super("Morningtide", "MOR", "", "mage.sets.morningtide", new GregorianCalendar(2008, 1, 1).getTime(), SetType.EXPANSION); this.blockName = "Lorwyn"; + this.parentSet = Morningtide.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Nemesis.java b/Mage.Sets/src/mage/sets/Nemesis.java index 0e6beb87ae3..58915e92fbd 100644 --- a/Mage.Sets/src/mage/sets/Nemesis.java +++ b/Mage.Sets/src/mage/sets/Nemesis.java @@ -46,6 +46,8 @@ public class Nemesis extends ExpansionSet { private Nemesis() { super("Nemesis", "NMS", "", "mage.sets.nemesis", new GregorianCalendar(2000, 1, 5).getTime(), Constants.SetType.EXPANSION); this.blockName = "Masques"; + this.parentSet = MercadianMasques.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/NewPhyrexia.java b/Mage.Sets/src/mage/sets/NewPhyrexia.java index 7d5311c014b..1c00acb22c9 100644 --- a/Mage.Sets/src/mage/sets/NewPhyrexia.java +++ b/Mage.Sets/src/mage/sets/NewPhyrexia.java @@ -1,9 +1,9 @@ package mage.sets; +import java.util.GregorianCalendar; import mage.Constants; import mage.cards.ExpansionSet; -import java.util.GregorianCalendar; public class NewPhyrexia extends ExpansionSet { private static final NewPhyrexia fINSTANCE = new NewPhyrexia(); @@ -14,7 +14,8 @@ public class NewPhyrexia extends ExpansionSet { private NewPhyrexia() { super("New Phyrexia", "NPH", "", "mage.sets.newphyrexia", new GregorianCalendar(2011, 4, 4).getTime(), Constants.SetType.EXPANSION); - this.blockName = "Mirrodin Besieged"; + this.blockName = "Scars of Mirrodin"; + this.parentSet = ScarsOfMirrodin.getInstance(); this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/PlanarChaos.java b/Mage.Sets/src/mage/sets/PlanarChaos.java index 382af718d7c..9c00033a00f 100644 --- a/Mage.Sets/src/mage/sets/PlanarChaos.java +++ b/Mage.Sets/src/mage/sets/PlanarChaos.java @@ -46,6 +46,8 @@ public class PlanarChaos extends ExpansionSet { private PlanarChaos() { super("Planar Chaos", "PLC", "", "mage.sets.planarchaos", new GregorianCalendar(2007, 1, 2).getTime(), SetType.EXPANSION); this.blockName = "Time Spiral"; + this.parentSet = TimeSpiral.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Planeshift.java b/Mage.Sets/src/mage/sets/Planeshift.java index 3c22609ace7..0d0704227ba 100644 --- a/Mage.Sets/src/mage/sets/Planeshift.java +++ b/Mage.Sets/src/mage/sets/Planeshift.java @@ -46,6 +46,8 @@ public class Planeshift extends ExpansionSet { private Planeshift() { super("Planeshift", "PLS", "", "mage.sets.planeshift", new GregorianCalendar(2001, 1, 5).getTime(), SetType.EXPANSION); this.blockName = "Invasion"; + this.parentSet = Invasion.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Prophecy.java b/Mage.Sets/src/mage/sets/Prophecy.java index 3a946eb66b0..902f6a84c2f 100644 --- a/Mage.Sets/src/mage/sets/Prophecy.java +++ b/Mage.Sets/src/mage/sets/Prophecy.java @@ -46,6 +46,8 @@ public class Prophecy extends ExpansionSet { private Prophecy() { super("Prophecy", "PCY", "", "mage.sets.prophecy", new GregorianCalendar(2000, 4, 27).getTime(), Constants.SetType.EXPANSION); this.blockName = "Masques"; + this.parentSet = MercadianMasques.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/SaviorsOfKamigawa.java b/Mage.Sets/src/mage/sets/SaviorsOfKamigawa.java index 0ba42a27c18..5d0eff9ee02 100644 --- a/Mage.Sets/src/mage/sets/SaviorsOfKamigawa.java +++ b/Mage.Sets/src/mage/sets/SaviorsOfKamigawa.java @@ -46,6 +46,8 @@ public class SaviorsOfKamigawa extends ExpansionSet { private SaviorsOfKamigawa() { super("Saviors of Kamigawa", "SOK", "", "mage.sets.saviorsofkamigawa", new GregorianCalendar(2005, 5, 3).getTime(), SetType.EXPANSION); this.blockName = "Kamigawa"; + this.parentSet = ChampionsOfKamigawa.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/ScarsOfMirrodin.java b/Mage.Sets/src/mage/sets/ScarsOfMirrodin.java index 8e614f45faf..7c734077a41 100644 --- a/Mage.Sets/src/mage/sets/ScarsOfMirrodin.java +++ b/Mage.Sets/src/mage/sets/ScarsOfMirrodin.java @@ -47,7 +47,7 @@ public class ScarsOfMirrodin extends ExpansionSet { private ScarsOfMirrodin() { super("Scars of Mirrodin", "SOM", "seticon_mtgsom", "mage.sets.scarsofmirrodin", new GregorianCalendar(2010, 10, 1).getTime(), SetType.EXPANSION); - this.blockName = "Mirrodin Besieged"; + this.blockName = "Scars of Mirrodin"; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Scourge.java b/Mage.Sets/src/mage/sets/Scourge.java index a5f884cab90..6d1d45c83a3 100644 --- a/Mage.Sets/src/mage/sets/Scourge.java +++ b/Mage.Sets/src/mage/sets/Scourge.java @@ -46,6 +46,8 @@ public class Scourge extends ExpansionSet { private Scourge() { super("Scourge", "SCG", "", "mage.sets.scourge", new GregorianCalendar(2003, 5, 17).getTime(), Constants.SetType.EXPANSION); this.blockName = "Onslaught"; + this.parentSet = Onslaught.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Stronghold.java b/Mage.Sets/src/mage/sets/Stronghold.java index 459cd66b52b..9edc7c59e4e 100644 --- a/Mage.Sets/src/mage/sets/Stronghold.java +++ b/Mage.Sets/src/mage/sets/Stronghold.java @@ -46,6 +46,8 @@ public class Stronghold extends ExpansionSet { private Stronghold() { super("Stronghold", "STH", "", "mage.sets.stronghold", new GregorianCalendar(1998, 1, 21).getTime(), Constants.SetType.EXPANSION); this.blockName = "Tempest"; + this.parentSet = Tempest.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/TheDark.java b/Mage.Sets/src/mage/sets/TheDark.java index d2a8220d50c..0f5dd4197f1 100644 --- a/Mage.Sets/src/mage/sets/TheDark.java +++ b/Mage.Sets/src/mage/sets/TheDark.java @@ -45,6 +45,7 @@ public class TheDark extends ExpansionSet { private TheDark() { super("The Dark", "DRK", "", "mage.sets.thedark", new GregorianCalendar(1994, 7, 1).getTime(), Constants.SetType.EXPANSION); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java b/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java index f520debc20b..e5cff83aa14 100644 --- a/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java +++ b/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java @@ -46,5 +46,7 @@ public class TimeSpiralTimeshifted extends ExpansionSet { private TimeSpiralTimeshifted() { super("Time Spiral \"Timeshifted\"", "TSB", "", "mage.sets.timeshifted", new GregorianCalendar(2006, 9, 9).getTime(), SetType.EXPANSION); this.blockName = "Time Spiral"; + this.parentSet = TimeSpiral.getInstance(); + this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/Torment.java b/Mage.Sets/src/mage/sets/Torment.java index 2119c8f4248..105c5355e86 100644 --- a/Mage.Sets/src/mage/sets/Torment.java +++ b/Mage.Sets/src/mage/sets/Torment.java @@ -46,6 +46,8 @@ public class Torment extends ExpansionSet { private Torment() { super("Torment", "TOR", "", "mage.sets.torment", new GregorianCalendar(2002, 0, 26).getTime(), Constants.SetType.EXPANSION); this.blockName = "Odyssey"; + this.parentSet = Odyssey.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/UrzasDestiny.java b/Mage.Sets/src/mage/sets/UrzasDestiny.java index fa84a27172d..cefd1707834 100644 --- a/Mage.Sets/src/mage/sets/UrzasDestiny.java +++ b/Mage.Sets/src/mage/sets/UrzasDestiny.java @@ -46,6 +46,8 @@ public class UrzasDestiny extends ExpansionSet { private UrzasDestiny() { super("Urza's Destiny", "UDS", "exp_symbol_mtguds", "mage.sets.urzasdestiny", new GregorianCalendar(1999, 6, 23).getTime(), SetType.EXPANSION); this.blockName = "Urza"; + this.parentSet = UrzasSaga.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/UrzasLegacy.java b/Mage.Sets/src/mage/sets/UrzasLegacy.java index 67f5212b5f1..bee37d9c8f0 100644 --- a/Mage.Sets/src/mage/sets/UrzasLegacy.java +++ b/Mage.Sets/src/mage/sets/UrzasLegacy.java @@ -48,6 +48,8 @@ public class UrzasLegacy extends ExpansionSet { private UrzasLegacy() { super("Urza's Legacy", "ULG", "exp_symbol_mtgulg", "mage.sets.urzaslegacy", new GregorianCalendar(1999, 2, 6).getTime(), SetType.EXPANSION); this.blockName = "Urza"; + this.parentSet = UrzasSaga.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Visions.java b/Mage.Sets/src/mage/sets/Visions.java index ef4240bba6f..43dc5b31644 100644 --- a/Mage.Sets/src/mage/sets/Visions.java +++ b/Mage.Sets/src/mage/sets/Visions.java @@ -46,6 +46,8 @@ public class Visions extends ExpansionSet { private Visions() { super("Visions", "VIS", "", "mage.sets.visions", new GregorianCalendar(1997, 0, 11).getTime(), Constants.SetType.EXPANSION); this.blockName = "Mirage"; + this.parentSet = Mirage.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/Weatherlight.java b/Mage.Sets/src/mage/sets/Weatherlight.java index 094f06f46fb..667f978527c 100644 --- a/Mage.Sets/src/mage/sets/Weatherlight.java +++ b/Mage.Sets/src/mage/sets/Weatherlight.java @@ -48,6 +48,8 @@ public class Weatherlight extends ExpansionSet { private Weatherlight() { super("Weatherlight", "WTH", "exp_symbol_mtgwth", "mage.sets.weatherlight", new GregorianCalendar(1997, 5, 31).getTime(), SetType.EXPANSION); this.blockName = "Mirage"; + this.parentSet = Mirage.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Worldwake.java b/Mage.Sets/src/mage/sets/Worldwake.java index 58dbcd70962..4f08bdcfecd 100644 --- a/Mage.Sets/src/mage/sets/Worldwake.java +++ b/Mage.Sets/src/mage/sets/Worldwake.java @@ -48,6 +48,7 @@ public class Worldwake extends ExpansionSet { super("Worldwake", "WWK", "seticon_WWK", "mage.sets.worldwake", new GregorianCalendar(2010, 0, 30).getTime(), SetType.EXPANSION); this.blockName = "Zendikar"; this.parentSet = Zendikar.getInstance(); + this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; this.numBoosterCommon = 11; diff --git a/Mage.Sets/src/mage/sets/gatecrash/Realmwright.java b/Mage.Sets/src/mage/sets/gatecrash/Realmwright.java index 4eff24f2ce2..3722ec4ae84 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/Realmwright.java +++ b/Mage.Sets/src/mage/sets/gatecrash/Realmwright.java @@ -33,18 +33,16 @@ import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.mana.*; import mage.cards.CardImpl; import mage.choices.ChoiceImpl; -import mage.filter.common.FilterArtifactPermanent; -import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledLandPermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -70,7 +68,7 @@ public class Realmwright extends CardImpl { this.addAbility(new AsEntersBattlefieldAbility(new RealmwrightEffect())); // Lands you control are the chosen type in addition to their other types. - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new RealmwrightEffect2())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new RealmwrightEffect2())); } public Realmwright(final Realmwright card) { @@ -143,8 +141,7 @@ class RealmwrightEffect2 extends ContinuousEffectImpl { String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Realmwright"); if (you != null && choice != null) { for (Permanent land : lands) { - if (land != null) { - System.out.println("The land is " + land.getName()); + if (land != null && !land.getSubtype().contains(choice)) { switch (layer) { case TypeChangingEffects_4: if (sublayer == Constants.SubLayer.NA) { diff --git a/Mage/src/mage/cards/ExpansionSet.java b/Mage/src/mage/cards/ExpansionSet.java index 14eac7e2fc1..84eb302d0d9 100644 --- a/Mage/src/mage/cards/ExpansionSet.java +++ b/Mage/src/mage/cards/ExpansionSet.java @@ -55,6 +55,7 @@ public abstract class ExpansionSet implements Serializable { protected List cards; protected SetType setType; protected Map> rarities; + protected boolean hasBasicLands = true; protected String blockName; protected boolean hasBoosters = false; @@ -92,6 +93,10 @@ public abstract class ExpansionSet implements Serializable { return releaseDate; } + public ExpansionSet getParentSet() { + return parentSet; + } + public SetType getSetType() { return setType; } @@ -112,7 +117,7 @@ public abstract class ExpansionSet implements Serializable { } CardCriteria criteria = new CardCriteria(); - criteria.setCodes(parentSet != null ? parentSet.code : this.code).rarities(Rarity.LAND).doubleFaced(false); + criteria.setCodes(!hasBasicLands && parentSet != null ? parentSet.code : this.code).rarities(Rarity.LAND).doubleFaced(false); List basicLand = CardRepository.instance.findCards(criteria); criteria = new CardCriteria(); @@ -173,4 +178,9 @@ public abstract class ExpansionSet implements Serializable { public boolean hasBoosters() { return hasBoosters; } + + public boolean hasBasicLands() { + return hasBasicLands; + } + }