From afd6bc080df0f47c5297a820180b3312fa2b5bca Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 16 Sep 2017 15:14:52 +0200 Subject: [PATCH] Removed exception for missing subType to prevent empty card list in older deck editors. --- .../src/main/java/mage/constants/SubType.java | 18 ++++++++--------- Mage/src/main/java/mage/util/SubTypeList.java | 20 ++++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index 2cfe62d1e5a..755d1ea658f 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.Set; import java.util.stream.Collectors; - import mage.util.SubTypeList; public enum SubType { @@ -12,7 +11,6 @@ public enum SubType { //205.3k Instants and sorceries share their lists of subtypes; these subtypes are called spell types. ARCANE("Arcane", SubTypeSet.SpellType), TRAP("Trap", SubTypeSet.SpellType), - // 205.3i: Lands have their own unique set of subtypes; these subtypes are called land types. // Of that list, Forest, Island, Mountain, Plains, and Swamp are the basic land types. FOREST("Forest", SubTypeSet.BasicLandType), @@ -28,13 +26,11 @@ public enum SubType { MINE("Mine", SubTypeSet.NonBasicLandType), POWER_PLANT("Power-Plant", SubTypeSet.NonBasicLandType), TOWER("Tower", SubTypeSet.NonBasicLandType), - // 205.3h Enchantments have their own unique set of subtypes; these subtypes are called enchantment types. AURA("Aura", SubTypeSet.EnchantmentType), CARTOUCHE("Cartouche", SubTypeSet.EnchantmentType), CURSE("Curse", SubTypeSet.EnchantmentType), SHRINE("Shrine", SubTypeSet.EnchantmentType), - // 205.3g: Artifacts have their own unique set of subtypes; these subtypes are called artifact types. CLUE("Clue", SubTypeSet.ArtifactType), CONTRAPTION("Contraption", SubTypeSet.ArtifactType), @@ -42,7 +38,6 @@ public enum SubType { FORTIFICATION("Fortification", SubTypeSet.ArtifactType), TREASURE("Treasure", SubTypeSet.ArtifactType), VEHICLE("Vehicle", SubTypeSet.ArtifactType), - // 205.3m : Creatures and tribals share their lists of subtypes; these subtypes are called creature types. // A ADVISOR("Advisor", SubTypeSet.CreatureType), @@ -320,7 +315,7 @@ public enum SubType { TURTLE("Turtle", SubTypeSet.CreatureType), TUSKEN("Tusken", SubTypeSet.CreatureType, true), // Star Wars TROOPER("Trooper", SubTypeSet.CreatureType, true), // Star Wars - TRILOBITE("Trilobite",SubTypeSet.CreatureType), + TRILOBITE("Trilobite", SubTypeSet.CreatureType), TWILEK("Twi'lek", SubTypeSet.CreatureType, true), // Star Wars // U @@ -427,9 +422,12 @@ public enum SubType { return s; } } - throw new IllegalArgumentException("no subtype for " + subType + " exists"); + org.apache.log4j.Logger.getLogger(SubType.class).error("no subtype for " + subType + " exists"); + return null; } + ; + public SubTypeSet getSubTypeSet() { return subTypeSet; } @@ -446,9 +444,9 @@ public enum SubType { public static Set getBasicLands(boolean customSet) { return Arrays.stream(values()) - .filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType) - .filter(s -> s.customSet == customSet) - .collect(Collectors.toSet()); + .filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType) + .filter(s -> s.customSet == customSet) + .collect(Collectors.toSet()); } public static SubTypeList getLandTypes(boolean customSet) { diff --git a/Mage/src/main/java/mage/util/SubTypeList.java b/Mage/src/main/java/mage/util/SubTypeList.java index 8f90b17a8ba..08fc2575ba0 100644 --- a/Mage/src/main/java/mage/util/SubTypeList.java +++ b/Mage/src/main/java/mage/util/SubTypeList.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; - import mage.constants.SubType; public class SubTypeList extends ArrayList { @@ -13,30 +12,33 @@ public class SubTypeList extends ArrayList { @Deprecated public boolean addAll(List subtypes) { return addAll(subtypes.stream() - .map(SubType::byDescription) - .collect(Collectors.toList())); + .map(SubType::byDescription) + .collect(Collectors.toList())); } @Deprecated - public boolean removeAll(List subtypes){ + public boolean removeAll(List subtypes) { return removeAll(subtypes.stream() - .map(SubType::byDescription) - .collect(Collectors.toList())); + .map(SubType::byDescription) + .collect(Collectors.toList())); } - public boolean add(SubType... subTypes) { return Collections.addAll(this, subTypes); } public boolean removeAll(SubType... subTypes) { return super.removeAll(Arrays.stream(subTypes) - .collect(Collectors.toList())); + .collect(Collectors.toList())); } @Deprecated public boolean add(String s) { - return add(SubType.byDescription(s)); + SubType subType = SubType.byDescription(s); + if (subType != null) { + return add(subType); + } + return false; } @Deprecated