Class CardCatalogue


public class CardCatalogue extends Object
A place that stores CardCatalogueRecord records that were generated from the "cards" Java package.
  • Field Details

  • Constructor Details

    • CardCatalogue

      public CardCatalogue()
  • Method Details

    • getBannedDraftCards

      public static Set<String> getBannedDraftCards()
    • getHardRemovalCardIds

      public static Set<String> getHardRemovalCardIds()
    • getOneOneNeutralMinionCardId

      public static String getOneOneNeutralMinionCardId()
    • getNeutralHero

      public static String getNeutralHero()
    • getAll

      @NotNull public static @NotNull CardList getAll()
    • getCards

      @NotNull public static @NotNull Map<String,Card> 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.

    • getCardById

      @NotNull public static @NotNull Card getCardById(@NotNull @NotNull String id)
      Gets a card from the card database by a specific ID. These IDs correspond to the names of the JSON files in the cards/src/main/resources/cards directory. Staging cards are never retrieved. The catalogue does not respect DeckFormat 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 call GameContext.getCardById(String) in order to correctly retrieve those cards.

      id -
      NullPointerException - if the card cannot be found or if the card's version exceeds the currently configured version. (Versions are only used for Trace objects.)
    • getRecords

      @NotNull public static @NotNull Map<String,CardCatalogueRecord> getRecords()
      Gets all the CardCatalogueRecord objects specified in the cards module.
    • getCardByName

      @Nullable public static @Nullable Card getCardByName(String name)
    • getCardByName

      public static Card getCardByName(String name, String heroClass)
    • query

      public static CardList query(DeckFormat deckFormat)
    • query

      public static CardList query(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType)
    • query

      public static CardList query(DeckFormat deckFormat, String heroClass)
    • query

      public static CardList query(DeckFormat deckFormat, com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType cardType, com.hiddenswitch.spellsource.rpc.Spellsource.RarityMessage.Rarity rarity, String heroClass)
    • query

      @NotNull public 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.
      deckFormat -
      cardType -
      rarity -
      heroClass -
      tag -
      clone -
    • loadCardsFromPackage

      public static void loadCardsFromPackage(List<com.hiddenswitch.spellsource.core.CardResources> cardResources)
      Loads all the cards from the specified CardResources instances.
      cardResources -
    • addOrReplaceCard

      public static String addOrReplaceCard(String json) throws IOException
      Adds or replaces a card for the given JSON.

      If a CardDesc.getName() name field is specified and no id, the

      json -
    • removeCard

      public static void removeCard(String id)
      Removes the specified card by ID from the catalogue.
      id -
    • loadCards

      public static void loadCards(Collection<com.hiddenswitch.spellsource.core.ResourceInputStream> inputStreams)
      Loads all the cards from the specified ResourceInputStream instances, which can be a mix of files and resources.
      inputStreams -
    • loadAllCards

      public static void loadAllCards()
      Loads all the cards from all classpath resources that are recursively inside the "cards" directory.
    • loadCardsFromFilesystemDirectories

      public static void loadCardsFromFilesystemDirectories(String... directories)
    • loadAllCards

      public static void loadAllCards(String directory)
      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.

      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 the cards module. This can be called multiple times, but will not "refresh" the catalogue file.
    • firstLoad

      public static boolean firstLoad()
    • getFormatCard

      public static Card getFormatCard(String name)
    • getHeroCard

      public static Card getHeroCard(String heroClass)
    • getClassCards

      public static CardList getClassCards(DeckFormat format)
      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.
      format -
    • getBaseClasses

      public static List<String> getBaseClasses(DeckFormat deckFormat)
      Retrieves the HeroClass strings that correspond to the classes in the specified format.
      deckFormat -
    • query

      public static CardList query(DeckFormat deckFormat, Predicate<Card> filter)
    • stream

      public static Stream<Card> stream()
    • getVersion

      public static int getVersion()
    • setVersion

      public static void setVersion(int version)