From 77e92d9186f37642d93202740836a2aa8a552c35 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 6 Jun 2019 22:50:16 +0400 Subject: [PATCH] * Fixed that snow lands can be added in draft and sealed modes (#5831); --- .../mage/client/dialog/AddLandDialog.java | 12 ++++++++++-- .../java/mage/verify/VerifyCardDataTest.java | 19 ++++++++++++++++++- .../mage/cards/repository/CardRepository.java | 7 +++++++ 3 files changed, 35 insertions(+), 3 deletions(-) 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 e3c067ca5d..c365da6d9d 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java @@ -37,6 +37,10 @@ public class AddLandDialog extends MageDialog { this.setModal(true); } + private boolean setHaveSnowLands(ExpansionInfo exp) { + return CardRepository.instance.haveSnowLands(exp.getCode()); + } + public void showDialog(Deck deck, DeckEditorMode mode) { this.deck = deck; SortedSet landSetNames = new TreeSet<>(); @@ -45,7 +49,7 @@ public class AddLandDialog extends MageDialog { // decide from which sets basic lands are taken from for (String setCode : deck.getExpansionSetCodes()) { ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode); - if (expansionInfo != null && expansionInfo.hasBasicLands()) { + if (expansionInfo != null && expansionInfo.hasBasicLands() && !setHaveSnowLands(expansionInfo)) { defaultSetName = expansionInfo.getName(); break; } @@ -58,7 +62,7 @@ public class AddLandDialog extends MageDialog { if (expansionInfo != null) { List blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); for (ExpansionInfo blockSet : blockSets) { - if (blockSet.hasBasicLands()) { + if (blockSet.hasBasicLands() && !setHaveSnowLands(expansionInfo)) { defaultSetName = expansionInfo.getName(); break; } @@ -70,6 +74,10 @@ public class AddLandDialog extends MageDialog { // if still no set with lands found, add list of all available List basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate(); for (ExpansionInfo expansionInfo : basicLandSets) { + // snow lands only in free mode + if (mode != DeckEditorMode.FREE_BUILDING && setHaveSnowLands(expansionInfo)) { + continue; + } landSetNames.add(expansionInfo.getName()); } if (landSetNames.isEmpty()) { diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index 42b5ebf52e..b045559fee 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -358,6 +358,23 @@ public class VerifyCardDataTest { // TODO: add test to check num cards (hasBasicLands and numLand > 0) } + // 3. wrong snow land info + for (ExpansionSet set : sets) { + boolean needSnow = CardRepository.instance.haveSnowLands(set.getCode()); + boolean haveSnow = false; + for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) { + if (card.getName().startsWith("Snow-Covered ")) { + haveSnow = true; + break; + } + } + if (needSnow != haveSnow) { + errorsList.add("error, found wrong snow lands info in set " + set.getCode() + ": " + + (haveSnow ? "set have snow card" : "set haven't snow card") + + ", but xmage think that it " + (needSnow ? "have" : "haven't")); + } + } + // TODO: add test to check num cards for rarity (rarityStats > 0 and numRarity > 0) printMessages(warningsList); printMessages(errorsList); @@ -740,7 +757,7 @@ public class VerifyCardDataTest { private void checkWrongAbilitiesText(Card card, JsonCard ref) { // checks missing or wrong text - if (!card.getExpansionSetCode().equals("WAR")) { + if (!card.getExpansionSetCode().equals("MH1")) { return; } diff --git a/Mage/src/main/java/mage/cards/repository/CardRepository.java b/Mage/src/main/java/mage/cards/repository/CardRepository.java index e54d6e4812..4e57a12ddd 100644 --- a/Mage/src/main/java/mage/cards/repository/CardRepository.java +++ b/Mage/src/main/java/mage/cards/repository/CardRepository.java @@ -176,6 +176,13 @@ public enum CardRepository { return names; } + public Boolean haveSnowLands(String setCode) { + return setCode.equals("CSP") + || setCode.equals("MH1") + || setCode.equals("ME2") + || setCode.equals("ICE"); + } + public Set getNonbasicLandNames() { Set names = new TreeSet<>(); try {