Skip to content
Snippets Groups Projects
Commit 0adb09ce authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Merge branch 'feature-halloffame' into 'devel'

#275 Changed way of evaluation of trophy for 6 games on hard/medium on 3 trophies in row

* Změněn způsob vyhodnocení trofeje... nyní se postupně hry po šesti ukladají do jednoho pole, které se následně testuje na jedinečnost každé hry

See merge request !290
parents 26f0fec9 31a527a0
Branches
Tags
No related merge requests found
......@@ -198,15 +198,32 @@ public class UserTrophy {
} catch (SQLException e) {
Log.err(UserTrophy.class, "Cannot select game with user_id: " + user.getId() + ", difficulty: " + trophyDef.getLimit(), e);
}
Set<Integer> gamesPlayed = new HashSet<Integer>();
if(games.size() < GameDefinition.values().length) return false;
int[] sixConsecutiveGames = new int[GameDefinition.values().length];
for (Game game : games) {
if (GameDAO.getGameResult(game).getStarCount() == AbstractTablexiaGame.GameResult.THREE_STAR.getStarCount()
&& !gamesPlayed.contains(game.getGameNumber())) {
gamesPlayed.add(game.getGameNumber());
if (gamesPlayed.size() == GameDefinition.values().length) return true;
} else {
gamesPlayed.clear();
boolean duplicateFound = false;
//shifting games in array
for (int i = 0; i < sixConsecutiveGames.length - 1; i++) {
sixConsecutiveGames[i] = sixConsecutiveGames[i + 1];
}
sixConsecutiveGames[sixConsecutiveGames.length - 1] = game.getGameNumber();
//if array sixConsecutiveGames has minimum number of games loaded, we can try achieve a trophy
if(games.indexOf(game) + 1 >= GameDefinition.values().length) {
for (int i = 0; i < sixConsecutiveGames.length; i++) {
for (int j = i + 1; j < sixConsecutiveGames.length; j++) {
if (sixConsecutiveGames[i] == sixConsecutiveGames[j] ||
GameDAO.getGameResult(game).getStarCount() != AbstractTablexiaGame.GameResult.THREE_STAR.getStarCount()) {
duplicateFound = true;
break;
}
}
if (duplicateFound) break;
}
if (!duplicateFound) return true;
}
}
return false;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment