Skip to content

Commit

Permalink
adjust points calculation for solved just play level
Browse files Browse the repository at this point in the history
References #46
  • Loading branch information
David Schilling committed Aug 24, 2015
1 parent 235d0a4 commit 09a8e2a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public class JustPlayLevelResult {

private final int leftTime;
private final int moves;
private final int minLevelMoves;

public JustPlayLevelResult(int leftTime, int moves) {
public JustPlayLevelResult(int leftTime, int moves, int minLevelMoves) {

this.leftTime = leftTime;
this.moves = moves;
this.minLevelMoves = minLevelMoves;
}

public int getLeftTime() {
Expand All @@ -24,4 +26,10 @@ public int getMoves() {

return moves;
}


public int getMinLevelMoves() {

return minLevelMoves;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ private int calculateNewScore(JustPlayLevelResult justPlayLevelResult, LevelSett
if (justPlayLevelResult.getLeftTime() == -1) {
return lastScore;
} else {
return lastScore + levelSetting.getMaxScore() - justPlayLevelResult.getMoves() * 10;
double movesToMinMovesratio = (double) justPlayLevelResult.getMinLevelMoves()
/ justPlayLevelResult.getMoves();

double additionalScore = levelSetting.getMaxScore() * movesToMinMovesratio;

return lastScore + (int) additionalScore;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public void onTimePassed(TimerHandler pTimerHandler) {
engine.unregisterUpdateHandler(pTimerHandler);
storyService.loadJustPlayScoreSceneFromJustPlayScene(
new JustPlayLevelResult(timeBasedGameService.getRemainingTime(),
gameService.getLevel().getMovesCount()));
gameService.getLevel().getMovesCount(),
gameService.getLevel().getMinimumMovesToSolve()));
}
}));
}
Expand All @@ -144,7 +145,8 @@ public void onTimePassed(TimerHandler pTimerHandler) {

engine.unregisterUpdateHandler(pTimerHandler);
storyService.loadJustPlayScoreSceneFromJustPlayScene(
new JustPlayLevelResult(-1, gameService.getLevel().getMovesCount()));
new JustPlayLevelResult(-1, gameService.getLevel().getMovesCount(),
gameService.getLevel().getMinimumMovesToSolve()));
}
}));
}
Expand Down

0 comments on commit 09a8e2a

Please sign in to comment.