Commit b5b8934a authored by Matyáš Latner's avatar Matyáš Latner

Merge branch 'V3.4' into feature-copyright2

parents 2d417b36 e61a050c
[submodule "core/external"]
[submodule "core/external/tablexia-shared"]
path = core/external/tablexia-shared
url = git@gitlab.labs.nic.cz:labs/tablexia-model.git
[submodule "core/external/copyright-test"]
......
......@@ -16,8 +16,8 @@
#
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 bodů: [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_victory_text_2=Tohle nebylo vůbec špatné! Stačilo málo a důkazy by byly neprůstřelné.
......
......@@ -16,8 +16,8 @@
#
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=Punktezahl: [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_victory_text_2=Das war gar nicht schlecht! Es fehlt nicht viel und die Beweise wären bombensicher.
......
......@@ -16,8 +16,8 @@
#
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=Počet bodov: [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ť!
game_nocnisledovani_victory_text_2=To vôbec nebolo zlé! Stačilo málo a dôkazy by boli nepriestrelné.
......
/Model/nbproject/private/
\ No newline at end of file
Subproject commit 473867f6fa7f1721cb93f706a050f0b136647ec5
Subproject commit 68850450f6feeaaa7699750a5b2515549a60eaa1
......@@ -60,11 +60,6 @@ public class TablexiaSettings {
public static final String LOCALE_KEY = "locale";
private static final String SELECTED_USER = "selected_user";
public static final int EXPERIENCE_POINTS_TUTORIAL = 0;
public static final int EXPERIENCE_POINTS_EASY = 1;
public static final int EXPERIENCE_POINTS_MEDIUM = 2;
public static final int EXPERIENCE_POINTS_HARD = 3;
//Interval <start month; end month>
private static final int WINTER_MODE_START_MONTH = 10;
private static final int WINTER_MODE_END_MONTH = 2;
......@@ -429,28 +424,28 @@ public class TablexiaSettings {
}
public enum LocaleDefinition {
SYSTEM (null, "system", 0, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true),
cs_CZ (new Locale("cs", "CZ"), "cs_CZ", 1, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, true),
sk_SK (new Locale("sk", "SK"), "sk_SK", 2, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, true),
de_DE (new Locale("de", "DE"), "de_DE", 3, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, true);
SYSTEM (null, null, "system", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true),
cs_CZ (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.cs_CZ, new Locale("cs", "CZ"), "cs_CZ", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, true),
sk_SK (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.sk_SK, new Locale("sk", "SK"), "sk_SK", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, true),
de_DE (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.de_DE, new Locale("de", "DE"), "de_DE", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, true);
public final static LocaleDefinition DEFAULT_LOCALE = LocaleDefinition.cs_CZ;
private final static LocaleDefinition FALLBACK_VARIANT = LocaleDefinition.SYSTEM;
private final Locale locale;
private final String localeKey;
private final int localeNumber;
private final String descriptionKey;
private boolean enabled;
private final cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition;
private final Locale locale;
private final String localeKey;
private final String descriptionKey;
private final boolean enabled;
private static List<LocaleDefinition> enabledLocaleDefinitions;
LocaleDefinition(Locale locale, String localeKey, int localeNumber, String descriptionKey, boolean enabled) {
this.locale = locale;
this.localeKey = localeKey;
this.localeNumber = localeNumber;
this.descriptionKey = descriptionKey;
this.enabled = enabled;
LocaleDefinition(cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition, Locale locale, String localeKey, String descriptionKey, boolean enabled) {
this.modelLocaleDefinition = modelLocaleDefinition;
this.locale = locale;
this.localeKey = localeKey;
this.descriptionKey = descriptionKey;
this.enabled = enabled;
}
public String getLocaleKey() {
......@@ -458,7 +453,7 @@ public class TablexiaSettings {
}
public int getLocaleNumber() {
return localeNumber;
return getLocaleDefinitionForLocale(getLocale()).modelLocaleDefinition.number();
}
public String getDescriptionKey() {
......
......@@ -79,6 +79,8 @@ import cz.nic.tablexia.screen.halloffame.trophy.TrophyHelper;
import cz.nic.tablexia.screen.profile.ProfileScreen;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.GameScore;
import cz.nic.tablexia.shared.model.definitions.DifficultyDefinition;
import cz.nic.tablexia.shared.model.definitions.GameResultDefinition;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.MusicUtil;
import cz.nic.tablexia.util.actions.MoveAlongAction;
......@@ -127,30 +129,43 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
public enum GameResult {
NO_STAR(0, null),
ONE_STAR(1, RATINGSTAR1_SOUND),
TWO_STAR(2, RATINGSTAR2_SOUND),
THREE_STAR(3, RATINGSTAR3_SOUND);
NO_STAR (GameResultDefinition.NO_STAR, null),
ONE_STAR (GameResultDefinition.ONE_STAR, RATINGSTAR1_SOUND),
TWO_STAR (GameResultDefinition.TWO_STAR, RATINGSTAR2_SOUND),
THREE_STAR (GameResultDefinition.THREE_STAR, RATINGSTAR3_SOUND);
private int starCount;
private GameResultDefinition gameResultDefinition;
private String startSoundName;
GameResult(int starCount, String startSoundName) {
this.starCount = starCount;
GameResult(GameResultDefinition gameResultDefinition, String startSoundName) {
this.gameResultDefinition = gameResultDefinition;
this.startSoundName = startSoundName;
}
public int getStarCount() {
return starCount;
return gameResultDefinition.number();
}
public String getStartSoundName() {
return startSoundName;
}
public GameResultDefinition getGameResultDefinition() {
return gameResultDefinition;
}
public static GameResult getGameResultForStartCount(int starCount) {
for (GameResult gameResult : GameResult.values()) {
if (gameResult.starCount == starCount) {
if (gameResult.getStarCount() == starCount) {
return gameResult;
}
}
return null;
}
public static GameResult getGameResultForGameResultDefinition(GameResultDefinition gameCupsResult) {
for(GameResult gameResult : values()) {
if(gameResult.gameResultDefinition == gameCupsResult) {
return gameResult;
}
}
......@@ -514,7 +529,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
@Override
public void clicked(InputEvent event, float x, float y) {
if(getGamePhase() == GamePhase.STARTED) {
forceGameEnd(GameResult.THREE_STAR);
forceGameEnd(GameResultDefinition.THREE_STAR);
debugEndGameButton.setDisabled();
}
}
......@@ -1369,15 +1384,15 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
ApplicationBus.getInstance().publishAsync(new StartIncrementalSynchronizationEvent(getSelectedUser().getId()));
}
private void forceGameEnd(GameResult gameResult) {
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getGameScoreList(getGameDifficulty(), gameResult);
private void forceGameEnd(GameResultDefinition gameResult) {
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getExampleScoreForGameResult(getGameDifficulty().getDifficultyDefinition(), gameResult);
setGameScores(gameScores);
waitForActualGameScore();
onForceGameEnd(gameResult);
}
protected void onForceGameEnd(GameResult gameResult) {
protected void onForceGameEnd(GameResultDefinition gameResult) {
endGame();
showGameResultDialog();
}
......
......@@ -29,14 +29,11 @@ import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.crime_scene.CrimeSceneGame;
import cz.nic.tablexia.game.games.in_the_darkness.InTheDarknessGame;
import cz.nic.tablexia.game.games.kidnapping.KidnappingGame;
import cz.nic.tablexia.game.games.kidnapping.util.KidnappingResultResolver;
import cz.nic.tablexia.game.games.night_watch.NightWatchGame;
import cz.nic.tablexia.game.games.pursuit.PursuitGame;
import cz.nic.tablexia.game.games.robbery.RobberyGame;
import cz.nic.tablexia.game.games.runes.RunesGame;
import cz.nic.tablexia.game.games.runes.model.RunesGameResultResolver;
import cz.nic.tablexia.game.games.shooting_range.ShootingRangeGame;
import cz.nic.tablexia.game.games.shooting_range.tools.ShootingRangeResultResolver;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.IMenuItem;
......@@ -51,19 +48,20 @@ import cz.nic.tablexia.screen.gamemenu.gamepages.RunesPageScreen;
import cz.nic.tablexia.screen.gamemenu.gamepages.ShootingRangePageScreen;
import cz.nic.tablexia.shared.model.GameScore;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.resolvers.AbstractGameScoreResolver;
public enum GameDefinition implements ApplicationEvent, IMenuItem {
//TODO - Add Menu Class
ROBBERY (1, ApplicationTextManager.ApplicationTextsAssets.GAME_ROBBERY_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_ROBBERY_DESCRIPTION, RobberyPageScreen.class, RobberyGame.class, false, new RobberyGame.GameResultResolver(), ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
PURSUIT (2, ApplicationTextManager.ApplicationTextsAssets.GAME_PURSUIT_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_PURSUIT_DESCRIPTION, PursuitPageScreen.class, PursuitGame.class, false, new PursuitGame.GameResultResolver(), ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE_DURATION, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE_DURATION),
KIDNAPPING (3, ApplicationTextManager.ApplicationTextsAssets.GAME_KIDNAPPING_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_KIDNAPPING_DESCRIPTION, KidnappingPageScreen.class, KidnappingGame.class, false, new KidnappingResultResolver(), ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE_ERROR, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE_ERROR),
NIGHT_WATCH (4, ApplicationTextManager.ApplicationTextsAssets.GAME_NIGHT_WATCH_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_NIGHT_WATCH_DESCRIPTION, NightWatchPageScreen.class, NightWatchGame.class, false, new NightWatchGame.GameResultResolver(), ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
SHOOTING_RANGE (5, ApplicationTextManager.ApplicationTextsAssets.GAME_SHOOTING_RANGE_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_SHOOTING_RANGE_DESCRIPTION, ShootingRangePageScreen.class, ShootingRangeGame.class, false, new ShootingRangeResultResolver(), ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
IN_THE_DARKNESS (6, ApplicationTextManager.ApplicationTextsAssets.GAME_IN_THE_DARKNESS_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_IN_THE_DARKNESS_DESCRIPTION, InTheDarknessPageScreen.class, InTheDarknessGame.class, true, new InTheDarknessGame.GameResultResolver(),ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE_ERROR, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE_ERROR),
RUNES (7, ApplicationTextManager.ApplicationTextsAssets.GAME_RUNES_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_RUNES_DESCRIPTION, RunesPageScreen.class, RunesGame.class, false, new RunesGameResultResolver(),ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
CRIME_SCENE (8, ApplicationTextManager.ApplicationTextsAssets.GAME_CRIME_SCENE_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_CRIME_SCENE_DESCRIPTION, CrimeScenePageScreen.class, CrimeSceneGame.class, false, new CrimeSceneGame.GameResultResolver(), ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE);
ROBBERY (cz.nic.tablexia.shared.model.definitions.GameDefinition.ROBBERY, ApplicationTextManager.ApplicationTextsAssets.GAME_ROBBERY_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_ROBBERY_DESCRIPTION, RobberyPageScreen.class, RobberyGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
PURSUIT (cz.nic.tablexia.shared.model.definitions.GameDefinition.PURSUIT, ApplicationTextManager.ApplicationTextsAssets.GAME_PURSUIT_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_PURSUIT_DESCRIPTION, PursuitPageScreen.class, PursuitGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE_DURATION, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE_DURATION),
KIDNAPPING (cz.nic.tablexia.shared.model.definitions.GameDefinition.KIDNAPPING, ApplicationTextManager.ApplicationTextsAssets.GAME_KIDNAPPING_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_KIDNAPPING_DESCRIPTION, KidnappingPageScreen.class, KidnappingGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE_ERROR, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE_ERROR),
NIGHT_WATCH (cz.nic.tablexia.shared.model.definitions.GameDefinition.NIGHT_WATCH, ApplicationTextManager.ApplicationTextsAssets.GAME_NIGHT_WATCH_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_NIGHT_WATCH_DESCRIPTION, NightWatchPageScreen.class, NightWatchGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
SHOOTING_RANGE (cz.nic.tablexia.shared.model.definitions.GameDefinition.SHOOTING_RANGE, ApplicationTextManager.ApplicationTextsAssets.GAME_SHOOTING_RANGE_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_SHOOTING_RANGE_DESCRIPTION, ShootingRangePageScreen.class, ShootingRangeGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
IN_THE_DARKNESS (cz.nic.tablexia.shared.model.definitions.GameDefinition.IN_THE_DARKNESS, ApplicationTextManager.ApplicationTextsAssets.GAME_IN_THE_DARKNESS_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_IN_THE_DARKNESS_DESCRIPTION, InTheDarknessPageScreen.class, InTheDarknessGame.class, true, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE_ERROR, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE_ERROR),
RUNES (cz.nic.tablexia.shared.model.definitions.GameDefinition.RUNES, ApplicationTextManager.ApplicationTextsAssets.GAME_RUNES_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_RUNES_DESCRIPTION, RunesPageScreen.class, RunesGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE),
CRIME_SCENE (cz.nic.tablexia.shared.model.definitions.GameDefinition.CRIME_SCENE, ApplicationTextManager.ApplicationTextsAssets.GAME_CRIME_SCENE_TITLE, ApplicationTextManager.ApplicationTextsAssets.GAME_CRIME_SCENE_DESCRIPTION, CrimeScenePageScreen.class, CrimeSceneGame.class, false, ApplicationTextManager.ApplicationTextsAssets.GAME_SCORE, ApplicationTextManager.ApplicationTextsAssets.GAME_AVERAGE_SCORE);
//TODO - Remove
public static abstract class GameResultResolver {
public abstract AbstractTablexiaGame.GameResult getGameCupsResult(Game game);
public abstract float getGameScoreResult(Game game);
......@@ -80,30 +78,28 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
}
}
private int gameNumber;
private final cz.nic.tablexia.shared.model.definitions.GameDefinition modelGameDefinition;
private String menuTextKey;
private String descriptionResource;
private Class<? extends GamePageScreen> pageClass;
private Class<? extends AbstractTablexiaGame<?>> screenClass;
private boolean hasTutorial;
private GameResultResolver gameResultResolver;
private String statisticsScoreDialogText;
private String statisticsAverageScoreDialogText;
GameDefinition(int gameNumber, String nameResource, String descriptionResource, Class<? extends GamePageScreen> pageClass, Class<? extends AbstractTablexiaGame<?>> screenClass, boolean hasTutorial, GameResultResolver gameResultResolver, String statisticsDialogText, String statisticsAverageScoreDialogText) {
this.gameNumber = gameNumber;
GameDefinition(cz.nic.tablexia.shared.model.definitions.GameDefinition modelGameDefinition, String nameResource, String descriptionResource, Class<? extends GamePageScreen> pageClass, Class<? extends AbstractTablexiaGame<?>> screenClass, boolean hasTutorial, String statisticsDialogText, String statisticsAverageScoreDialogText) {
this.modelGameDefinition = modelGameDefinition;
this.menuTextKey = nameResource;
this.descriptionResource = descriptionResource;
this.pageClass = pageClass;
this.screenClass = screenClass;
this.hasTutorial = hasTutorial;
this.gameResultResolver = gameResultResolver;
this.statisticsScoreDialogText = statisticsDialogText;
this.statisticsAverageScoreDialogText = statisticsAverageScoreDialogText;
}
public int getGameNumber() {
return gameNumber;
return modelGameDefinition.number();
}
@Override
......@@ -157,8 +153,8 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
return null;
}
public GameResultResolver getGameResultResolver(){
return gameResultResolver;
public AbstractGameScoreResolver getGameResultResolver() {
return modelGameDefinition.getGameScoreResolver();
}
public static GameDefinition getGameDefinitionForClass(Class<? extends AbstractTablexiaGame> screenClass) {
......@@ -172,7 +168,7 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
public static GameDefinition getGameDefinitionForGameNumber(int gameNumber) {
for (GameDefinition gameDefinition : GameDefinition.values()) {
if (gameDefinition.gameNumber == gameNumber) {
if (gameDefinition.modelGameDefinition.number() == gameNumber) {
return gameDefinition;
}
}
......
......@@ -23,6 +23,7 @@ import java.util.List;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.definitions.DifficultyDefinition;
/**
* Game difficulty types
......@@ -31,29 +32,31 @@ import cz.nic.tablexia.shared.model.Game;
*/
public enum GameDifficulty {
TUTORIAL(0, TablexiaSettings.EXPERIENCE_POINTS_TUTORIAL, "gamedifficulty_tutorial", false, false),
EASY (1, TablexiaSettings.EXPERIENCE_POINTS_EASY, "gamedifficulty_easy", true, true),
MEDIUM (2, TablexiaSettings.EXPERIENCE_POINTS_MEDIUM, "gamedifficulty_medium", true, true),
HARD (3, TablexiaSettings.EXPERIENCE_POINTS_HARD, "gamedifficulty_hard", true, true);
TUTORIAL(DifficultyDefinition.TUTORIAL, "gamedifficulty_tutorial", false, false),
EASY (DifficultyDefinition.EASY, "gamedifficulty_easy", true, true),
MEDIUM (DifficultyDefinition.MEDIUM, "gamedifficulty_medium", true, true),
HARD (DifficultyDefinition.HARD, "gamedifficulty_hard", true, true);
public static final GameDifficulty DEFAULT_DIFFICULTY = EASY;
public static final GameDifficulty DEFAULT_DIFFICULTY = EASY;
private int difficultyNumber;
private int experiencePointsMultiplier;
private String descriptionResourceKey;
private boolean visible;
private boolean hasScore;
private final DifficultyDefinition difficultyDefinition;
private final String descriptionResourceKey;
private final boolean visible;
private final boolean hasScore;
GameDifficulty(int difficultyNumber, int experiencePointsMultiplier, String descriptionResourceKey, boolean visible, boolean hasScore) {
this.difficultyNumber = difficultyNumber;
this.experiencePointsMultiplier = experiencePointsMultiplier;
GameDifficulty(DifficultyDefinition difficultyDefinition, String descriptionResourceKey, boolean visible, boolean hasScore) {
this.difficultyDefinition = difficultyDefinition;
this.descriptionResourceKey = descriptionResourceKey;
this.visible = visible;
this.hasScore = hasScore;
}
public DifficultyDefinition getDifficultyDefinition() {
return difficultyDefinition;
}
public int getDifficultyNumber() {
return difficultyNumber;
return difficultyDefinition.number();
}
public String getTextDescription() {
......@@ -85,7 +88,7 @@ public enum GameDifficulty {
public static GameDifficulty getGameDifficultyForDifficultyNumber(int difficultyNumber) {
for (GameDifficulty gameDifficulty: GameDifficulty.values()) {
if (gameDifficulty.difficultyNumber == difficultyNumber) {
if (gameDifficulty.difficultyDefinition.number() == difficultyNumber) {
return gameDifficulty;
}
}
......@@ -97,7 +100,7 @@ public enum GameDifficulty {
}
public int getExperiencePointsMultiplier() {
return experiencePointsMultiplier;
return difficultyDefinition.getExperiencePointsMultiplier();
}
public boolean hasScore() {
......
......@@ -40,7 +40,6 @@ import java.util.TimerTask;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.crime_scene.actors.PlaySoundScreen;
import cz.nic.tablexia.game.games.crime_scene.assets.CrimeSceneAssets;
......@@ -50,7 +49,7 @@ import cz.nic.tablexia.game.games.crime_scene.gameobject.GameObjectType;
import cz.nic.tablexia.game.games.crime_scene.model.*;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationInternalTextureManager;
import cz.nic.tablexia.shared.model.GameScore;
import cz.nic.tablexia.shared.model.resolvers.CrimeSceneScoreResolver;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.ui.AnimatedImage;
import cz.nic.tablexia.util.ui.actionwidget.Action;
......@@ -82,8 +81,9 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
private static final int GAME_MAP_PADDING = 25;
private static final int GAME_MAP_SIZE = 625;
private static final int ACTION_CARD_EXTRA_LARGE = 2 * ACTION_CARD_DRAG_SIZE;
private static final String SCORE_KEY_COUNT = "score_count";
private static final String RESULT_SCORE_COUNT = "result_score_count";
private static final String SCORE_KEY_COUNT = CrimeSceneScoreResolver.SCORE_KEY_COUNT;
private static final String RESULT_SCORE_COUNT = CrimeSceneScoreResolver.RESULT_SCORE_COUNT;
private static final float ANIMATION_DURATION = 0.3f;
private static final float FADE_DURATION = 1f;
......@@ -123,39 +123,6 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
private int level = 1;
private int wrongRounds = 0;
public static class GameResultResolver extends GameDefinition.GameResultResolver {
private static final String FORMATTED_TEXT_FOR_STATISTICS_FORMAT = "%d / %d";
@Override
public AbstractTablexiaGame.GameResult getGameCupsResult(Game game) {
return ResultStars.getStarCountForDifficultyAndErrors(GameDifficulty.getGameDifficultyForDifficultyNumber(game.getGameDifficulty()),
Integer.parseInt(game.getGameScore(SCORE_KEY_COUNT, String.valueOf(correctSounds))));
}
@Override
public float getGameScoreResult(Game game) {
return Float.parseFloat(game.getGameScore(SCORE_KEY_COUNT, String.valueOf(correctSounds)));
}
@Override
public float getStatisticsScore(Game game) {
//Score to sort graph values in statistics is calculated as "actualScore / maxScore". So 2 cups on hard difficulty wont show up higher than 3 cups on medium difficulty.
return getGameScoreResult(game) / (float)(getMaxScoreForDifficulty(GameDifficulty.getGameDifficultyForDifficultyNumber(game.getGameDifficulty())));
}
@Override
public String getFormattedScoreForStatistics(Game game) {
return String.format(FORMATTED_TEXT_FOR_STATISTICS_FORMAT, Math.round(getGameScoreResult(game)), getMaxScoreForDifficulty(GameDifficulty.getGameDifficultyForDifficultyNumber(game.getGameDifficulty())));
}
@Override
public List<GameScore> getGameScoreList(GameDifficulty difficulty, GameResult result) {
ArrayList gameScoreList = new ArrayList<GameScore>(1);
gameScoreList.add(new GameScore(SCORE_KEY_COUNT, String.valueOf(ResultStars.getScoreForGameResultAndDifficulty(result, difficulty))));
return gameScoreList;
}
}
@Override
protected void gameLoaded(java.util.Map gameState) {
setUpActionsStripWidget();
......
......@@ -24,6 +24,7 @@ import java.util.Random;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.in_the_darkness.action.InTheDarknessActionType;
import cz.nic.tablexia.game.games.in_the_darkness.map.IMapProvider;
import cz.nic.tablexia.game.games.in_the_darkness.map.InTheDarknessMap;
import cz.nic.tablexia.game.games.in_the_darkness.map.MapGenerator;
import cz.nic.tablexia.game.games.in_the_darkness.map.MapTutorial;
import cz.nic.tablexia.util.Log;
......@@ -36,23 +37,25 @@ import cz.nic.tablexia.util.Log;
*/
public enum InTheDarknessDifficulty {
TUTORIAL(GameDifficulty.TUTORIAL, false, MapTutorial.class, 1, Arrays.asList(new InTheDarknessActionType[]{})),
EASY (GameDifficulty.EASY, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{})),
MEDIUM (GameDifficulty.MEDIUM, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY})),
HARD (GameDifficulty.HARD, true, MapGenerator.class, 2, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY}));
TUTORIAL(GameDifficulty.TUTORIAL, false, MapTutorial.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.SMALL_MAP),
EASY (GameDifficulty.EASY, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.SMALL_MAP),
MEDIUM (GameDifficulty.MEDIUM, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.LARGE_MAP),
HARD (GameDifficulty.HARD, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY}), InTheDarknessMap.LARGE_MAP);
private GameDifficulty gameDifficulty;
private int floorCount;
private InTheDarknessMap map;
private List<InTheDarknessActionType> difficultyInTheDarknessActionTypes;
private Class<? extends IMapProvider> mapProviderClass;
private boolean hasResults;
InTheDarknessDifficulty(GameDifficulty gameDifficulty, boolean hasResults, Class<? extends IMapProvider> mapProviderClass, int floorCount, List<InTheDarknessActionType> difficultyInTheDarknessActionTypes) {
InTheDarknessDifficulty(GameDifficulty gameDifficulty, boolean hasResults, Class<? extends IMapProvider> mapProviderClass, int floorCount, List<InTheDarknessActionType> difficultyInTheDarknessActionTypes, InTheDarknessMap map) {
this.gameDifficulty = gameDifficulty;
this.hasResults = hasResults;
this.mapProviderClass = mapProviderClass;
this.floorCount = floorCount;
this.difficultyInTheDarknessActionTypes = difficultyInTheDarknessActionTypes;
this.map = map;
}
public boolean hasResults() {
......@@ -62,7 +65,11 @@ public enum InTheDarknessDifficulty {
public int getFloorCount() {
return floorCount;
}
public InTheDarknessMap getMap() {
return map;
}
public boolean hasDifficultyActionType(InTheDarknessActionType inTheDarknessActionType) {
return difficultyInTheDarknessActionTypes.contains(inTheDarknessActionType);
}
......
......@@ -38,9 +38,8 @@ import java.util.Map;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.in_the_darkness.action.InTheDarknessActionType;
import cz.nic.tablexia.shared.model.resolvers.InTheDarknessScoreResolver;
import cz.nic.tablexia.util.ui.actionwidget.Action;
import cz.nic.tablexia.util.ui.actionwidget.ActionContainer;
import cz.nic.tablexia.util.ui.actionwidget.ActionsStripWidget;
......@@ -56,7 +55,6 @@ import cz.nic.tablexia.loader.application.ApplicationInternalTextureManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.game.GameDAO;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.GameScore;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.ui.AnimatedImage;
......@@ -82,48 +80,6 @@ import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence;
* Created by Matyáš Latner on 7.9.15.
*/
public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> implements MapWidget.TileMapClickListener {
public static class GameResultResolver extends GameDefinition.GameResultResolver {
public static final int ERROR_COUNT_THREE_STARS = 2;
public static final int ERROR_COUNT_TWO_STARS = 4;
public static final int ERROR_COUNT_ONE_STAR = 8;
@Override
public AbstractTablexiaGame.GameResult getGameCupsResult(Game game) {
Integer errorsCount = Integer.valueOf(game.getGameScoreValue(InTheDarknessGame.SCORE_KEY_ERRORS_COUNT));
if (errorsCount < ERROR_COUNT_THREE_STARS) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (errorsCount < ERROR_COUNT_TWO_STARS) {
return AbstractTablexiaGame.GameResult.TWO_STAR;
} else if (errorsCount < ERROR_COUNT_ONE_STAR) {
return AbstractTablexiaGame.GameResult.ONE_STAR;
} else {
return AbstractTablexiaGame.GameResult.NO_STAR;
}
}
@Override
public float getGameScoreResult(Game game) {
return Float.parseFloat(game.getGameScore(InTheDarknessGame.SCORE_KEY_ERRORS_COUNT, "0"));
}
@Override
public List<GameScore> getGameScoreList(GameDifficulty difficulty, GameResult result) {
int errors;
switch (result) {
case NO_STAR: errors = GameResultResolver.ERROR_COUNT_ONE_STAR + 1; break;
case ONE_STAR: errors = GameResultResolver.ERROR_COUNT_ONE_STAR - 1; break;
case TWO_STAR: errors = GameResultResolver.ERROR_COUNT_TWO_STARS - 1; break;
default: errors = GameResultResolver.ERROR_COUNT_THREE_STARS - 1; break;
}
List<GameScore> gameScores = new ArrayList<GameScore>(1);
gameScores.add(new GameScore(SCORE_KEY_ERRORS_COUNT, Integer.toString(errors)));
return gameScores;
}
}
public enum GameLayer {
BACKGROUND_TEXTURE_LAYER (0, Touchable.disabled),
......@@ -183,8 +139,8 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
}
}
private static final String SCORE_KEY_PLANNING_DURATION = "planning_duration";
public static final String SCORE_KEY_ERRORS_COUNT = "errors_count";
private static final String SCORE_KEY_PLANNING_DURATION = InTheDarknessScoreResolver.SCORE_KEY_PLANNING_DURATION;
public static final String SCORE_KEY_ERRORS_COUNT = InTheDarknessScoreResolver.SCORE_KEY_ERRORS_COUNT;
private static final Interpolation.Pow FADE_IN_INTERPOLATION = Interpolation.pow2;
private static final float FADE_DURATION = 0.4f;
......@@ -205,7 +161,7 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
private static final String START_BUTTON_TEXT_KEY = "complete";
private static final String START_BUTTON_ICON_KEY = ApplicationInternalTextureManager.BUTTON_YES_ICON;
public static final float ANIMATION_DURATION = 0.4f;
public static final float ANIMATION_DURATION = 0.25f;
public static final int ERROR_ACTION_DELAY = 1;
public static final int FINISH_ACTION_DELAY = 1;
......@@ -217,15 +173,14 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
private static final int ACTION_STRIP_WIDGET_WIDTH = 155;
public static final int MAP_X_SIZE = 7;
public static final int MAP_Y_SIZE = 6;
public static final TileMap.TileMapPosition DEFAULT_MAP_START_POSITION = new TileMap.TileMapPosition(MAP_X_SIZE - 1, MAP_Y_SIZE - 2);
public static final int TILE_SIZE = 78;
public static final int MAP_START_POSITION_X = 62;
public static final int DEFAULT_MAP_START_POSITION_X = 62;
public static final int MAP_START_POSITION_Y = 52;
private static final int MAXIMUM_ACTIONS_COUNT = 200;
private final int MAX_MAP_X_SIZE = 7;
private final int START_TILE_OFFSET_X = 1;
private final int START_TILE_OFFSET_Y = 2;
private static final String BOOKMARK_FLOOR_TEXT_KEY = "floor";
private static final String SCORE0_TEXT_KEY = "score_0";
......@@ -267,6 +222,9 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
private long planningStartTime;
public static int mapSizeX;
public static int mapSizeY;
public static TileMap.TileMapPosition defaultMapStartPosition;
//////////////////////////////////////////// ABSTRACT TABLEXIA GAME
......@@ -299,6 +257,10 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
for (int i = 0; i < floorCount; i++) {
mapSizeX = getInTheDarknessDifficulty().getMap().getSizeX();
mapSizeY = getInTheDarknessDifficulty().getMap().getSizeY();
defaultMapStartPosition = new TileMap.TileMapPosition(mapSizeX - START_TILE_OFFSET_X, mapSizeY - START_TILE_OFFSET_Y);
MapObjectType finishMapObjectMapObjectType;
if (i == (floorCount - 1)) {
finishMapObjectMapObjectType = MapObjectType.SAFE;
......@@ -307,7 +269,7 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
}
boolean floorHasKey = hasKey && ((floorCount - 1) / 2) == i;
Log.info(getClass(), "Preparing map for floor number: " + (i + 1));
MapWidget mapWidget = new MapWidget(getInTheDarknessDifficulty().getMapProviderNewInstance(getRandom()), lastFinishPosition, finishMapObjectMapObjectType, i, floorCount > 1, MAP_START_POSITION_X, MAP_START_POSITION_Y, MAP_X_SIZE, MAP_Y_SIZE, floorHasKey, getText(BOOKMARK_FLOOR_TEXT_KEY));
MapWidget mapWidget = new MapWidget(getInTheDarknessDifficulty().getMapProviderNewInstance(getRandom()), lastFinishPosition, finishMapObjectMapObjectType, i, floorCount > 1, getMapStartPositionX(), MAP_START_POSITION_Y, mapSizeX, mapSizeY, floorHasKey, getText(BOOKMARK_FLOOR_TEXT_KEY));
mapWidgets.add(mapWidget);
if (i == 0) {
......@@ -486,7 +448,7 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
@Override
public void run() {
InTheDarknessActionType.values()[selectedActions.get(selectedActionPosition).getAction().getActionNumber()].performActionTypeRule(InTheDarknessGame.this, tileMap, player, MAP_START_POSITION_X, MAP_START_POSITION_Y, new InTheDarknessActionType.IActionFinishedListener() {
InTheDarknessActionType.values()[selectedActions.get(selectedActionPosition).getAction().getActionNumber()].performActionTypeRule(InTheDarknessGame.this, tileMap, player, getMapStartPositionX(), MAP_START_POSITION_Y, new InTheDarknessActionType.IActionFinishedListener() {
@Override
public void onActionFinished(boolean