mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Add Quest World option to card and deck advanced search options
This commit is contained in:
@@ -3,6 +3,7 @@ package forge.itemmanager;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
@@ -26,6 +27,7 @@ import forge.interfaces.IButton;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestWorld;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.util.gui.SOptionPane;
|
||||
|
||||
@@ -70,6 +72,16 @@ public class AdvancedSearch {
|
||||
return FModel.getFormats().getAllFormatsOfCard(input);
|
||||
}
|
||||
}),
|
||||
CARD_QUEST_WORLD("Quest World", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator<PaperCard, QuestWorld>(ImmutableList.copyOf(FModel.getWorlds())) {
|
||||
@Override
|
||||
protected QuestWorld getItemValue(PaperCard input) {
|
||||
throw new RuntimeException("getItemValues should be called instead");
|
||||
}
|
||||
@Override
|
||||
protected Set<QuestWorld> getItemValues(PaperCard input) {
|
||||
return QuestWorld.getAllQuestWorldsOfCard(input);
|
||||
}
|
||||
}),
|
||||
CARD_COLOR("Color", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new ColorEvaluator<PaperCard>() {
|
||||
@Override
|
||||
protected MagicColor.Color getItemValue(PaperCard input) {
|
||||
@@ -196,6 +208,16 @@ public class AdvancedSearch {
|
||||
return input.getFormats();
|
||||
}
|
||||
}),
|
||||
DECK_QUEST_WORLD("Quest World", DeckProxy.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator<DeckProxy, QuestWorld>(ImmutableList.copyOf(FModel.getWorlds())) {
|
||||
@Override
|
||||
protected QuestWorld getItemValue(DeckProxy input) {
|
||||
throw new RuntimeException("getItemValues should be called instead");
|
||||
}
|
||||
@Override
|
||||
protected Set<QuestWorld> getItemValues(DeckProxy input) {
|
||||
return QuestWorld.getAllQuestWorldsOfDeck(input.getDeck());
|
||||
}
|
||||
}),
|
||||
DECK_COLOR("Color", DeckProxy.class, FilterOperator.MULTI_LIST_OPS, new ColorEvaluator<DeckProxy>() {
|
||||
@Override
|
||||
protected MagicColor.Color getItemValue(DeckProxy input) {
|
||||
|
||||
@@ -18,12 +18,19 @@
|
||||
package forge.quest;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameFormat;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.data.GameFormatQuest;
|
||||
import forge.util.storage.StorageReaderFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This function holds the "world info" for the current quest.
|
||||
@@ -181,4 +188,32 @@ public class QuestWorld implements Comparable<QuestWorld>{
|
||||
}
|
||||
return name.compareTo(other.name);
|
||||
}
|
||||
|
||||
public static Set<QuestWorld> getAllQuestWorldsOfCard(PaperCard card) {
|
||||
Set<QuestWorld> result = new HashSet<QuestWorld>();
|
||||
for (QuestWorld qw : FModel.getWorlds()) {
|
||||
GameFormat format = qw.getFormat();
|
||||
if (format == null) {
|
||||
format = FModel.getQuest().getMainFormat();
|
||||
}
|
||||
if (format == null || format.getFilterRules().apply(card)) {
|
||||
result.add(qw);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Set<QuestWorld> getAllQuestWorldsOfDeck(Deck deck) {
|
||||
Set<QuestWorld> result = new HashSet<QuestWorld>();
|
||||
for (QuestWorld qw : FModel.getWorlds()) {
|
||||
GameFormat format = qw.getFormat();
|
||||
if (format == null) {
|
||||
format = FModel.getQuest().getMainFormat();
|
||||
}
|
||||
if (format == null || format.isDeckLegal(deck)) {
|
||||
result.add(qw);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user