Skip to content
Snippets Groups Projects
Commit 3d8d8987 authored by Frantisek Simon's avatar Frantisek Simon
Browse files

#139 Fixed score counting for robbery.

parent 32c31b09
No related branches found
No related tags found
No related merge requests found
......@@ -30,8 +30,8 @@ public class RobberyGame extends AbstractTablexiaGame<GameRule> {
public static class GameResultResolver implements GameDefinition.GameResultResolver {
@Override
public GameResult getGameCupsResult(Game game) {
int creaturesCount = Integer.valueOf(game.getGameScore(RobberyGame.SCORE_KEY_PERSON_NUMBER, "0")) + 1;
if (creaturesCount > 49) {
int creaturesCount = getFinalScore(game);
if (creaturesCount > 47) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (creaturesCount > 29) {
return AbstractTablexiaGame.GameResult.TWO_STAR;
......@@ -44,7 +44,14 @@ public class RobberyGame extends AbstractTablexiaGame<GameRule> {
@Override
public float getGameScoreResult(Game game) {
return Float.parseFloat(game.getGameScore(RobberyGame.SCORE_KEY_PERSON_NUMBER, "0")) + 1;
return getFinalScore(game);
}
private int getFinalScore(Game game) {
int numOfPerson = Integer.valueOf(game.getGameScore(RobberyGame.SCORE_KEY_PERSON_NUMBER, "0"));
int wrongPerson = Integer.valueOf(game.getGameScore(RobberyGame.SCORE_KEY_INNOCENCE_PERSON, "0"));
int escapedThieves = Integer.valueOf(game.getGameScore(RobberyGame.SCORE_KEY_ESCAPED_THIEVES, "0"));
return numOfPerson - wrongPerson - escapedThieves;
}
}
......@@ -211,7 +218,7 @@ public class RobberyGame extends AbstractTablexiaGame<GameRule> {
@Override
protected List<SummaryMessage> getSummaryMessageForGameResult(Game game) {
String identification = game.getUser().getGender() == User.Gender.MALE ? getText(SUMMARY_IDENTIFICATION_MALE_TEXT_KEY) : getText(SUMMARY_IDENTIFICATION_FEMALE_TEXT_KEY);
return Arrays.asList(new SummaryMessage(SummaryImage.STATS, getFormattedText(SUMMARY_TEXT_KEY, identification, game.getGameScore(SCORE_KEY_PERSON_NUMBER, "0"), game.getGameScoreValue(SCORE_KEY_PERSON_COUNT))));
return Arrays.asList(new SummaryMessage(SummaryImage.STATS, getFormattedText(SUMMARY_TEXT_KEY, identification, new RobberyGame.GameResultResolver().getFinalScore(game), game.getGameScoreValue(SCORE_KEY_PERSON_COUNT))));
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment