java.lang.Object
it.polimi.ingsw.am13.model.card.CardFactory
This class parses the information of card_json and creates
Card
objects in accordance to the Factory pattern-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Color
Deserializes a list of Gold cards from the card_data.jsonDeserializes a list of Objective cards from the card_data.jsonDeserializes a list of Resource cards from the card_data.jsonDeserializes a list of Starter cards from the card_data.jsonprivate com.fasterxml.jackson.databind.JsonNode
getBacksNode
(String cardType) getCorners
(com.fasterxml.jackson.databind.JsonNode cardSide) private com.fasterxml.jackson.databind.JsonNode
getFrontsNode
(String cardType) private Resource
resourceConverter
(char c)
-
Field Details
-
CARD_JSON_PATH
Path tocard_data.json
file- See Also:
-
-
Constructor Details
-
CardFactory
public CardFactory()
-
-
Method Details
-
createCardsResource
Deserializes a list of Resource cards from the card_data.json- Returns:
LinkedList<>
of CardResource- Throws:
InvalidCardCreationException
- if it fails to create a valid card
-
createCardsGold
Deserializes a list of Gold cards from the card_data.json- Returns:
LinkedList<>
of CardGold- Throws:
InvalidCardCreationException
- if it fails to create a valid card
-
createCardsStarter
Deserializes a list of Starter cards from the card_data.json- Returns:
LinkedList<>
of CardStarter- Throws:
InvalidCardCreationException
- if it fails to create a valid card
-
createCardsObjective
Deserializes a list of Objective cards from the card_data.json- Returns:
LinkedList<>
of CardObjective- Throws:
InvalidCardCreationException
- if it fails to create a valid card
-
getFrontsNode
- Parameters:
cardType
- String used to reference this card type in thecard_data.json
- Returns:
- JsonNode of the list of "front sides" of the given
cardType
- Throws:
IOException
- If it fails to retrieve the correct JsonNode from the JSON file- See Also:
-
getBacksNode
- Parameters:
cardType
- String used to reference this card type in thecard_data.json
- Returns:
- JsonNode of the list of "front sides" of the given
cardType
- Throws:
IOException
- If it fails to retrieve the correct JsonNode from the JSON file- See Also:
-
getCorners
- Parameters:
cardSide
-JsonNode
of the card side to which the corners are a part of.- Returns:
List<>
ofCorner
objects
-
colorConverter
- Parameters:
s
- String whose first letter represents a color for a card- Returns:
- corresponding
Color
-
resourceConverter
- Parameters:
c
- Character indicating a resource- Returns:
- corresponding
Resource
-
emptyCorners
- Returns:
List
of empty corners
-