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 String
addOrReplaceCard
(String json) Adds or replaces a card for the given JSON.static boolean
static @NotNull CardList
getAll()
getBaseClasses
(DeckFormat deckFormat) Retrieves theHeroClass
strings that correspond to the classes in the specified format.static @NotNull Card
getCardById
(@NotNull String id) Gets a card from the card database by a specific ID.static @Nullable Card
getCardByName
(String name) static Card
getCardByName
(String name, String heroClass) getCards()
Returns a mutable reference to the cards loaded into this catalogue.static CardList
getClassCards
(DeckFormat format) Retrieves all the "class_"Spellsource.CardTypeMessage.CardType.CLASS
cards that specify a hero card, color, heroClass string, etc.static Card
getFormatCard
(String name) static Card
getHeroCard
(String heroClass) static String
static String
static @NotNull Map<String,
CardCatalogueRecord> Gets all theCardCatalogueRecord
objects specified in thecards
module.static int
static void
Loads all the cards from all classpath resources that are recursively inside the "cards" directory.static void
loadAllCards
(String directory) Loads all the cards from the specified directory.static void
loadCards
(Collection<com.hiddenswitch.spellsource.core.ResourceInputStream> inputStreams) Loads all the cards from the specifiedResourceInputStream
instances, which can be a mix of files and resources.static void
loadCardsFromFilesystemDirectories
(String... directories) static void
Loads all the cards specified in the"cards/src/main/resources" + DEFAULT_CARDS_FOLDER
directory in thecards
module.static void
loadCardsFromPackage
(List<com.hiddenswitch.spellsource.core.CardResources> cardResources) Loads all the cards from the specifiedCardResources
instances.static CardList
query
(DeckFormat deckFormat) static CardList
query
(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType) static CardList
query
(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType, com.hiddenswitch.spellsource.rpc.Spellsource.RarityMessage.Rarity rarity, String heroClass) static @NotNull CardList
query
(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 CardList
query
(DeckFormat deckFormat, String heroClass) static CardList
query
(DeckFormat deckFormat, Predicate<Card> filter) static void
removeCard
(String id) Removes the specified card by ID from the catalogue.static void
setVersion
(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/cards
directory. Staging cards are never retrieved. The catalogue does not respectDeckFormat
filters 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 forTrace
objects.)
-
getRecords
Gets all theCardCatalogueRecord
objects specified in thecards
module.- Returns:
-
getCardByName
-
getCardByName
-
query
-
query
-
loadCardsFromPackage
public static void loadCardsFromPackage(List<com.hiddenswitch.spellsource.core.CardResources> cardResources) Loads all the cards from the specifiedCardResources
instances.- Parameters:
cardResources
-
-
addOrReplaceCard
Adds or replaces a card for the given JSON.If a
CardDesc.getName()
name
field 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 specifiedResourceInputStream
instances, 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_FOLDER
directory in thecards
module. 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.CLASS
cards that specify a hero card, color, heroClass string, etc. for the specified class in the specified format.- Parameters:
format
-- Returns:
-
getBaseClasses
Retrieves theHeroClass
strings 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)
-