diff --git a/core/src/io/github/lonamiwebs/klooni/Klooni.java b/core/src/io/github/lonamiwebs/klooni/Klooni.java index 2015950..033d970 100644 --- a/core/src/io/github/lonamiwebs/klooni/Klooni.java +++ b/core/src/io/github/lonamiwebs/klooni/Klooni.java @@ -99,6 +99,10 @@ public static void setMaxScore(int score) { prefs.putInteger("maxScore", score).flush(); } + public static void setMaxTimeScore(int maxTimeScore) { + prefs.putInteger("maxTimeScore", maxTimeScore).flush(); + } + public static boolean soundsEnabled() { return !prefs.getBoolean("muteSound", false); } diff --git a/core/src/io/github/lonamiwebs/klooni/game/Scorer.java b/core/src/io/github/lonamiwebs/klooni/game/Scorer.java index 9b3f54b..67c0f10 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/Scorer.java +++ b/core/src/io/github/lonamiwebs/klooni/game/Scorer.java @@ -15,9 +15,6 @@ public class Scorer extends BaseScorer { private int currentScore, maxScore; - // If the currentScore beat the maxScore, then we have a new record - private boolean newRecord; - // To interpolate between shown score -> real score private float shownScore; @@ -40,7 +37,6 @@ public Scorer(final Klooni game, GameLayout layout) { @Override protected void addScore(int score) { currentScore += score; - newRecord = currentScore > maxScore; } //endregion @@ -52,14 +48,14 @@ public int getCurrentScore() { } public void saveScore() { - if (newRecord) { + if (isNewRecord()) { Klooni.setMaxScore(currentScore); } } @Override protected boolean isNewRecord() { - return newRecord; + return currentScore > maxScore; } @Override diff --git a/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java b/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java index 98cb17f..bd89ba7 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java +++ b/core/src/io/github/lonamiwebs/klooni/game/TimeScorer.java @@ -11,6 +11,7 @@ public class TimeScorer extends BaseScorer { //region Members private long startTime; + private final int highScoreTime; // Indicates where we would die in time. Score adds to this, so we take // longer to die. To get the "score" we simply calculate `deadTime - startTime` @@ -29,6 +30,7 @@ public class TimeScorer extends BaseScorer { // The board size is required when calculating the score public TimeScorer(final Klooni game, GameLayout layout) { super(game, layout, Klooni.getMaxTimeScore()); + highScoreTime = Klooni.getMaxTimeScore(); startTime = TimeUtils.nanoTime(); deadTime = startTime + START_TIME; @@ -74,13 +76,14 @@ public boolean isGameOver() { @Override public void saveScore() { - // TODO Save high time score + if (isNewRecord()) { + Klooni.setMaxTimeScore(getCurrentScore()); + } } @Override protected boolean isNewRecord() { - // TODO Return true if it is a new record - return false; + return getCurrentScore() > highScoreTime; } @Override