From f28217bf465bb4c59a3af7cdb39c2ad7f2c96edb Mon Sep 17 00:00:00 2001 From: Gongxter Date: Thu, 26 Nov 2015 14:21:25 +0100 Subject: [PATCH] Stats: Changed Average time and min time per difficulty to only games without Hints used --- .../helper/HighscoreInfoContainer.java | 47 +++++++++---------- .../tu_darmstadt/sudoku/ui/StatsActivity.java | 2 +- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/tu_darmstadt/sudoku/controller/helper/HighscoreInfoContainer.java b/app/src/main/java/tu_darmstadt/sudoku/controller/helper/HighscoreInfoContainer.java index 789724c..aa27ea6 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/controller/helper/HighscoreInfoContainer.java +++ b/app/src/main/java/tu_darmstadt/sudoku/controller/helper/HighscoreInfoContainer.java @@ -16,8 +16,10 @@ public class HighscoreInfoContainer { private int time=0; private int numberOfHintsUsed =0; private int numberOfGames=0; + private int numberOfGamesNoHints =0; + private int timeNoHints = 0; - private int amountOfSavedArguments = 6; + private int amountOfSavedArguments = 8; public HighscoreInfoContainer(){ @@ -34,7 +36,11 @@ public class HighscoreInfoContainer { time += gc.getTime(); numberOfHintsUsed += gc.getNumbOfHints(); numberOfGames++; - minTime = (gc.getTime()< minTime) ? gc.getTime() : minTime; + // min time is only minTime of games without hints used + minTime = (gc.getNumbOfHints() == 0 && gc.getTime()< minTime) ? gc.getTime() : minTime; + numberOfGamesNoHints = (gc.getNumbOfHints()==0)?numberOfGamesNoHints+1:numberOfGamesNoHints; + timeNoHints = (gc.getNumbOfHints()==0)?timeNoHints+gc.getTime():timeNoHints; + } public void setInfosFromFile(String s){ @@ -50,6 +56,9 @@ public class HighscoreInfoContainer { minTime = parseTime(strings[3]); type = parseGameType(strings[4]); difficulty = parsDifficulty(strings[5]); + numberOfGamesNoHints=parseNumberOfGames(strings[6]); + timeNoHints = parseTime(strings[7]); + } catch (IllegalArgumentException e){ throw new IllegalArgumentException("Could not set Infoprmation illegal Arguments"); } @@ -58,21 +67,16 @@ public class HighscoreInfoContainer { public GameDifficulty getDifficulty(){ return difficulty; } - public GameType getGameType(){ - return type; - } + public GameType getGameType(){return type;} public int getTime(){ return time; } - public int getMinTime(){ - return minTime; - } - public int getNumberOfHintsUsed(){ - return numberOfHintsUsed; - } - public int getNumberOfGames(){ - return numberOfGames; - } + public int getMinTime(){return minTime; } + public int getNumberOfHintsUsed(){return numberOfHintsUsed; } + public int getNumberOfGames(){ return numberOfGames; } + public int getNumberOfGamesNoHints(){ return numberOfGamesNoHints; } + public int getTimeNoHints(){ return timeNoHints; } + private GameType parseGameType(String s){ return GameType.valueOf(s); @@ -117,20 +121,11 @@ public class HighscoreInfoContainer { sb.append(type.name()); sb.append("/"); sb.append(difficulty.name()); - - - return sb.toString(); - } - - public static String getStats(int time,GameDifficulty gd, int numberOfHints, GameType gt){ - StringBuilder sb = new StringBuilder(); - sb.append(time); sb.append("/"); - sb.append(gd.name()); + sb.append(numberOfGamesNoHints); sb.append("/"); - sb.append(numberOfHints); - sb.append("/"); - sb.append(gt.name()); + sb.append(timeNoHints); + return sb.toString(); } diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java index 8610011..24e3e33 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/StatsActivity.java @@ -237,7 +237,7 @@ public class StatsActivity extends AppCompatActivity { } difficultyBarView.setRating(pos+1); difficultyView.setText(rootView.getResources().getString(infos.getDifficulty().getStringResID())); - s= (infos.getTime() == 0)?"/":String.valueOf(infos.getTime() / infos.getNumberOfGames()); + s= (infos.getTimeNoHints() == 0)?"/":String.valueOf(infos.getTimeNoHints() / infos.getNumberOfGamesNoHints()); averageTimeView.setText(s); s = (infos.getMinTime()==Integer.MAX_VALUE)? "/":String.valueOf(infos.getMinTime()); minTimeView.setText(s);