Allow higher scoring customization for Scorers
This commit is contained in:
parent
b94907162c
commit
18f864f418
4 changed files with 23 additions and 17 deletions
BIN
android/Klooni-v0.3.apk
Normal file
BIN
android/Klooni-v0.3.apk
Normal file
Binary file not shown.
|
@ -48,13 +48,11 @@ public abstract class BaseScorer implements BinSerializable {
|
|||
|
||||
//region Private methods
|
||||
|
||||
protected abstract int addScore(int score);
|
||||
|
||||
// The original game seems to work as follows:
|
||||
// If < 1 were cleared, score = 0
|
||||
// If = 1 was cleared, score = cells cleared
|
||||
// If > 1 were cleared, score = cells cleared + score(cleared - 1)
|
||||
private int calculateClearScore(int stripsCleared, int boardSize) {
|
||||
protected final int calculateClearScore(int stripsCleared, int boardSize) {
|
||||
if (stripsCleared < 1) return 0;
|
||||
if (stripsCleared == 1) return boardSize;
|
||||
else return boardSize * stripsCleared + calculateClearScore(stripsCleared - 1, boardSize);
|
||||
|
@ -65,14 +63,10 @@ public abstract class BaseScorer implements BinSerializable {
|
|||
//region Public methods
|
||||
|
||||
// Adds the score a given piece would give
|
||||
public final int addPieceScore(int areaPut) {
|
||||
return addScore(areaPut);
|
||||
}
|
||||
public abstract int addPieceScore(int areaPut);
|
||||
|
||||
// Adds the score given by the board, this is, the count of cleared strips
|
||||
public final int addBoardScore(int stripsCleared, int boardSize) {
|
||||
return addScore(calculateClearScore(stripsCleared, boardSize));
|
||||
}
|
||||
public abstract int addBoardScore(int stripsCleared, int boardSize);
|
||||
|
||||
public void pause() { }
|
||||
public void resume() { }
|
||||
|
|
|
@ -37,18 +37,21 @@ public class Scorer extends BaseScorer implements BinSerializable {
|
|||
|
||||
//endregion
|
||||
|
||||
//region Private methods
|
||||
//region Public methods
|
||||
|
||||
@Override
|
||||
protected int addScore(int score) {
|
||||
public int addPieceScore(int areaPut) {
|
||||
currentScore += areaPut;
|
||||
return areaPut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addBoardScore(int stripsCleared, int boardSize) {
|
||||
int score = calculateClearScore(stripsCleared, boardSize);
|
||||
currentScore += score;
|
||||
return score;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region Public methods
|
||||
|
||||
public int getCurrentScore() {
|
||||
return currentScore;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
|||
|
||||
//region Private methods
|
||||
|
||||
@Override
|
||||
protected int addScore(int score) {
|
||||
private int addScore(int score) {
|
||||
int scoreBefore = getCurrentScore();
|
||||
deadTime += scoreToNanos(score);
|
||||
return getCurrentScore() - scoreBefore;
|
||||
|
@ -81,6 +80,16 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
|||
|
||||
//region Public methods
|
||||
|
||||
@Override
|
||||
public int addPieceScore(int areaPut) {
|
||||
return addScore(areaPut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addBoardScore(int stripsCleared, int boardSize) {
|
||||
return addScore(calculateClearScore(stripsCleared, boardSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentScore() {
|
||||
return nanosToSeconds(deadTime - startTime);
|
||||
|
|
Loading…
Reference in a new issue