Module polimi.ingsw.am21.codex
Class CardsLoader
java.lang.Object
polimi.ingsw.am21.codex.model.Cards.Commons.CardsLoader
-
Constructor Summary
ConstructorsConstructorDescriptionCardsLoader
(String path) Instantiates a new CardsLoader by parsing a JSON file at the given path.CardsLoader
(org.json.JSONArray cards) Instantiates a new CardsLoader by parsing a JSON array. -
Method Summary
Modifier and TypeMethodDescriptiongetCardFromId
(int id) getCardsFromIds
(List<Integer> ids) void
Loads the cards from the JSON array.void
loadCards
(List<PlayableCard> starterCardsList, List<PlayableCard> resourceCardsList, List<PlayableCard> goldCardsList, List<ObjectiveCard> objectiveCardsList)
-
Constructor Details
-
CardsLoader
public CardsLoader() -
CardsLoader
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 addedresourceCardsList
- resource card list where the cards will be addedgoldCardsList
- gold cards list where the cards will be addedobjectiveCardsList
- objective cards list where the cards will be added
-
getCardsFromIds
- Parameters:
ids
- the ids of the cards to be returned- Returns:
- the list of cards with the given ids
-
getCardFromId
- Parameters:
id
- the id of the card to be returned- Returns:
- the card with the given id
-
getStarterCards
-
getGoldCards
-
getResourceCards
-
getObjectiveCards
-
loadCards
public void loadCards()Loads the cards from the JSON array. Will not re-run after subsequent calls.
-