mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
GameFormatQuest allowedSetCodes and bannedCardNames are now final and should never be null (set in the constructors).
This commit is contained in:
@@ -42,8 +42,8 @@ public final class GameFormatQuest {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
// contains allowed sets, when empty allows all sets
|
// contains allowed sets, when empty allows all sets
|
||||||
private List<String> allowedSetCodes;
|
private final List<String> allowedSetCodes;
|
||||||
private List<String> bannedCardNames;
|
private final List<String> bannedCardNames;
|
||||||
|
|
||||||
private Predicate<CardPrinted> filterRules;
|
private Predicate<CardPrinted> filterRules;
|
||||||
private Predicate<CardPrinted> filterPrinted;
|
private Predicate<CardPrinted> filterPrinted;
|
||||||
@@ -106,7 +106,7 @@ public final class GameFormatQuest {
|
|||||||
|
|
||||||
private Predicate<CardPrinted> buildFilterPrinted() {
|
private Predicate<CardPrinted> buildFilterPrinted() {
|
||||||
final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames);
|
final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames);
|
||||||
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
if (this.allowedSetCodes.isEmpty()) {
|
||||||
return banNames;
|
return banNames;
|
||||||
}
|
}
|
||||||
return com.google.common.base.Predicates.and(banNames, CardPrinted.Predicates.printedInSets(this.allowedSetCodes, true));
|
return com.google.common.base.Predicates.and(banNames, CardPrinted.Predicates.printedInSets(this.allowedSetCodes, true));
|
||||||
@@ -114,7 +114,7 @@ public final class GameFormatQuest {
|
|||||||
|
|
||||||
private Predicate<CardPrinted> buildFilterRules() {
|
private Predicate<CardPrinted> buildFilterRules() {
|
||||||
final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames);
|
final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames);
|
||||||
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
if (this.allowedSetCodes.isEmpty()) {
|
||||||
return banNames;
|
return banNames;
|
||||||
}
|
}
|
||||||
return com.google.common.base.Predicates.and(banNames, com.google.common.base.Predicates.compose(CardRulesPredicates.wasPrintedInSets(this.allowedSetCodes), CardPrinted.FN_GET_RULES));
|
return com.google.common.base.Predicates.and(banNames, com.google.common.base.Predicates.compose(CardRulesPredicates.wasPrintedInSets(this.allowedSetCodes), CardPrinted.FN_GET_RULES));
|
||||||
@@ -201,7 +201,7 @@ public final class GameFormatQuest {
|
|||||||
* @return unmodifiable list of excluded sets.
|
* @return unmodifiable list of excluded sets.
|
||||||
*/
|
*/
|
||||||
public List<String> getExcludedSetCodes() {
|
public List<String> getExcludedSetCodes() {
|
||||||
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
if (this.allowedSetCodes.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,9 +221,7 @@ public final class GameFormatQuest {
|
|||||||
* @param setCode String, set code.
|
* @param setCode String, set code.
|
||||||
*/
|
*/
|
||||||
public void unlockSet(final String setCode) {
|
public void unlockSet(final String setCode) {
|
||||||
if (this.allowedSetCodes == null) {
|
if (this.allowedSetCodes.isEmpty()) {
|
||||||
this.allowedSetCodes = new ArrayList<String>(); // this should never happen.
|
|
||||||
} else if (this.allowedSetCodes.isEmpty()) {
|
|
||||||
return; // We are already allowing all sets!
|
return; // We are already allowing all sets!
|
||||||
} else if (this.allowedSetCodes.contains(setCode)) {
|
} else if (this.allowedSetCodes.contains(setCode)) {
|
||||||
return; // Already on the list
|
return; // Already on the list
|
||||||
|
|||||||
Reference in New Issue
Block a user