Stats: Changed Average time and min time per difficulty to only games without Hints used

This commit is contained in:
Gongxter 2015-11-26 14:21:25 +01:00
parent 5e8c1bd2b1
commit f28217bf46
2 changed files with 22 additions and 27 deletions

View file

@ -16,8 +16,10 @@ public class HighscoreInfoContainer {
private int time=0; private int time=0;
private int numberOfHintsUsed =0; private int numberOfHintsUsed =0;
private int numberOfGames=0; private int numberOfGames=0;
private int numberOfGamesNoHints =0;
private int timeNoHints = 0;
private int amountOfSavedArguments = 6; private int amountOfSavedArguments = 8;
public HighscoreInfoContainer(){ public HighscoreInfoContainer(){
@ -34,7 +36,11 @@ public class HighscoreInfoContainer {
time += gc.getTime(); time += gc.getTime();
numberOfHintsUsed += gc.getNumbOfHints(); numberOfHintsUsed += gc.getNumbOfHints();
numberOfGames++; 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){ public void setInfosFromFile(String s){
@ -50,6 +56,9 @@ public class HighscoreInfoContainer {
minTime = parseTime(strings[3]); minTime = parseTime(strings[3]);
type = parseGameType(strings[4]); type = parseGameType(strings[4]);
difficulty = parsDifficulty(strings[5]); difficulty = parsDifficulty(strings[5]);
numberOfGamesNoHints=parseNumberOfGames(strings[6]);
timeNoHints = parseTime(strings[7]);
} catch (IllegalArgumentException e){ } catch (IllegalArgumentException e){
throw new IllegalArgumentException("Could not set Infoprmation illegal Arguments"); throw new IllegalArgumentException("Could not set Infoprmation illegal Arguments");
} }
@ -58,21 +67,16 @@ public class HighscoreInfoContainer {
public GameDifficulty getDifficulty(){ public GameDifficulty getDifficulty(){
return difficulty; return difficulty;
} }
public GameType getGameType(){ public GameType getGameType(){return type;}
return type;
}
public int getTime(){ public int getTime(){
return time; return time;
} }
public int getMinTime(){ public int getMinTime(){return minTime; }
return minTime; public int getNumberOfHintsUsed(){return numberOfHintsUsed; }
} public int getNumberOfGames(){ return numberOfGames; }
public int getNumberOfHintsUsed(){ public int getNumberOfGamesNoHints(){ return numberOfGamesNoHints; }
return numberOfHintsUsed; public int getTimeNoHints(){ return timeNoHints; }
}
public int getNumberOfGames(){
return numberOfGames;
}
private GameType parseGameType(String s){ private GameType parseGameType(String s){
return GameType.valueOf(s); return GameType.valueOf(s);
@ -117,20 +121,11 @@ public class HighscoreInfoContainer {
sb.append(type.name()); sb.append(type.name());
sb.append("/"); sb.append("/");
sb.append(difficulty.name()); 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("/");
sb.append(gd.name()); sb.append(numberOfGamesNoHints);
sb.append("/"); sb.append("/");
sb.append(numberOfHints); sb.append(timeNoHints);
sb.append("/");
sb.append(gt.name());
return sb.toString(); return sb.toString();
} }

View file

@ -237,7 +237,7 @@ public class StatsActivity extends AppCompatActivity {
} }
difficultyBarView.setRating(pos+1); difficultyBarView.setRating(pos+1);
difficultyView.setText(rootView.getResources().getString(infos.getDifficulty().getStringResID())); 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); averageTimeView.setText(s);
s = (infos.getMinTime()==Integer.MAX_VALUE)? "/":String.valueOf(infos.getMinTime()); s = (infos.getMinTime()==Integer.MAX_VALUE)? "/":String.valueOf(infos.getMinTime());
minTimeView.setText(s); minTimeView.setText(s);