Class CardCatalogue
java.lang.Object
net.demilich.metastone.game.cards.CardCatalogue
A place that stores
CardCatalogueRecord records that were generated from the "cards" Java package.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddOrReplaceCard(String json) Adds or replaces a card for the given JSON.static booleanstatic @NotNull CardListgetAll()getBaseClasses(DeckFormat deckFormat) Retrieves theHeroClassstrings that correspond to the classes in the specified format.static @NotNull CardgetCardById(@NotNull String id) Gets a card from the card database by a specific ID.static @Nullable CardgetCardByName(String name) static CardgetCardByName(String name, String heroClass) getCards()Returns a mutable reference to the cards loaded into this catalogue.static CardListgetClassCards(DeckFormat format) Retrieves all the "class_"Spellsource.CardTypeMessage.CardType.CLASScards that specify a hero card, color, heroClass string, etc.static CardgetFormatCard(String name) static CardgetHeroCard(String heroClass) static Stringstatic Stringstatic @NotNull Map<String,CardCatalogueRecord> Gets all theCardCatalogueRecordobjects specified in thecardsmodule.static intstatic voidLoads all the cards from all classpath resources that are recursively inside the "cards" directory.static voidloadAllCards(String directory) Loads all the cards from the specified directory.static voidloadCards(Collection<com.hiddenswitch.spellsource.core.ResourceInputStream> inputStreams) Loads all the cards from the specifiedResourceInputStreaminstances, which can be a mix of files and resources.static voidloadCardsFromFilesystemDirectories(String... directories) static voidLoads all the cards specified in the"cards/src/main/resources" + DEFAULT_CARDS_FOLDERdirectory in thecardsmodule.static voidloadCardsFromPackage(List<com.hiddenswitch.spellsource.core.CardResources> cardResources) Loads all the cards from the specifiedCardResourcesinstances.static CardListquery(DeckFormat deckFormat) static CardListquery(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType) static CardListquery(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType, com.hiddenswitch.spellsource.rpc.Spellsource.RarityMessage.Rarity rarity, String heroClass) static @NotNull CardListquery(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType, com.hiddenswitch.spellsource.rpc.Spellsource.RarityMessage.Rarity rarity, String heroClass, Attribute tag, boolean clone) Queries the card catalogue for cards that match the specified filters.static CardListquery(DeckFormat deckFormat, String heroClass) static CardListquery(DeckFormat deckFormat, Predicate<Card> filter) static voidremoveCard(String id) Removes the specified card by ID from the catalogue.static voidsetVersion(int version) stream()static void
-
Field Details
-
FORMATS
-
-
Constructor Details
-
CardCatalogue
public CardCatalogue()
-
-
Method Details
-
getBannedDraftCards
-
getHardRemovalCardIds
-
getOneOneNeutralMinionCardId
-
getNeutralHero
-
getAll
-
getCards
Returns a mutable reference to the cards loaded into this catalogue.Changing the cards here changes all their references in all games. However,
getCardById(String)returns clones.- Returns:
-
getCardById
Gets a card from the card database by a specific ID. These IDs correspond to the names of the JSON files in thecards/src/main/resources/cardsdirectory. Staging cards are never retrieved. The catalogue does not respectDeckFormatfilters here, and will return any card with a valid ID.Some effects, like
CastFromGroupSpell, create temporary cards that exist only in the game context. Generally, you should callGameContext.getCardById(String)in order to correctly retrieve those cards.- Parameters:
id-- Returns:
- Throws:
NullPointerException- if the card cannot be found or if the card's version exceeds the currently configured version. (Versions are only used forTraceobjects.)
-
getRecords
Gets all theCardCatalogueRecordobjects specified in thecardsmodule.- Returns:
-
getCardByName
-
getCardByName
-
query
-
query
-
loadCardsFromPackage
public static void loadCardsFromPackage(List<com.hiddenswitch.spellsource.core.CardResources> cardResources) Loads all the cards from the specifiedCardResourcesinstances.- Parameters:
cardResources-
-
addOrReplaceCard
Adds or replaces a card for the given JSON.If a
CardDesc.getName()namefield is specified and noid, the- Parameters:
json-- Throws:
IOException
-
removeCard
Removes the specified card by ID from the catalogue.- Parameters:
id-
-
loadCards
public static void loadCards(Collection<com.hiddenswitch.spellsource.core.ResourceInputStream> inputStreams) Loads all the cards from the specifiedResourceInputStreaminstances, which can be a mix of files and resources.- Parameters:
inputStreams-
-
loadAllCards
public static void loadAllCards()Loads all the cards from all classpath resources that are recursively inside the "cards" directory. -
loadCardsFromFilesystemDirectories
-
loadAllCards
Loads all the cards from the specified directory.Prevents
loadCardsFromPackage()from also redundantly loading the same cards.Does not use ClassGraph so does not need to allocate direct byte buffers.
- Parameters:
directory-
-
unloadCards
public static void unloadCards() -
loadCardsFromPackage
public static void loadCardsFromPackage()Loads all the cards specified in the"cards/src/main/resources" + DEFAULT_CARDS_FOLDERdirectory in thecardsmodule. This can be called multiple times, but will not "refresh" the catalogue file. -
firstLoad
public static boolean firstLoad() -
getFormatCard
-
getHeroCard
-
getClassCards
Retrieves all the "class_"Spellsource.CardTypeMessage.CardType.CLASScards that specify a hero card, color, heroClass string, etc. for the specified class in the specified format.- Parameters:
format-- Returns:
-
getBaseClasses
Retrieves theHeroClassstrings that correspond to the classes in the specified format.- Parameters:
deckFormat-- Returns:
-
query
-
stream
-
getVersion
public static int getVersion() -
setVersion
public static void setVersion(int version)
-