MCPcopy Create free account
hub / github.com/Card-Forge/forge / FDeckEditor

Class FDeckEditor

forge-gui-mobile/src/forge/deck/FDeckEditor.java:53–2665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51import java.util.stream.Collectors;
52
53public class FDeckEditor extends TabPageScreen<FDeckEditor> {
54 public static FSkinImage MAIN_DECK_ICON = Forge.hdbuttons ? FSkinImage.HDLIBRARY :FSkinImage.DECKLIST;
55 public static FSkinImage SIDEBOARD_ICON = Forge.hdbuttons ? FSkinImage.HDSIDEBOARD : FSkinImage.FLASHBACK;
56 private static final float HEADER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
57
58 //Toggle that suppresses most conformity logic in the editor.
59 public static final String DECK_TAG_SUPPRESS_CONFORMITY = "noEditorConformity";
60
61 public static abstract class DeckEditorConfig {
62 public abstract GameType getGameType();
63 public DeckFormat getDeckFormat() {
64 GameType gameType = getGameType();
65 return gameType == null ? null : gameType.getDeckFormat();
66 }
67
68 public ItemPool<PaperCard> getCardPool() {
69 return FModel.getAllCards();
70 }
71 protected Predicate<PaperCard> getCardFilter() { return null; }
72
73 public boolean isLimited() { return false; } //TODO: Figure out if I can derive this from gameType; Has different meaning for Quest...
74 public boolean usePlayerInventory() { return false; }
75 public boolean isDraft() { return false; } //Draft and quest draft
76 public boolean hasInfiniteCardPool() { return !isLimited() && !usePlayerInventory(); }
77 public boolean hasCommander() {
78 DeckFormat deckFormat = getDeckFormat();
79 return deckFormat != null && deckFormat.hasCommander();
80 }
81 public boolean allowsCardReplacement() { return hasInfiniteCardPool() || usePlayerInventory(); }
82
83 public List<CardEdition> getBasicLandSets(Deck currentDeck) {
84 if(hasInfiniteCardPool())
85 return FModel.getMagicDb().getSortedEditions().stream().filter(CardEdition::hasBasicLands).collect(Collectors.toList());
86 return List.of(DeckProxy.getDefaultLandSet(currentDeck));
87 }
88
89 protected abstract IDeckController getController();
90 protected abstract DeckEditorPage[] getInitialPages();
91
92 public DeckSection[] getPrimarySections() {
93 if(getGameType() != null)
94 return getGameType().getPrimaryDeckSections().toArray(new DeckSection[0]);
95 return new DeckSection[]{DeckSection.Main, DeckSection.Sideboard};
96 }
97
98 public DeckSection[] getExtraSections() {
99 if(getGameType() != null)
100 return getGameType().getSupplimentalDeckSections().toArray(new DeckSection[0]);
101 return new DeckSection[]{DeckSection.Attractions, DeckSection.Contraptions};
102 }
103
104 private IDeckController initDeckController(String editDeckName, String editDeckPath) {
105 if(StringUtils.isEmpty(editDeckName))
106 return initDeckController();
107 IDeckController controller = this.getController();
108 if(!(controller instanceof FileDeckController<?>))
109 throw new UnsupportedOperationException("Tried to load a deck by file name without a FileDeckController.");
110 controller.setEditor(null);

Callers

nothing calls this directly

Calls 15

getDecksMethod · 0.95
getQuestMethod · 0.95
getInstanceMethod · 0.95
getConstructedMethod · 0.80
setSideboardConfigMethod · 0.80
getSealedMethod · 0.80
getWinstonMethod · 0.80
getCommanderMethod · 0.80
setCardFilterMethod · 0.80
getTinyLeadersMethod · 0.80
isLegalCardPredicateMethod · 0.80
getBrawlMethod · 0.80

Tested by

no test coverage detected