mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Add advanced search for region
This commit is contained in:
@@ -84,6 +84,16 @@ public class AdvancedSearch {
|
|||||||
return ConquestPlane.getAllPlanesOfCard(input);
|
return ConquestPlane.getAllPlanesOfCard(input);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
CARD_REGION("Region", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator<PaperCard, ConquestPlane.Region>(ConquestPlane.getAllRegions()) {
|
||||||
|
@Override
|
||||||
|
protected ConquestPlane.Region getItemValue(PaperCard input) {
|
||||||
|
throw new RuntimeException("getItemValues should be called instead");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Set<ConquestPlane.Region> getItemValues(PaperCard input) {
|
||||||
|
return ConquestPlane.getAllRegionsOfCard(input);
|
||||||
|
}
|
||||||
|
}),
|
||||||
CARD_QUEST_WORLD("Quest World", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator<PaperCard, QuestWorld>(ImmutableList.copyOf(FModel.getWorlds())) {
|
CARD_QUEST_WORLD("Quest World", PaperCard.class, FilterOperator.MULTI_LIST_OPS, new CustomListEvaluator<PaperCard, QuestWorld>(ImmutableList.copyOf(FModel.getWorlds())) {
|
||||||
@Override
|
@Override
|
||||||
protected QuestWorld getItemValue(PaperCard input) {
|
protected QuestWorld getItemValue(PaperCard input) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.planarconquest;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -355,6 +356,10 @@ public enum ConquestPlane {
|
|||||||
bannedCards.addAll(bannedCards0);
|
bannedCards.addAll(bannedCards0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Region region : regions) {
|
||||||
|
region.plane = this;
|
||||||
|
}
|
||||||
|
|
||||||
CardDb commonCards = FModel.getMagicDb().getCommonCards();
|
CardDb commonCards = FModel.getMagicDb().getCommonCards();
|
||||||
for (String setCode : setCodes0) {
|
for (String setCode : setCodes0) {
|
||||||
CardEdition edition = FModel.getMagicDb().getEditions().get(setCode);
|
CardEdition edition = FModel.getMagicDb().getEditions().get(setCode);
|
||||||
@@ -466,6 +471,7 @@ public enum ConquestPlane {
|
|||||||
private final DeckGenPool cardPool = new DeckGenPool();
|
private final DeckGenPool cardPool = new DeckGenPool();
|
||||||
private final FCollection<PaperCard> commanders = new FCollection<PaperCard>();
|
private final FCollection<PaperCard> commanders = new FCollection<PaperCard>();
|
||||||
|
|
||||||
|
private ConquestPlane plane;
|
||||||
private ISkinImage art;
|
private ISkinImage art;
|
||||||
|
|
||||||
private Region(String name0, String artCardName0, final int colorMask) {
|
private Region(String name0, String artCardName0, final int colorMask) {
|
||||||
@@ -509,8 +515,12 @@ public enum ConquestPlane {
|
|||||||
return commanders;
|
return commanders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConquestPlane getPlane() {
|
||||||
|
return plane;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return plane.name + " - " + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,4 +660,28 @@ public enum ConquestPlane {
|
|||||||
}
|
}
|
||||||
return planes;
|
return planes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<Region> getAllRegionsOfCard(PaperCard card) {
|
||||||
|
Set<Region> regions = new HashSet<Region>();
|
||||||
|
for (ConquestPlane plane : values()) {
|
||||||
|
if (plane.cardPool.contains(card)) {
|
||||||
|
for (Region region : plane.getRegions()) {
|
||||||
|
if (region.cardPool.contains(card)) {
|
||||||
|
regions.add(region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return regions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Region> getAllRegions() {
|
||||||
|
List<Region> regions = new ArrayList<Region>();
|
||||||
|
for (ConquestPlane plane : values()) {
|
||||||
|
for (Region region : plane.getRegions()) {
|
||||||
|
regions.add(region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return regions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user