Class MoralDecision
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.moral.MoralDecision
The MoralDecision class manages a list of moral decisions and tracks the current morality score.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDecision
(Decision decision) Adds an existing Decision object to the list of decisions.boolean
addQuestion
(String question) Adds a new Question, assuming it is good and worth 10 points.boolean
addQuestion
(String question, boolean isGood, int effectMoney) Adds a new Question with the specified question, goodness, and decision points.void
Clears all decisions from the list.Returns the current morality score.boolean
getDecision
(int index) Returns the result of the decision at the specified index.boolean
getDecision
(String question) Returns the result of the decision with the specified question.getDecisionQuestion
(int index) Returns the statement of the decision at the specified index.Returns the list of decisions.void
removeDecision
(int index) Removes the decision at the specified index.void
removeDecision
(Decision decision) Removes the specified Decision object from the list.void
removeDecision
(String question) Removes the decision with the specified question from the list.void
setCurrentMorality
(Boolean currentMorality) Sets the current morality score.boolean
setDecision
(int index, boolean decision) Sets the decision result at the specified index and updates the morality score.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
MoralDecision
public MoralDecision()
-
-
Method Details
-
addQuestion
Adds a new Question, assuming it is good and worth 10 points.- Parameters:
question
- the question or statement of the decision- Returns:
- true if the decision was added successfully
-
addQuestion
Adds a new Question with the specified question, goodness, and decision points.- Parameters:
question
- the question or statement of the decisionisGood
- whether the effect is positive or negativeeffectMoney
- Money to be added or subtracted. Add/sub controlled by isGood- Returns:
- true if the decision was added successfully
-
addDecision
Adds an existing Decision object to the list of decisions.- Parameters:
decision
- the Decision object to add
-
getDecision
public boolean getDecision(int index) Returns the result of the decision at the specified index.- Parameters:
index
- the index of the decision- Returns:
- the result of the decision, or false if the decision is not found
-
getDecision
Returns the result of the decision with the specified question.- Parameters:
question
- the question or statement of the decision- Returns:
- the result of the decision, or false if the decision is not found
-
getCurrentMorality
Returns the current morality score.- Returns:
- the current morality score
-
setCurrentMorality
Sets the current morality score.- Parameters:
currentMorality
- the new morality score
-
setDecision
public boolean setDecision(int index, boolean decision) Sets the decision result at the specified index and updates the morality score.- Parameters:
index
- the index of the decisiondecision
- the result of the decision- Returns:
- true if the decision was set successfully
-
getListOfDecisions
Returns the list of decisions.- Returns:
- the list of decisions
-
getDecisionQuestion
Returns the statement of the decision at the specified index.- Parameters:
index
- the index of the decision- Returns:
- the statement of the decision
-
clearDecisions
public void clearDecisions()Clears all decisions from the list. -
removeDecision
public void removeDecision(int index) Removes the decision at the specified index.- Parameters:
index
- the index of the decision to remove
-
removeDecision
Removes the specified Decision object from the list.- Parameters:
decision
- the Decision object to remove
-
removeDecision
Removes the decision with the specified question from the list.- Parameters:
question
- the question or statement of the decision to remove
-