java.lang.Object
polimi.ingsw.am21.codex.model.Cards.Commons.CardsLoader

public final class CardsLoader extends Object
  • Constructor Details

    • CardsLoader

      public CardsLoader()
    • CardsLoader

      public CardsLoader(String path)
      Instantiates a new CardsLoader by parsing a JSON file at the given path.
      Parameters:
      path - Resource path to the JSON file
    • CardsLoader

      public CardsLoader(org.json.JSONArray cards)
      Instantiates a new CardsLoader by parsing a JSON array.
      Parameters:
      cards - JSON array containing the cards
  • Method Details

    • loadCards

      public void loadCards(List<PlayableCard> starterCardsList, List<PlayableCard> resourceCardsList, List<PlayableCard> goldCardsList, List<ObjectiveCard> objectiveCardsList)
      Parameters:
      starterCardsList - starter card list where the cards will be added
      resourceCardsList - resource card list where the cards will be added
      goldCardsList - gold cards list where the cards will be added
      objectiveCardsList - objective cards list where the cards will be added
    • getCardsFromIds

      public List<Card> getCardsFromIds(List<Integer> ids)
      Parameters:
      ids - the ids of the cards to be returned
      Returns:
      the list of cards with the given ids
    • getCardFromId

      public Card getCardFromId(int id)
      Parameters:
      id - the id of the card to be returned
      Returns:
      the card with the given id
    • getStarterCards

      public List<PlayableCard> getStarterCards()
    • getGoldCards

      public List<PlayableCard> getGoldCards()
    • getResourceCards

      public List<PlayableCard> getResourceCards()
    • getObjectiveCards

      public List<ObjectiveCard> getObjectiveCards()
    • loadCards

      public void loadCards()
      Loads the cards from the JSON array. Will not re-run after subsequent calls.