diff --git a/core/src/uk/ac/york/student/player/PlayerEnergy.java b/core/src/uk/ac/york/student/player/PlayerEnergy.java index f169369..cfa7966 100644 --- a/core/src/uk/ac/york/student/player/PlayerEnergy.java +++ b/core/src/uk/ac/york/student/player/PlayerEnergy.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar; import org.jetbrains.annotations.Range; +import uk.ac.york.student.game.GameTime; /** * The PlayerEnergy class represents the energy level of a player in the game. @@ -34,6 +35,28 @@ public PlayerEnergy() { * By default, the energy level is set to 1 (full energy). */ private @Range(from=0, to=1) float energy = getDefault(); + /** + * The total amount of energy accumulated by the player across all days of the game. + * This is a float value that starts at 0 and increases as the player gains more energy. + * This value is incremented when the player sleeps based on what their energy level is at that given time. + */ + private float totalEnergy = 0f; + + public float getMaxTotal() { + return GameTime.getDays(); + } + + public float getTotal() { + return totalEnergy; + } + + public void setTotal(float total) { + this.totalEnergy = total; + } + + public void increaseTotal(float amount) { + this.totalEnergy += amount; + } /** * Returns the default energy level for the player. * This is a float value of 1, representing full energy. diff --git a/core/src/uk/ac/york/student/player/PlayerHappiness.java b/core/src/uk/ac/york/student/player/PlayerHappiness.java index d1380bf..9f4d68d 100644 --- a/core/src/uk/ac/york/student/player/PlayerHappiness.java +++ b/core/src/uk/ac/york/student/player/PlayerHappiness.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar; import org.jetbrains.annotations.Range; +import uk.ac.york.student.game.GameTime; /** * The PlayerHappiness class implements the PlayerMetric interface. @@ -33,6 +34,29 @@ public PlayerHappiness() { * It is initially set to 1, indicating that the player starts the game being very happy. */ private @Range(from=0, to=1) float happiness = getDefault(); + /** + * The total amount of happiness accumulated by the player across all days of the game. + * This is a float value that starts at 0 and increases as the player becomes happier. + * This value is incremented when the player sleeps based on what their happiness level is at that given time. + */ + private float totalHappiness = 0f; + + public float getMaxTotal() { + return GameTime.getDays(); + } + + public float getTotal() { + return totalHappiness; + } + + public void setTotal(float total) { + this.totalHappiness = total; + } + + public void increaseTotal(float amount) { + this.totalHappiness += amount; + } + /** * This method is used to get the default happiness level for a player. * The default happiness level is set to 1.0, indicating that a player starts the game at full happiness. diff --git a/core/src/uk/ac/york/student/player/PlayerMetric.java b/core/src/uk/ac/york/student/player/PlayerMetric.java index 1797360..e1a8087 100644 --- a/core/src/uk/ac/york/student/player/PlayerMetric.java +++ b/core/src/uk/ac/york/student/player/PlayerMetric.java @@ -38,6 +38,11 @@ public interface PlayerMetric { void decrease(float amount); float getDefault(); + void setTotal(float total); + void increaseTotal(float amount); + float getTotal(); + float getMaxTotal(); + /** * Dispose resources when they are no longer needed. * By default, it disposes the skin. diff --git a/core/src/uk/ac/york/student/player/PlayerScore.java b/core/src/uk/ac/york/student/player/PlayerScore.java index 301dbcc..4650d5f 100644 --- a/core/src/uk/ac/york/student/player/PlayerScore.java +++ b/core/src/uk/ac/york/student/player/PlayerScore.java @@ -9,11 +9,41 @@ * The score is then converted to a string representation of a degree class. */ public interface PlayerScore { + /** + * Calculate a score for the player based on their energy, study level, and happiness. + * The score is calculated using the provided weightings for each parameter. + * The weightings are used to determine the importance of each parameter in the final score. + * + * @param energy The player's energy level. + * @param maxEnergy The maximum possible energy level. + * @param studyLevel The player's study level. + * @param maxStudyLevel The maximum possible study level. + * @param happiness The player's happiness level. + * @param maxHappiness The maximum possible happiness level. + * @return The player's score, calculated based on the provided parameters and weightings. + */ + default float calculateScore(float energy, float maxEnergy, float studyLevel, float maxStudyLevel, float happiness, float maxHappiness) { + float energyWeighting = 1.2f; + float studyWeighting = 2f; + float happinessWeighting = 1f; + + float energyScore = (energy / maxEnergy) * energyWeighting; + float studyScore = (studyLevel / maxStudyLevel) * studyWeighting; + float happinessScore = (happiness / maxHappiness) * happinessWeighting; + + float totalScore = energyScore + studyScore + happinessScore; + float maxPossibleScore = energyWeighting + studyWeighting + happinessWeighting; + + return (totalScore / maxPossibleScore) * 100; + } + + /** * Calculate a score for the player based on their energy, study time, and the game's difficulty level. * The score is calculated using a specific algorithm that has diminishing returns for the amount of work the player has done. * The algorithm also allows for a choice of difficulties, with a custom difficulty range. * + * @deprecated * @param energy The player's energy level. * @param maxEnergy The maximum possible energy level. * @param studyTime The time the player has spent studying. @@ -22,6 +52,7 @@ public interface PlayerScore { * @param maxDifficulty The maximum possible difficulty level. * @return The player's score, calculated based on the provided parameters. */ + @Deprecated(forRemoval = true) default int calculateScore(float energy, float maxEnergy, float studyTime, float maxStudyTime, int difficulty, int maxDifficulty) { @@ -42,10 +73,26 @@ default int calculateScore(float energy, float maxEnergy, float studyTime, return (int) Math.round(percentScoreDouble); } + /** + * Overload of the calculateScore method that only requires energy and study time parameters. + * This method assumes a default difficulty level of 1 for both the game and the maximum possible difficulty. + * + * @deprecated + * @param energy The player's energy level. + * @param maxEnergy The maximum possible energy level. + * @param studyTime The time the player has spent studying. + * @param maxStudyTime The maximum possible study time. + * @return The player's score, calculated based on the provided parameters and the default difficulty level. + */ + @Deprecated(forRemoval = true) + default int calculateScore(float energy, float maxEnergy, float studyTime, float maxStudyTime) { + return calculateScore(energy, maxEnergy, studyTime, maxStudyTime, 1, 1); + } /** * Overload of the calculateScore method that accepts integer parameters. * This method simply converts the integer parameters to floats and calls the other calculateScore method. * + * @deprecated * @param energy The player's energy level. * @param maxEnergy The maximum possible energy level. * @param studyTime The time the player has spent studying. @@ -54,6 +101,7 @@ default int calculateScore(float energy, float maxEnergy, float studyTime, * @param maxDifficulty The maximum possible difficulty level. * @return The player's score, calculated based on the provided parameters. */ + @Deprecated(forRemoval = true) default int calculateScore(int energy, int maxEnergy, int studyTime, int maxStudyTime, int difficulty, int maxDifficulty) { @@ -71,7 +119,7 @@ default int calculateScore(int energy, int maxEnergy, int studyTime, * @return A string representation of a degree class. */ @Contract(pure = true) - default @NotNull String convertScoreToString(int score) { + default @NotNull String convertScoreToString(float score) { if (score >= 70) { return "First-class Honours"; } else if (score >= 60) { diff --git a/core/src/uk/ac/york/student/player/PlayerStudyLevel.java b/core/src/uk/ac/york/student/player/PlayerStudyLevel.java index 165f137..eff332f 100644 --- a/core/src/uk/ac/york/student/player/PlayerStudyLevel.java +++ b/core/src/uk/ac/york/student/player/PlayerStudyLevel.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar; import org.jetbrains.annotations.Range; +import uk.ac.york.student.game.GameTime; /** * The PlayerStudyLevel class represents the study level of a player in the game. @@ -35,6 +36,29 @@ public PlayerStudyLevel() { */ private @Range(from=0, to=1) float studyLevel = 0.1f; + /** + * The total amount of study accumulated by the player across all days of the game. + * This is a float value that starts at 0 and increases as the player studies more. + * This value is incremented when the player sleeps based on what their study level is at that given time. + */ + private float totalStudy = 0f; + + public float getMaxTotal() { + return GameTime.getDays(); + } + + public float getTotal() { + return totalStudy; + } + + public void setTotal(float total) { + this.totalStudy = total; + } + + public void increaseTotal(float amount) { + this.totalStudy += amount; + } + /** * This method is used to get the default study level for a player. * The default study level is set to 0.1, indicating that a player starts the game with a study level of 0.1.