mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Removed exception for missing subType to prevent empty card list in older deck editors.
This commit is contained in:
parent
d66a9d1693
commit
afd6bc080d
2 changed files with 19 additions and 19 deletions
|
@ -4,7 +4,6 @@ import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import mage.util.SubTypeList;
|
import mage.util.SubTypeList;
|
||||||
|
|
||||||
public enum SubType {
|
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.
|
//205.3k Instants and sorceries share their lists of subtypes; these subtypes are called spell types.
|
||||||
ARCANE("Arcane", SubTypeSet.SpellType),
|
ARCANE("Arcane", SubTypeSet.SpellType),
|
||||||
TRAP("Trap", SubTypeSet.SpellType),
|
TRAP("Trap", SubTypeSet.SpellType),
|
||||||
|
|
||||||
// 205.3i: Lands have their own unique set of subtypes; these subtypes are called land types.
|
// 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.
|
// Of that list, Forest, Island, Mountain, Plains, and Swamp are the basic land types.
|
||||||
FOREST("Forest", SubTypeSet.BasicLandType),
|
FOREST("Forest", SubTypeSet.BasicLandType),
|
||||||
|
@ -28,13 +26,11 @@ public enum SubType {
|
||||||
MINE("Mine", SubTypeSet.NonBasicLandType),
|
MINE("Mine", SubTypeSet.NonBasicLandType),
|
||||||
POWER_PLANT("Power-Plant", SubTypeSet.NonBasicLandType),
|
POWER_PLANT("Power-Plant", SubTypeSet.NonBasicLandType),
|
||||||
TOWER("Tower", SubTypeSet.NonBasicLandType),
|
TOWER("Tower", SubTypeSet.NonBasicLandType),
|
||||||
|
|
||||||
// 205.3h Enchantments have their own unique set of subtypes; these subtypes are called enchantment types.
|
// 205.3h Enchantments have their own unique set of subtypes; these subtypes are called enchantment types.
|
||||||
AURA("Aura", SubTypeSet.EnchantmentType),
|
AURA("Aura", SubTypeSet.EnchantmentType),
|
||||||
CARTOUCHE("Cartouche", SubTypeSet.EnchantmentType),
|
CARTOUCHE("Cartouche", SubTypeSet.EnchantmentType),
|
||||||
CURSE("Curse", SubTypeSet.EnchantmentType),
|
CURSE("Curse", SubTypeSet.EnchantmentType),
|
||||||
SHRINE("Shrine", SubTypeSet.EnchantmentType),
|
SHRINE("Shrine", SubTypeSet.EnchantmentType),
|
||||||
|
|
||||||
// 205.3g: Artifacts have their own unique set of subtypes; these subtypes are called artifact types.
|
// 205.3g: Artifacts have their own unique set of subtypes; these subtypes are called artifact types.
|
||||||
CLUE("Clue", SubTypeSet.ArtifactType),
|
CLUE("Clue", SubTypeSet.ArtifactType),
|
||||||
CONTRAPTION("Contraption", SubTypeSet.ArtifactType),
|
CONTRAPTION("Contraption", SubTypeSet.ArtifactType),
|
||||||
|
@ -42,7 +38,6 @@ public enum SubType {
|
||||||
FORTIFICATION("Fortification", SubTypeSet.ArtifactType),
|
FORTIFICATION("Fortification", SubTypeSet.ArtifactType),
|
||||||
TREASURE("Treasure", SubTypeSet.ArtifactType),
|
TREASURE("Treasure", SubTypeSet.ArtifactType),
|
||||||
VEHICLE("Vehicle", SubTypeSet.ArtifactType),
|
VEHICLE("Vehicle", SubTypeSet.ArtifactType),
|
||||||
|
|
||||||
// 205.3m : Creatures and tribals share their lists of subtypes; these subtypes are called creature types.
|
// 205.3m : Creatures and tribals share their lists of subtypes; these subtypes are called creature types.
|
||||||
// A
|
// A
|
||||||
ADVISOR("Advisor", SubTypeSet.CreatureType),
|
ADVISOR("Advisor", SubTypeSet.CreatureType),
|
||||||
|
@ -320,7 +315,7 @@ public enum SubType {
|
||||||
TURTLE("Turtle", SubTypeSet.CreatureType),
|
TURTLE("Turtle", SubTypeSet.CreatureType),
|
||||||
TUSKEN("Tusken", SubTypeSet.CreatureType, true), // Star Wars
|
TUSKEN("Tusken", SubTypeSet.CreatureType, true), // Star Wars
|
||||||
TROOPER("Trooper", 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
|
TWILEK("Twi'lek", SubTypeSet.CreatureType, true), // Star Wars
|
||||||
|
|
||||||
// U
|
// U
|
||||||
|
@ -427,9 +422,12 @@ public enum SubType {
|
||||||
return s;
|
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() {
|
public SubTypeSet getSubTypeSet() {
|
||||||
return subTypeSet;
|
return subTypeSet;
|
||||||
}
|
}
|
||||||
|
@ -446,9 +444,9 @@ public enum SubType {
|
||||||
|
|
||||||
public static Set<SubType> getBasicLands(boolean customSet) {
|
public static Set<SubType> getBasicLands(boolean customSet) {
|
||||||
return Arrays.stream(values())
|
return Arrays.stream(values())
|
||||||
.filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType)
|
.filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType)
|
||||||
.filter(s -> s.customSet == customSet)
|
.filter(s -> s.customSet == customSet)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SubTypeList getLandTypes(boolean customSet) {
|
public static SubTypeList getLandTypes(boolean customSet) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
|
||||||
public class SubTypeList extends ArrayList<SubType> {
|
public class SubTypeList extends ArrayList<SubType> {
|
||||||
|
@ -13,30 +12,33 @@ public class SubTypeList extends ArrayList<SubType> {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean addAll(List<String> subtypes) {
|
public boolean addAll(List<String> subtypes) {
|
||||||
return addAll(subtypes.stream()
|
return addAll(subtypes.stream()
|
||||||
.map(SubType::byDescription)
|
.map(SubType::byDescription)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean removeAll(List<String> subtypes){
|
public boolean removeAll(List<String> subtypes) {
|
||||||
return removeAll(subtypes.stream()
|
return removeAll(subtypes.stream()
|
||||||
.map(SubType::byDescription)
|
.map(SubType::byDescription)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean add(SubType... subTypes) {
|
public boolean add(SubType... subTypes) {
|
||||||
return Collections.addAll(this, subTypes);
|
return Collections.addAll(this, subTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeAll(SubType... subTypes) {
|
public boolean removeAll(SubType... subTypes) {
|
||||||
return super.removeAll(Arrays.stream(subTypes)
|
return super.removeAll(Arrays.stream(subTypes)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean add(String s) {
|
public boolean add(String s) {
|
||||||
return add(SubType.byDescription(s));
|
SubType subType = SubType.byDescription(s);
|
||||||
|
if (subType != null) {
|
||||||
|
return add(subType);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
Loading…
Reference in a new issue