Make time mode (a lot) harder (closes #6)

This commit is contained in:
Lonami Exo 2017-02-18 19:47:19 +01:00
parent 1c93589c77
commit f997a099ef

View file

@ -26,14 +26,22 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
// longer to die. To get the "score" we simply calculate `deadTime - startTime` // longer to die. To get the "score" we simply calculate `deadTime - startTime`
private long deadTime; private long deadTime;
private static final long START_TIME = 20 * 1000000000L;
// We need to know when the game was paused to "stop" counting // We need to know when the game was paused to "stop" counting
private long pauseTime; private long pauseTime;
private int pausedTimeLeft; private int pausedTimeLeft;
//endregion //endregion
//region Static variables
private static final long START_TIME = 30 * 1000000000L;
// 2 seconds every 10 points: (2/10)*10^9 to get the nanoseconds
private static final double SCORE_TO_NANOS = 0.2e+09d;
private static final double NANOS_TO_SECONDS = 1e-09d;
//endregion
//region Constructor //region Constructor
// The board size is required when calculating the score // The board size is required when calculating the score
@ -57,19 +65,12 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
//region Private methods //region Private methods
private int addScore(int score) {
int scoreBefore = getCurrentScore();
deadTime += scoreToNanos(score);
return getCurrentScore() - scoreBefore;
}
private int nanosToSeconds(long nano) { private int nanosToSeconds(long nano) {
return MathUtils.ceil((float)(nano * 1e-09)); return MathUtils.ceil((float)(nano * NANOS_TO_SECONDS));
} }
private long scoreToNanos(int score) { private long scoreToNanos(int score) {
// 1s/4p seems fair enough return (long)(score * SCORE_TO_NANOS);
return (long)((score / 4.0) * 1e+09);
} }
private int getTimeLeft() { private int getTimeLeft() {
@ -81,13 +82,13 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
//region Public methods //region Public methods
@Override @Override
public int addPieceScore(int areaPut) { public int addPieceScore(int areaPut) { return 0; /* Nope, no score for single pieces */ }
return addScore(areaPut);
}
@Override @Override
public int addBoardScore(int stripsCleared, int boardSize) { public int addBoardScore(int stripsCleared, int boardSize) {
return addScore(calculateClearScore(stripsCleared, boardSize)); int scoreBefore = getCurrentScore();
deadTime += scoreToNanos(calculateClearScore(stripsCleared, boardSize));
return getCurrentScore() - scoreBefore;
} }
@Override @Override