Class Card
java.lang.Object
com.cmiurca.saintseiyadeckbuilding.saintseiya.Card
Card class, where the cards are created
- Since:
- 2023-02-04
-
Constructor Summary
ConstructorsConstructorDescriptionCard()
Default constructorCard
(int id) Constructeur par ID qui crée une carte à partir d'un fichier JSON qui contient les données de la carte.Creates a new Card instance with the specified parameters.Card
(String name, String category, int acquisitionCostInStrength, int acquisitionCostInCosmos, String rank, int id, int flameOfTheClock, int pointOfVictory, Effect effect, int strength, int cosmos, int care) Creates a new Card instance with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCare
(int careToAdd) Method to add care to theCard
.void
addCosmos
(int cosmosToAdd) Method to add cosmos to theCard
.void
addStrength
(int strengthToAdd) Method to add strength to theCard
.void
Method to apply the effect of theCard
createEffect
(int id, String effectDescription) JSONParser parser = new JSONParser(); try { Object obj = parser.parse(new FileReader("./saint_seiya_cartes.json")); JSONArray cards = (JSONArray) obj; Iteratoriterator = cards.iterator(); JSONObject card = (JSONObject)parser.parse(iterator.next()); while(iterator.hasNext() invalid input: '&'invalid input: '&' !card.get("id").equals(id + "")) { card = (JSONObject)parser.parse(iterator.next()); } System.out.print(card.get("nom")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); }* /** CreateEffect method to create an effect from a card id and a description boolean
Method to compare two cardsint
Getter for acquisitionCostInCosmosint
Getter for acquisitionCostInStrengthint
getCare()
Getter for careGetter for categoryint
Getter for cosmosGetter for effectint
Getter for flameOfTheClockint
getId()
Getter for idgetName()
Getter for nameint
Getter for pointOfVictorygetRank()
Getter for rankint
Getter for strengthvoid
removeAcquisitionCostInCosmos
(int acquisitionCostInCosmosToRemove) Method to remove acquisitionCostInCosmos to theCard
void
removeAcquisitionCostInStrength
(int acquisitionCostInStrengthToRemove) Method to remove acquisitionCostInStrength to theCard
void
removeCare
(int careToRemove) Method to remove care to theCard
.void
removeCosmos
(int cosmosToRemove) Method to remove cosmos to theCard
.void
removeStrength
(int strengthToRemove) Method to remove strength to theCard
.void
setAcquisitionCostInCosmos
(int acquisitionCostInCosmos) Setter for acquisitionCostInCosmosvoid
setAcquisitionCostInStrength
(int acquisitionCostInStrength) Setter for acquisitionCostInStrengthvoid
setCare
(int care) Setter for carevoid
setCategory
(String category) Setter for categoryvoid
setCosmos
(int cosmos) Setter for cosmosvoid
Setter for effectvoid
setFlameOfTheClock
(int flameOfTheClock) Setter for flameOfTheClockvoid
setId
(int id) Setter for idvoid
Setter for namevoid
setPointOfVictory
(int pointOfVictory) Setter for pointOfVictoryvoid
Setter for rankvoid
setStrength
(int strength) Setter for strengthtoString()
Method to display theCard
.
-
Constructor Details
-
Card
public Card()Default constructor -
Card
Creates a new Card instance with the specified parameters.- Parameters:
card
- The card to copy.
-
Card
public Card(String name, String category, int acquisitionCostInStrength, int acquisitionCostInCosmos, String rank, int id, int flameOfTheClock, int pointOfVictory, Effect effect, int strength, int cosmos, int care) Creates a new Card instance with the specified parameters.- Parameters:
name
- The name of theCard
.category
- The category of theCard
.acquisitionCostInStrength
- The acquisition cost in strength required to acquire theCard
.acquisitionCostInCosmos
- The acquisition cost in cosmos required to acquire theCard
.rank
- The rank of theCard
.id
- The id of theCard
.flameOfTheClock
- The flame of the clock value of theCard
.pointOfVictory
- The point of victory value of theCard
.effect
- The effect of theCard
.strength
- The strength value of theCard
.cosmos
- The cosmos value of theCard
.care
- The care value of theCard
.
-
Card
public Card(int id) Constructeur par ID qui crée une carte à partir d'un fichier JSON qui contient les données de la carte.- Parameters:
id
- L'identifiant de la carte.
-
-
Method Details
-
createEffect
JSONParser parser = new JSONParser(); try { Object obj = parser.parse(new FileReader("./saint_seiya_cartes.json")); JSONArray cards = (JSONArray) obj; Iteratoriterator = cards.iterator(); JSONObject card = (JSONObject)parser.parse(iterator.next()); while(iterator.hasNext() invalid input: '&'invalid input: '&' !card.get("id").equals(id + "")) { card = (JSONObject)parser.parse(iterator.next()); } System.out.print(card.get("nom")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); }* /** CreateEffect method to create an effect from a card id and a description - Parameters:
id
-effectDescription
-- Returns:
- Effect
-
getName
Getter for name- Returns:
- String name
-
getCategory
Getter for category- Returns:
- String category
-
getAcquisitionCostInStrength
public int getAcquisitionCostInStrength()Getter for acquisitionCostInStrength- Returns:
- int acquisitionCostInStrength
-
getAcquisitionCostInCosmos
public int getAcquisitionCostInCosmos()Getter for acquisitionCostInCosmos- Returns:
- int acquisitionCostInCosmos
-
getRank
Getter for rank- Returns:
- String rank
-
getId
public int getId()Getter for id- Returns:
- int id
-
getFlameOfTheClock
public int getFlameOfTheClock()Getter for flameOfTheClock- Returns:
- int flameOfTheClock
-
getPointOfVictory
public int getPointOfVictory()Getter for pointOfVictory- Returns:
- int pointOfVictory
-
getEffect
Getter for effect- Returns:
- Effect effect
-
getStrength
public int getStrength()Getter for strength- Returns:
- int strength
-
getCosmos
public int getCosmos()Getter for cosmos- Returns:
- int cosmos
-
getCare
public int getCare()Getter for care- Returns:
- int care
-
setName
Setter for name- Parameters:
name
- The name of theCard
.
-
setCategory
Setter for category- Parameters:
category
- The category of theCard
.
-
setAcquisitionCostInStrength
public void setAcquisitionCostInStrength(int acquisitionCostInStrength) Setter for acquisitionCostInStrength- Parameters:
acquisitionCostInStrength
- The acquisition cost in strength required to acquire theCard
.
-
setAcquisitionCostInCosmos
public void setAcquisitionCostInCosmos(int acquisitionCostInCosmos) Setter for acquisitionCostInCosmos- Parameters:
acquisitionCostInCosmos
- The acquisition cost in cosmos required to acquire theCard
.
-
setRank
Setter for rank- Parameters:
rank
- The rank of theCard
.
-
setId
public void setId(int id) Setter for id- Parameters:
id
- The id of theCard
.
-
setFlameOfTheClock
public void setFlameOfTheClock(int flameOfTheClock) Setter for flameOfTheClock- Parameters:
flameOfTheClock
- The flame of the clock value of theCard
.
-
setPointOfVictory
public void setPointOfVictory(int pointOfVictory) Setter for pointOfVictory- Parameters:
pointOfVictory
- The point of victory value of theCard
.
-
setEffect
Setter for effect- Parameters:
effect
- The effect of theCard
.
-
setStrength
public void setStrength(int strength) Setter for strength- Parameters:
strength
- The strength value of theCard
.
-
setCosmos
public void setCosmos(int cosmos) Setter for cosmos- Parameters:
cosmos
- The cosmos value of theCard
.
-
setCare
public void setCare(int care) Setter for care- Parameters:
care
- The care value of theCard
.
-
toString
Method to display theCard
. -
equals
Method to compare two cards -
addStrength
public void addStrength(int strengthToAdd) Method to add strength to theCard
.- Parameters:
strengthToAdd
- The strength to add
-
addCosmos
public void addCosmos(int cosmosToAdd) Method to add cosmos to theCard
.- Parameters:
cosmosToAdd
- The cosmos to add
-
addCare
public void addCare(int careToAdd) Method to add care to theCard
.- Parameters:
careToAdd
- The care to add
-
removeStrength
public void removeStrength(int strengthToRemove) Method to remove strength to theCard
.- Parameters:
strengthToRemove
- The strength to remove
-
removeCosmos
public void removeCosmos(int cosmosToRemove) Method to remove cosmos to theCard
.- Parameters:
cosmosToRemove
- The cosmos to remove
-
removeCare
public void removeCare(int careToRemove) Method to remove care to theCard
.- Parameters:
careToRemove
- The care to remove
-
removeAcquisitionCostInStrength
public void removeAcquisitionCostInStrength(int acquisitionCostInStrengthToRemove) Method to remove acquisitionCostInStrength to theCard
- Parameters:
acquisitionCostInStrengthToRemove
- The acquisitionCostInStrength to remove
-
removeAcquisitionCostInCosmos
public void removeAcquisitionCostInCosmos(int acquisitionCostInCosmosToRemove) Method to remove acquisitionCostInCosmos to theCard
- Parameters:
acquisitionCostInCosmosToRemove
- The acquisitionCostInCosmos to remove
-
applyEffect
Method to apply the effect of theCard
- Parameters:
card
- The card to apply the effectplayer
- The player to apply the effectplayMat
- The playMat to apply the effect
-