Commit d55c9a3c authored by Anton Danilov's avatar Anton Danilov Committed by Anton Danilov

#342 Now showing both old and new type of score in statistics

parent 155cd852
game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybně označená okna: [BLACK]{0}[]
victory_text_time_mistakes=Chybně nastavený čas: [BLACK]{0}[]
victory_text_rounds=Počet odehraných kol: [BLACK]{0}[]
game_nocnisledovani_loadingtext=Dávej pozor, která okna se po setmění rozsvítí a v kolik hodin. Po rozednění nastav na hodinách čas a označ okna, která byla rozsvícená.
game_nocnisledovani_victory_text_0=To vypadá, že tady někdo usnul na\u00A0hlídce.
game_nocnisledovani_victory_text_1=U\u00A0soudu by tyhle důkazy neuspěly. To ale neznamená, že se nemůže zadařit příště!
......
game_nocnisledovani_btncontinue_text=Fertig
victory_text_window_mistakes=Falsch markierte Fenster: [BLACK]{0}[]
victory_text_time_mistakes=Falsch eingestellte Zeit: [BLACK]{0}[]
victory_text_rounds=*DE* Počet odehraných kol: [BLACK]{0}[]
game_nocnisledovani_loadingtext=Pass auf, welche Fenster nach Einbruch der Dunkelheit leuchten und um wieviel Uhr. Stelle nach Tageseinbruch in der Uhr die Zeit ein und markiere die Fenster, die geleuchtet haben.
game_nocnisledovani_victory_text_0=Es sieht so aus, als wäre hier jemand bei der Wache eingeschlafen.
game_nocnisledovani_victory_text_1=Vor Gericht hätten diese Beweise keinen Erfolg. Das heißt aber nicht, dass es nächstes Mal nicht gelingen kann!
......
game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybne označené okná: [BLACK]{0}[]
victory_text_time_mistakes=Chybne nastavený čas: [BLACK]{0}[]
victory_text_rounds=*SK* Počet odehraných kol: [BLACK]{0}[]
game_nocnisledovani_loadingtext=Dávaj pozor, ktoré okná sa po\u00A0zotmení rozsvietia a o\u00A0ktorej. Po\u00A0svitaní nastav na\u00A0hodinách čas a označ okná, ktoré boli rozsvietené.
game_nocnisledovani_victory_text_0=Vyzerá to tak, že tu niekto zaspal na\u00A0hliadke.
game_nocnisledovani_victory_text_1=Na súde by tieto dôkazy neuspeli. To ale neznamená, že sa to nemôže podariť!
......
......@@ -5,63 +5,34 @@ import cz.nic.tablexia.game.difficulty.GameDifficulty;
/**
* Created by Vendik on 30.4.2015.
* Edited by danilov on 3.8.2016.
*/
public class GameRulesHelper {
//time difference is divided by number of rounds in each level showing the same number of windows
private static final float STARTING_LID_TIME = 1.5f;
private static final float END_LID_TIME = 0.7f;
private static final int NUMBER_OF_LEVELS = 2;
public static final int NUMBER_OF_ROUNDS = 12;
public static final int ONE_STAR = 3;
public static final int TWO_STARS = 7;
public static final int THREE_STARS = 11;
public static final int OLD_VERSION_ONE_STAR = 4;
public static final int OLD_VERSION_TWO_STARS = 8;
public static final int OLD_VERSION_THREE_STARS = 13;
public static final int SCORE_THREE_STARS = 13;
public static final int SCORE_TWO_STARS = 8;
public static final int SCORE_ONE_STAR = 4;
public static int getRoundsPerLevelCount(GameDifficulty gameDifficulty, int level) {
switch (gameDifficulty) {
case EASY:
if (level == 0) {
return 4;
} else if (level == 1) {
return 4;
}
case MEDIUM:
if (level == 0) {
return 3;
} else if (level == 1) {
return 5;
}
case HARD:
if (level == 0) {
return 5;
} else if (level == 1) {
return 3;
}
default:
throw new IllegalArgumentException();
}
}
private static int[] easyLevelWindows = new int[] {1,1,1,2,2,3,3,4,4,4,5,5};
private static int[] mediumLevelWindows = new int[] {1,2,2,3,3,4,4,5,5,5,6,6};
private static int[] hardLevelWindows = new int[] {1,2,3,3,4,4,5,5,6,6,6,7};
public static int getNumberOfWindowsLightenedInCurrentRound(GameDifficulty gameDifficulty, int level) {
public static int getNumberOfWindowsLightenedInCurrentRound(GameDifficulty gameDifficulty, int round) {
switch (gameDifficulty) {
case EASY:
if (level == 0) {
return 1;
} else if (level == 1) {
return 2;
}
return easyLevelWindows[round];
case MEDIUM:
if (level == 0) {
return 1;
} else if (level == 1) {
return 2;
}
return mediumLevelWindows[round];
case HARD:
if (level == 0) {
return 2;
} else if (level == 1) {
return 3;
}
return hardLevelWindows[round];
default:
throw new IllegalArgumentException();
}
......@@ -84,23 +55,28 @@ public class GameRulesHelper {
}
}
public static int getNumberOfLevelsPerGame(){
return NUMBER_OF_LEVELS;
}
public static float getCurrentLidTime(GameDifficulty gameDifficulty,int level,int currentRound){
int numberOfRoundsInCurrentLevel = getRoundsPerLevelCount(gameDifficulty, level);
float timeUnit = (STARTING_LID_TIME - END_LID_TIME) / numberOfRoundsInCurrentLevel;
public static float getCurrentLidTime(int currentRound){
float timeUnit = (STARTING_LID_TIME - END_LID_TIME) / NUMBER_OF_ROUNDS;
return STARTING_LID_TIME - (timeUnit * currentRound);
}
public static AbstractTablexiaGame.GameResult getNumberOfStarsForResult(int points){
if (points > SCORE_THREE_STARS) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (points > SCORE_TWO_STARS) {
return AbstractTablexiaGame.GameResult.TWO_STAR;
} else if (points > SCORE_ONE_STAR) {
return AbstractTablexiaGame.GameResult.ONE_STAR;
public static AbstractTablexiaGame.GameResult getNumberOfStarsForResult(int points, boolean oldVersion){
if(oldVersion) {
if (points > OLD_VERSION_THREE_STARS) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (points > OLD_VERSION_TWO_STARS) {
return AbstractTablexiaGame.GameResult.TWO_STAR;
} else if (points > OLD_VERSION_ONE_STAR) {
return AbstractTablexiaGame.GameResult.ONE_STAR;
}
} else {
if (points > THREE_STARS) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (points > TWO_STARS) {
return AbstractTablexiaGame.GameResult.TWO_STAR;
} else if (points > ONE_STAR) {
return AbstractTablexiaGame.GameResult.ONE_STAR;
}
}
return AbstractTablexiaGame.GameResult.NO_STAR;
}
......
package cz.nic.tablexia.game.games.night_watch.solution;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
......@@ -11,26 +9,19 @@ import cz.nic.tablexia.game.games.night_watch.helper.GameRulesHelper;
/**
* Created by Václav Tarantík on 13.5.15.
* Edited by danilov on 3.8.16.
*/
public class GameSolutionGenerator {
public static Map<Integer,List<Solution>> generateSolutions(GameDifficulty gameDifficulty,Random random) {
Map<Integer,List<Solution>> mapToReturn = new HashMap<Integer, List<Solution>>();
int numberOfLevels = GameRulesHelper.getNumberOfLevelsPerGame();
for (int i = 0; i < numberOfLevels; i++) {
int numberOfRoundsInCurrentLevel = GameRulesHelper.getRoundsPerLevelCount(gameDifficulty,i);
List<Solution> currentLevelSolutions = new ArrayList<Solution>();
for (int j = 0; j < numberOfRoundsInCurrentLevel; j++) {
int totalWindows = GameRulesHelper.getNumberOfWindowsForDifficulty(gameDifficulty);
int lightenedWindows = GameRulesHelper.getNumberOfWindowsLightenedInCurrentRound(gameDifficulty, i);
Solution currentRoundSolution = new Solution(PropertiesGenerator.getRandomWindowSequence(totalWindows, lightenedWindows, random), PropertiesGenerator.getRandomTime(random));
currentLevelSolutions.add(currentRoundSolution);
}
mapToReturn.put(i, currentLevelSolutions);
}
return mapToReturn;
public static List<Solution> generateSolutions(GameDifficulty gameDifficulty, Random random) {
int numberOfRounds = GameRulesHelper.NUMBER_OF_ROUNDS;
List<Solution> currentLevelSolutions = new ArrayList<Solution>();
for(int i = 0; i < numberOfRounds; i++) {
int totalWindows = GameRulesHelper.getNumberOfWindowsForDifficulty(gameDifficulty);
int lightenedWindows = GameRulesHelper.getNumberOfWindowsLightenedInCurrentRound(gameDifficulty, i);
Solution currentRoundSolution = new Solution(PropertiesGenerator.getRandomWindowSequence(totalWindows, lightenedWindows, random), PropertiesGenerator.getRandomTime(random));
currentLevelSolutions.add(currentRoundSolution);
}
return currentLevelSolutions;
}
}
......@@ -5,6 +5,7 @@ import java.util.Calendar;
import java.util.List;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.screen.statistics.views.GraphPane;
import cz.nic.tablexia.shared.model.Game;
/**
......@@ -81,7 +82,7 @@ public class StatisticsGameScoreResolver {
public float getMaxScore(List<Game> games) {
float maxScore = -Float.MAX_VALUE;
for (Game game : games) {
float score = selectedGameDefinition.getGameResultResolver().getGameScoreResult(game);
float score = GraphPane.checkAndCorrectOldVersionScore(game, selectedGameDefinition.getGameResultResolver().getGameScoreResult(game));
if (score > maxScore) maxScore = score;
}
return maxScore;
......@@ -90,7 +91,7 @@ public class StatisticsGameScoreResolver {
public float getMinScore(List<Game> games) {
float minScore = Float.MAX_VALUE;
for (Game game : games) {
float score = selectedGameDefinition.getGameResultResolver().getGameScoreResult(game);
float score = GraphPane.checkAndCorrectOldVersionScore(game, selectedGameDefinition.getGameResultResolver().getGameScoreResult(game));
if (score < minScore) minScore = score;
}
return minScore;
......
......@@ -176,6 +176,8 @@ public class GraphPane extends WidgetGroup {
Actor clickArea = new Actor();
final Image graphPoint = new Image(pointTextureRegion);
score = checkAndCorrectOldVersionScore(game, score);
setPropertiesToGraphPoint(clickArea, score, numberOfGames, index, isFlipOfGraphNeeded(selectedGameDefinition));
setPropertiesToGraphPoint(graphPoint, score, numberOfGames, index, isFlipOfGraphNeeded(selectedGameDefinition));
......@@ -224,6 +226,21 @@ public class GraphPane extends WidgetGroup {
return false;
}
/**
* Converting old score from NIGHTWATCH game.
* Max score in old version is 16.
* New max score is 12, but minimum is now 2.
*
* @param game Any game
* @param score Score of game
* @return If old version of NIGHTWATCH, corrected score. Otherwise former score.
*/
public static float checkAndCorrectOldVersionScore(Game game, float score) {
if(game.getGameNumber() == GameDefinition.NIGHT_WATCH.getGameNumber() && game.getApplicationVersionCode() == Game.DEFAULT_APPLICATION_VERSION_CODE) {
return (int) (score / 16 * 10) + 2;
}
return score;
}
private void setPropertiesToGraphPoint(Actor actor, float score, int numberOfGames, int index, boolean flippedGraph) {
......
Markdown is supported
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