The default Model implementation for Forge. This used to be an interface, but it seems unlikely that we will ever use a different model. In case we need to convert it into an interface in the future, all fields of this class must be either private or public static final.
| 75 | * this class must be either private or public static final. |
| 76 | */ |
| 77 | public final class FModel { |
| 78 | private FModel() { } //don't allow creating instance |
| 79 | |
| 80 | private static CardStorageReader reader, tokenReader, customReader, customTokenReader; |
| 81 | private static final Supplier<StaticData> magicDb = Suppliers.memoize(() -> |
| 82 | new StaticData(reader, tokenReader, customReader, customTokenReader, ForgeConstants.EDITIONS_DIR, |
| 83 | ForgeConstants.USER_CUSTOM_EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR, ForgeConstants.SETLOOKUP_DIR, |
| 84 | getPreferences().getPref(FPref.UI_PREFERRED_ART), |
| 85 | getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), |
| 86 | getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS), |
| 87 | getPreferences().getPrefBoolean(FPref.ALLOW_CUSTOM_CARDS_IN_DECKS_CONFORMANCE), |
| 88 | getPreferences().getPrefBoolean(FPref.UI_SMART_CARD_ART))); |
| 89 | private static final Supplier<QuestPreferences> questPreferences = Suppliers.memoize(QuestPreferences::new); |
| 90 | private static final Supplier<ConquestPreferences> conquestPreferences = Suppliers.memoize(() -> { |
| 91 | final ConquestPreferences cp = new ConquestPreferences(); |
| 92 | ConquestUtil.updateRarityFilterOdds(cp); |
| 93 | return cp; |
| 94 | }); |
| 95 | private static final Supplier<ForgePreferences> preferences = Suppliers.memoize(ForgePreferences::new); |
| 96 | private static final Supplier<ForgeNetPreferences> netPreferences = Suppliers.memoize(ForgeNetPreferences::new); |
| 97 | private static final Supplier<Map<GameType, AchievementCollection>> achievements = Suppliers.memoize(() -> { |
| 98 | final Map<GameType, AchievementCollection> a = Maps.newHashMap(); |
| 99 | a.put(GameType.Constructed, new ConstructedAchievements()); |
| 100 | a.put(GameType.Draft, new DraftAchievements()); |
| 101 | a.put(GameType.Sealed, new SealedAchievements()); |
| 102 | a.put(GameType.Quest, new QuestAchievements()); |
| 103 | a.put(GameType.PlanarConquest, new PlanarConquestAchievements()); |
| 104 | a.put(GameType.Puzzle, new PuzzleAchievements()); |
| 105 | a.put(GameType.Adventure, new AdventureAchievements()); |
| 106 | return a; |
| 107 | }); |
| 108 | |
| 109 | // Someone should take care of 2 gauntlets here |
| 110 | private static TournamentData tournamentData; |
| 111 | private static GauntletData gauntletData; |
| 112 | private static final Supplier<GauntletMini> gauntletMini = Suppliers.memoize(GauntletMini::new); |
| 113 | |
| 114 | private static final Supplier<QuestController> quest = Suppliers.memoize(QuestController::new); |
| 115 | private static final Supplier<ConquestController> conquest = Suppliers.memoize(ConquestController::new); |
| 116 | private static final Supplier<CardCollections> decks = Suppliers.memoize(CardCollections::new); |
| 117 | |
| 118 | private static final Supplier<IStorage<CardBlock>> blocks = Suppliers.memoize( |
| 119 | () -> (IStorage<CardBlock>) new StorageBase<CardBlock>("Block definitions", new CardBlock.Reader( |
| 120 | ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", getMagicDb().getEditions()))); |
| 121 | private static final Supplier<IStorage<CardBlock>> fantasyBlocks = Suppliers.memoize(() -> new StorageBase<>("Custom blocks", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "fantasyblocks.txt", getMagicDb().getEditions()))); |
| 122 | private static final Supplier<IStorage<ThemedChaosDraft>> themedChaosDrafts = Suppliers.memoize(() -> new StorageBase<>("Themed Chaos Drafts", new ThemedChaosDraft.Reader(ForgeConstants.BLOCK_DATA_DIR + "chaosdraftthemes.txt"))); |
| 123 | private static final Supplier<IStorage<ConquestPlane>> planes = Suppliers.memoize(() -> new StorageBase<>("Conquest planes", new ConquestPlane.Reader(ForgeConstants.CONQUEST_PLANES_DIR + "planes.txt"))); |
| 124 | private static final Supplier<IStorage<QuestWorld>> worlds = Suppliers.memoize(() -> { |
| 125 | final Map<String, QuestWorld> standardWorlds = new QuestWorld.Reader(ForgeConstants.QUEST_WORLD_DIR + "worlds.txt").readAll(); |
| 126 | final Map<String, QuestWorld> customWorlds = new QuestWorld.Reader(ForgeConstants.USER_QUEST_WORLD_DIR + "customworlds.txt").readAll(); |
| 127 | customWorlds.values().forEach(world -> world.setCustom(true)); |
| 128 | standardWorlds.putAll(customWorlds); |
| 129 | final IStorage<QuestWorld> w = new StorageBase<>("Quest worlds", null, standardWorlds); |
| 130 | return w; |
| 131 | }); |
| 132 | private static final Supplier<GameFormat.Collection> formats = Suppliers.memoize(() -> new GameFormat.Collection(new GameFormat.Reader( new File(ForgeConstants.FORMATS_DATA_DIR), new File(ForgeConstants.USER_FORMATS_DIR), getPreferences().getPrefBoolean(FPref.LOAD_ARCHIVED_FORMATS)))); |
| 133 | private static final Supplier<ItemPool<PaperCard>> allCards = Suppliers.memoize(() -> ItemPool.createFrom(getMagicDb().getCommonCards().getAllCards(), PaperCard.class)); |
| 134 | private static final Supplier<ItemPool<PaperCard>> planechaseCards = Suppliers.memoize(() -> ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_PLANE_OR_PHENOMENON)), PaperCard.class)); |
nothing calls this directly
no test coverage detected