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
|
//region Private methods
|
||||||
|
|
||||||
protected abstract int addScore(int score);
|
|
||||||
|
|
||||||
// The original game seems to work as follows:
|
// The original game seems to work as follows:
|
||||||
// If < 1 were cleared, score = 0
|
// If < 1 were cleared, score = 0
|
||||||
// If = 1 was cleared, score = cells cleared
|
// If = 1 was cleared, score = cells cleared
|
||||||
// If > 1 were cleared, score = cells cleared + score(cleared - 1)
|
// 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 0;
|
||||||
if (stripsCleared == 1) return boardSize;
|
if (stripsCleared == 1) return boardSize;
|
||||||
else return boardSize * stripsCleared + calculateClearScore(stripsCleared - 1, boardSize);
|
else return boardSize * stripsCleared + calculateClearScore(stripsCleared - 1, boardSize);
|
||||||
|
@ -65,14 +63,10 @@ public abstract class BaseScorer implements BinSerializable {
|
||||||
//region Public methods
|
//region Public methods
|
||||||
|
|
||||||
// Adds the score a given piece would give
|
// Adds the score a given piece would give
|
||||||
public final int addPieceScore(int areaPut) {
|
public abstract int addPieceScore(int areaPut);
|
||||||
return addScore(areaPut);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the score given by the board, this is, the count of cleared strips
|
// Adds the score given by the board, this is, the count of cleared strips
|
||||||
public final int addBoardScore(int stripsCleared, int boardSize) {
|
public abstract int addBoardScore(int stripsCleared, int boardSize);
|
||||||
return addScore(calculateClearScore(stripsCleared, boardSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pause() { }
|
public void pause() { }
|
||||||
public void resume() { }
|
public void resume() { }
|
||||||
|
|
|
@ -37,18 +37,21 @@ public class Scorer extends BaseScorer implements BinSerializable {
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Private methods
|
//region Public methods
|
||||||
|
|
||||||
@Override
|
@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;
|
currentScore += score;
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
//region Public methods
|
|
||||||
|
|
||||||
public int getCurrentScore() {
|
public int getCurrentScore() {
|
||||||
return currentScore;
|
return currentScore;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
||||||
|
|
||||||
//region Private methods
|
//region Private methods
|
||||||
|
|
||||||
@Override
|
private int addScore(int score) {
|
||||||
protected int addScore(int score) {
|
|
||||||
int scoreBefore = getCurrentScore();
|
int scoreBefore = getCurrentScore();
|
||||||
deadTime += scoreToNanos(score);
|
deadTime += scoreToNanos(score);
|
||||||
return getCurrentScore() - scoreBefore;
|
return getCurrentScore() - scoreBefore;
|
||||||
|
@ -81,6 +80,16 @@ public class TimeScorer extends BaseScorer implements BinSerializable {
|
||||||
|
|
||||||
//region Public methods
|
//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
|
@Override
|
||||||
public int getCurrentScore() {
|
public int getCurrentScore() {
|
||||||
return nanosToSeconds(deadTime - startTime);
|
return nanosToSeconds(deadTime - startTime);
|
||||||
|
|
Loading…
Reference in a new issue