Moral Decision - UQcsse3200/2024-studio-3 GitHub Wiki
The moral system enhances gameplay by introducing ethical dilemmas that players must navigate, adding complexity and consequences to their actions. During the game, players encounter moral decisions presented by a mysterious character on-screen. These decisions are tracked through the MoralDecision class, which manages a list of decisions and updates the player's morality score based on their choices. For example, a player might be asked, “Add catnip to the meal for $10?”—tempting them to make an unethical choice for financial gain.
Each decision, represented by the Decision class, includes a statement, whether the decision is "good" or "bad," and the associated points, which affect the player's morality score. The player's decisions are stored and tracked, with the possibility to influence future gameplay. Decisions are evaluated as either Yes, No, or remain Pending until a choice is made, as represented by the MoralEnum.
When a decision is made, the system updates the current morality score, which reflects the cumulative result of the player's actions throughout the game. Players' choices not only impact immediate outcomes but also influence future levels, providing meaningful consequences to their actions.
The MoralDecision
class manages a list of moral decisions made by the player and tracks the player's current morality score based on those decisions. It allows adding, modifying, and removing decisions, as well as querying for decision results and updating morality points accordingly.
-
ListOfDecisions (List<Decision>)
: A list storing all the moral decisions the player makes, each represented by aDecision
object. -
currentMorality (Integer)
: Tracks the player's current morality score, which is updated based on the moral decisions made.
-
addQuestion(String question)
: Adds a new decision with a default morality score of 10 points, assuming the decision is "good." -
addQuestion(String question, boolean isGood, int decisionPoints)
: Adds a new decision with a specified question, morality (good or bad), and associated points. -
addDecision(Decision decision)
: Adds an existingDecision
object to the list of decisions. -
getDecision(int index)
: Retrieves the result (true/false) of the decision at the specified index. -
getDecision(String question)
: Finds and returns the result of a decision based on the question text. -
getCurrentMorality()
: Returns the current morality score of the player. -
setCurrentMorality(Integer currentMorality)
: Updates the player's current morality score. -
setDecision(int index, boolean decision)
: Sets the result of a decision at the given index and updates the morality score based on the decision's points. -
getListOfDecisions()
: Returns the list of all decisions made. -
getDecisionStatement(int index)
: Returns the question or statement of the decision at the specified index. -
clearDecisions()
: Clears all decisions from the list and resets the morality score to zero. -
removeDecision(int index)
: Removes a decision from the list based on its index. -
removeDecision(Decision decision)
: Removes the specifiedDecision
object from the list. -
removeDecision(String question)
: Removes a decision from the list based on the question text.
The Decision
class represents a moral decision made by the player, including the statement, its goodness, the points associated with it, and the final decision. It allows for the creation of a decision, setting and retrieving its result, and tracking its impact on the player's morality score.
-
statement (String)
: The text or question that represents the moral decision. -
isGood (boolean)
: Indicates whether the decision is inherently "good" or "bad." -
decisionMade (MoralEnum.Value)
: Tracks the result of the decision (Pending, Yes, or No). -
decisionPoints (int)
: Points associated with the decision, which can affect the player's morality score.
-
Decision(String statement, boolean isGood, int decisionPoints)
: Constructs a new decision with the given statement, whether it is good, and the points it is worth. -
getStatement()
: Returns the text of the decision statement. -
getDecision()
: Returns whether the decision was positive (true
) or negative (false
). If the decision has not been made, it logs an error and returnsfalse
. -
getDecisionPoints()
: Returns the points associated with the decision. If the decision is good, the points are positive; if bad, they are negative. -
isGood()
: Returnstrue
if the decision is good, otherwisefalse
. -
setDecision(boolean decision)
: Sets the result of the decision (Yes/No). The decision can only be set once; if attempted again, it logs an error and returnsfalse
. -
setPoints(int points)
: Sets the points associated with the decision. If the points are negative, it logs an error and returnsfalse
. Otherwise, the points are updated successfully.
The MoralEnum
class defines an enumeration of possible moral decision outcomes. It is used to track the status of a player's decision in moral dilemmas.
-
Value
: Represents the possible outcomes of a moral decision:-
Yes
: Indicates a positive or affirmative decision. -
No
: Indicates a negative or rejecting decision. -
Pending
: Indicates that the decision has not yet been made.
-
UML diagram of MoralDecision.java, Decision.java, and MoralEnum.java