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 path = core/external/tablexia-shared
url = git@gitlab.labs.nic.cz:labs/tablexia-model.git url = git@gitlab.labs.nic.cz:labs/tablexia-model.git
[submodule "core/external/copyright-test"] [submodule "core/external/copyright-test"]
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
# #
game_nocnisledovani_btncontinue_text=Hotovo game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybně označená okna: [BLACK]{0}[] victory_text_rounds=Počet bodů: [BLACK]{0}[]
victory_text_time_mistakes=Chybně nastavený čas: [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_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_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é. 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 @@ ...@@ -16,8 +16,8 @@
# #
game_nocnisledovani_btncontinue_text=Fertig game_nocnisledovani_btncontinue_text=Fertig
victory_text_window_mistakes=Falsch markierte Fenster: [BLACK]{0}[] victory_text_rounds=Punktezahl: [BLACK]{0}[]
victory_text_time_mistakes=Falsch eingestellte Zeit: [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_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_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. game_nocnisledovani_victory_text_2=Das war gar nicht schlecht! Es fehlt nicht viel und die Beweise wären bombensicher.
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
# #
game_nocnisledovani_btncontinue_text=Hotovo game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybne označené okná: [BLACK]{0}[] victory_text_rounds=Počet bodov: [BLACK]{0}[]
victory_text_time_mistakes=Chybne nastavený čas: [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_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_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é. 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 { ...@@ -60,11 +60,6 @@ public class TablexiaSettings {
public static final String LOCALE_KEY = "locale"; public static final String LOCALE_KEY = "locale";
private static final String SELECTED_USER = "selected_user"; 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> //Interval <start month; end month>
private static final int WINTER_MODE_START_MONTH = 10; private static final int WINTER_MODE_START_MONTH = 10;
private static final int WINTER_MODE_END_MONTH = 2; private static final int WINTER_MODE_END_MONTH = 2;
...@@ -429,28 +424,28 @@ public class TablexiaSettings { ...@@ -429,28 +424,28 @@ public class TablexiaSettings {
} }
public enum LocaleDefinition { public enum LocaleDefinition {
SYSTEM (null, "system", 0, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true), SYSTEM (null, null, "system", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true),
cs_CZ (new Locale("cs", "CZ"), "cs_CZ", 1, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, 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 (new Locale("sk", "SK"), "sk_SK", 2, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, 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 (new Locale("de", "DE"), "de_DE", 3, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, 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; public final static LocaleDefinition DEFAULT_LOCALE = LocaleDefinition.cs_CZ;
private final static LocaleDefinition FALLBACK_VARIANT = LocaleDefinition.SYSTEM; private final static LocaleDefinition FALLBACK_VARIANT = LocaleDefinition.SYSTEM;
private final Locale locale; private final cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition;
private final String localeKey; private final Locale locale;
private final int localeNumber; private final String localeKey;
private final String descriptionKey; private final String descriptionKey;
private boolean enabled; private final boolean enabled;
private static List<LocaleDefinition> enabledLocaleDefinitions; private static List<LocaleDefinition> enabledLocaleDefinitions;
LocaleDefinition(Locale locale, String localeKey, int localeNumber, String descriptionKey, boolean enabled) { LocaleDefinition(cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition, Locale locale, String localeKey, String descriptionKey, boolean enabled) {
this.locale = locale; this.modelLocaleDefinition = modelLocaleDefinition;
this.localeKey = localeKey; this.locale = locale;
this.localeNumber = localeNumber; this.localeKey = localeKey;
this.descriptionKey = descriptionKey; this.descriptionKey = descriptionKey;
this.enabled = enabled; this.enabled = enabled;
} }
public String getLocaleKey() { public String getLocaleKey() {
...@@ -458,7 +453,7 @@ public class TablexiaSettings { ...@@ -458,7 +453,7 @@ public class TablexiaSettings {
} }
public int getLocaleNumber() { public int getLocaleNumber() {
return localeNumber; return getLocaleDefinitionForLocale(getLocale()).modelLocaleDefinition.number();
} }
public String getDescriptionKey() { public String getDescriptionKey() {
......
...@@ -79,6 +79,8 @@ import cz.nic.tablexia.screen.halloffame.trophy.TrophyHelper; ...@@ -79,6 +79,8 @@ import cz.nic.tablexia.screen.halloffame.trophy.TrophyHelper;
import cz.nic.tablexia.screen.profile.ProfileScreen; import cz.nic.tablexia.screen.profile.ProfileScreen;
import cz.nic.tablexia.shared.model.Game; import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.GameScore; 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.Log;
import cz.nic.tablexia.util.MusicUtil; import cz.nic.tablexia.util.MusicUtil;
import cz.nic.tablexia.util.actions.MoveAlongAction; import cz.nic.tablexia.util.actions.MoveAlongAction;
...@@ -127,30 +129,43 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T> ...@@ -127,30 +129,43 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
public enum GameResult { public enum GameResult {
NO_STAR(0, null), NO_STAR (GameResultDefinition.NO_STAR, null),
ONE_STAR(1, RATINGSTAR1_SOUND), ONE_STAR (GameResultDefinition.ONE_STAR, RATINGSTAR1_SOUND),
TWO_STAR(2, RATINGSTAR2_SOUND), TWO_STAR (GameResultDefinition.TWO_STAR, RATINGSTAR2_SOUND),
THREE_STAR(3, RATINGSTAR3_SOUND); THREE_STAR (GameResultDefinition.THREE_STAR, RATINGSTAR3_SOUND);
private int starCount; private GameResultDefinition gameResultDefinition;
private String startSoundName; private String startSoundName;
GameResult(int starCount, String startSoundName) { GameResult(GameResultDefinition gameResultDefinition, String startSoundName) {
this.starCount = starCount; this.gameResultDefinition = gameResultDefinition;
this.startSoundName = startSoundName; this.startSoundName = startSoundName;
} }
public int getStarCount() { public int getStarCount() {
return starCount; return gameResultDefinition.number();
} }
public String getStartSoundName() { public String getStartSoundName() {
return startSoundName; return startSoundName;
} }
public GameResultDefinition getGameResultDefinition() {
return gameResultDefinition;
}
public static GameResult getGameResultForStartCount(int starCount) { public static GameResult getGameResultForStartCount(int starCount) {
for (GameResult gameResult : GameResult.values()) { 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; return gameResult;
} }
} }
...@@ -514,7 +529,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T> ...@@ -514,7 +529,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if(getGamePhase() == GamePhase.STARTED) { if(getGamePhase() == GamePhase.STARTED) {
forceGameEnd(GameResult.THREE_STAR); forceGameEnd(GameResultDefinition.THREE_STAR);
debugEndGameButton.setDisabled(); debugEndGameButton.setDisabled();
} }
} }
...@@ -1369,15 +1384,15 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T> ...@@ -1369,15 +1384,15 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
ApplicationBus.getInstance().publishAsync(new StartIncrementalSynchronizationEvent(getSelectedUser().getId())); ApplicationBus.getInstance().publishAsync(new StartIncrementalSynchronizationEvent(getSelectedUser().getId()));
} }
private void forceGameEnd(GameResult gameResult) { private void forceGameEnd(GameResultDefinition gameResult) {
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getGameScoreList(getGameDifficulty(), gameResult); List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getExampleScoreForGameResult(getGameDifficulty().getDifficultyDefinition(), gameResult);
setGameScores(gameScores); setGameScores(gameScores);
waitForActualGameScore(); waitForActualGameScore();
onForceGameEnd(gameResult); onForceGameEnd(gameResult);
} }
protected void onForceGameEnd(GameResult gameResult) { protected void onForceGameEnd(GameResultDefinition gameResult) {
endGame(); endGame();
showGameResultDialog(); showGameResultDialog();
} }
......
...@@ -23,6 +23,7 @@ import java.util.List; ...@@ -23,6 +23,7 @@ import java.util.List;
import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.shared.model.Game; import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.definitions.DifficultyDefinition;
/** /**
* Game difficulty types * Game difficulty types
...@@ -31,29 +32,31 @@ import cz.nic.tablexia.shared.model.Game; ...@@ -31,29 +32,31 @@ import cz.nic.tablexia.shared.model.Game;
*/ */
public enum GameDifficulty { public enum GameDifficulty {
TUTORIAL(0, TablexiaSettings.EXPERIENCE_POINTS_TUTORIAL, "gamedifficulty_tutorial", false, false), TUTORIAL(DifficultyDefinition.TUTORIAL, "gamedifficulty_tutorial", false, false),
EASY (1, TablexiaSettings.EXPERIENCE_POINTS_EASY, "gamedifficulty_easy", true, true), EASY (DifficultyDefinition.EASY, "gamedifficulty_easy", true, true),
MEDIUM (2, TablexiaSettings.EXPERIENCE_POINTS_MEDIUM, "gamedifficulty_medium", true, true), MEDIUM (DifficultyDefinition.MEDIUM, "gamedifficulty_medium", true, true),
HARD (3, TablexiaSettings.EXPERIENCE_POINTS_HARD, "gamedifficulty_hard", 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 final DifficultyDefinition difficultyDefinition;
private int experiencePointsMultiplier; private final String descriptionResourceKey;
private String descriptionResourceKey; private final boolean visible;
private boolean visible; private final boolean hasScore;
private boolean hasScore;
GameDifficulty(int difficultyNumber, int experiencePointsMultiplier, String descriptionResourceKey, boolean visible, boolean hasScore) { GameDifficulty(DifficultyDefinition difficultyDefinition, String descriptionResourceKey, boolean visible, boolean hasScore) {
this.difficultyNumber = difficultyNumber; this.difficultyDefinition = difficultyDefinition;
this.experiencePointsMultiplier = experiencePointsMultiplier;
this.descriptionResourceKey = descriptionResourceKey; this.descriptionResourceKey = descriptionResourceKey;
this.visible = visible; this.visible = visible;
this.hasScore = hasScore; this.hasScore = hasScore;
} }
public DifficultyDefinition getDifficultyDefinition() {
return difficultyDefinition;
}
public int getDifficultyNumber() { public int getDifficultyNumber() {
return difficultyNumber; return difficultyDefinition.number();
} }
public String getTextDescription() { public String getTextDescription() {
...@@ -85,7 +88,7 @@ public enum GameDifficulty { ...@@ -85,7 +88,7 @@ public enum GameDifficulty {
public static GameDifficulty getGameDifficultyForDifficultyNumber(int difficultyNumber) { public static GameDifficulty getGameDifficultyForDifficultyNumber(int difficultyNumber) {
for (GameDifficulty gameDifficulty: GameDifficulty.values()) { for (GameDifficulty gameDifficulty: GameDifficulty.values()) {
if (gameDifficulty.difficultyNumber == difficultyNumber) { if (gameDifficulty.difficultyDefinition.number() == difficultyNumber) {
return gameDifficulty; return gameDifficulty;
} }
} }
...@@ -97,7 +100,7 @@ public enum GameDifficulty { ...@@ -97,7 +100,7 @@ public enum GameDifficulty {
} }
public int getExperiencePointsMultiplier() { public int getExperiencePointsMultiplier() {
return experiencePointsMultiplier; return difficultyDefinition.getExperiencePointsMultiplier();
} }
public boolean hasScore() { public boolean hasScore() {
......
...@@ -40,7 +40,6 @@ import java.util.TimerTask; ...@@ -40,7 +40,6 @@ import java.util.TimerTask;
import cz.nic.tablexia.TablexiaApplication; import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.game.AbstractTablexiaGame; import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty; 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.actors.PlaySoundScreen;
import cz.nic.tablexia.game.games.crime_scene.assets.CrimeSceneAssets; import cz.nic.tablexia.game.games.crime_scene.assets.CrimeSceneAssets;
...@@ -50,7 +49,7 @@ import cz.nic.tablexia.game.games.crime_scene.gameobject.GameObjectType; ...@@ -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.game.games.crime_scene.model.*;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager; import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationInternalTextureManager; 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.ScaleUtil;
import cz.nic.tablexia.util.ui.AnimatedImage; import cz.nic.tablexia.util.ui.AnimatedImage;
import cz.nic.tablexia.util.ui.actionwidget.Action; import cz.nic.tablexia.util.ui.actionwidget.Action;
...@@ -82,8 +81,9 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> { ...@@ -82,8 +81,9 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
private static final int GAME_MAP_PADDING = 25; private static final int GAME_MAP_PADDING = 25;
private static final int GAME_MAP_SIZE = 625; private static final int GAME_MAP_SIZE = 625;
private static final int ACTION_CARD_EXTRA_LARGE = 2 * ACTION_CARD_DRAG_SIZE; 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 ANIMATION_DURATION = 0.3f;
private static final float FADE_DURATION = 1f; private static final float FADE_DURATION = 1f;
...@@ -123,39 +123,6 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> { ...@@ -123,39 +123,6 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
private int level = 1; private int level = 1;
private int wrongRounds = 0; 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 @Override
protected void gameLoaded(java.util.Map gameState) { protected void gameLoaded(java.util.Map gameState) {
setUpActionsStripWidget(); setUpActionsStripWidget();
......
...@@ -24,6 +24,7 @@ import java.util.Random; ...@@ -24,6 +24,7 @@ import java.util.Random;
import cz.nic.tablexia.game.difficulty.GameDifficulty; 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.action.InTheDarknessActionType;
import cz.nic.tablexia.game.games.in_the_darkness.map.IMapProvider; 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.MapGenerator;
import cz.nic.tablexia.game.games.in_the_darkness.map.MapTutorial; import cz.nic.tablexia.game.games.in_the_darkness.map.MapTutorial;
import cz.nic.tablexia.util.Log; import cz.nic.tablexia.util.Log;
...@@ -36,23 +37,25 @@ import cz.nic.tablexia.util.Log; ...@@ -36,23 +37,25 @@ import cz.nic.tablexia.util.Log;
*/ */
public enum InTheDarknessDifficulty { public enum InTheDarknessDifficulty {
TUTORIAL(GameDifficulty.TUTORIAL, false, MapTutorial.class, 1, Arrays.asList(new InTheDarknessActionType[]{})), 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[]{})), 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[]{InTheDarknessActionType.KEY})), MEDIUM (GameDifficulty.MEDIUM, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.LARGE_MAP),
HARD (GameDifficulty.HARD, true, MapGenerator.class, 2, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY})); HARD (GameDifficulty.HARD, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY}), InTheDarknessMap.LARGE_MAP);
private GameDifficulty gameDifficulty; private GameDifficulty gameDifficulty;
private int floorCount; private int floorCount;
private InTheDarknessMap map;
private List<InTheDarknessActionType> difficultyInTheDarknessActionTypes; private List<InTheDarknessActionType> difficultyInTheDarknessActionTypes;
private Class<? extends IMapProvider> mapProviderClass; private Class<? extends IMapProvider> mapProviderClass;
private boolean hasResults; 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.gameDifficulty = gameDifficulty;
this.hasResults = hasResults; this.hasResults = hasResults;
this.mapProviderClass = mapProviderClass; this.mapProviderClass = mapProviderClass;
this.floorCount = floorCount; this.floorCount = floorCount;
this.difficultyInTheDarknessActionTypes = difficultyInTheDarknessActionTypes; this.difficultyInTheDarknessActionTypes = difficultyInTheDarknessActionTypes;
this.map = map;
} }
public boolean hasResults() { public boolean hasResults() {
...@@ -62,7 +65,11 @@ public enum InTheDarknessDifficulty { ...@@ -62,7 +65,11 @@ public enum InTheDarknessDifficulty {
public int getFloorCount() { public int getFloorCount() {
return floorCount; return floorCount;
} }
public InTheDarknessMap getMap() {
return map;
}
public boolean hasDifficultyActionType(InTheDarknessActionType inTheDarknessActionType) { public boolean hasDifficultyActionType(InTheDarknessActionType inTheDarknessActionType) {
return difficultyInTheDarknessActionTypes.contains(inTheDarknessActionType); return difficultyInTheDarknessActionTypes.contains(inTheDarknessActionType);
} }
......
...@@ -26,7 +26,8 @@ public final class InTheDarknessAssets { ...@@ -26,7 +26,8 @@ public final class InTheDarknessAssets {
public static final String BACKGROUND_PATH = GFX_PATH + "background/"; public static final String BACKGROUND_PATH = GFX_PATH + "background/";
public static final String BACKGROUND = BACKGROUND_PATH + "background"; public static final String BACKGROUND = BACKGROUND_PATH + "background";
public static final String BACKGROUND_MAP = BACKGROUND_PATH + "background_map"; public static final String BACKGROUND_SMALL_MAP = BACKGROUND_PATH + "background_small_map";
public static final String BACKGROUND_LARGE_MAP = BACKGROUND_PATH + "background_large_map";
public static final String BACKGROUND_ACTIONS = BACKGROUND_PATH + "background_actions"; public static final String BACKGROUND_ACTIONS = BACKGROUND_PATH + "background_actions";
public static final String OBJECTS_PATH = GFX_PATH + "objects/"; public static final String OBJECTS_PATH = GFX_PATH + "objects/";
......
...@@ -284,7 +284,7 @@ public class Player extends Group { ...@@ -284,7 +284,7 @@ public class Player extends Group {
} }
private float getPlayerPositionYForTileMapPosition(int mapStartPositionY, TileMapPosition tileMapPosition) { private float getPlayerPositionYForTileMapPosition(int mapStartPositionY, TileMapPosition tileMapPosition) {
return mapStartPositionY + ((InTheDarknessGame.MAP_Y_SIZE - tileMapPosition.getPositionY() - 1) * InTheDarknessGame.TILE_SIZE) + (InTheDarknessGame.TILE_SIZE / 2) - (actualPlayerAnimatedImage.getHeight() / 2); return mapStartPositionY + ((InTheDarknessGame.mapSizeY - tileMapPosition.getPositionY() - 1) * InTheDarknessGame.TILE_SIZE) + (InTheDarknessGame.TILE_SIZE / 2) - (actualPlayerAnimatedImage.getHeight() / 2);
} }
private AnimatedImage createPlayerAnimatedImage(int width, int height, String animationName, int framesCount, InTheDarknessGame inTheDarknessGame) { private AnimatedImage createPlayerAnimatedImage(int width, int height, String animationName, int framesCount, InTheDarknessGame inTheDarknessGame) {
......
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.game.games.in_the_darkness.map;
import cz.nic.tablexia.game.games.in_the_darkness.assets.InTheDarknessAssets;
public enum InTheDarknessMap {
SMALL_MAP(InTheDarknessAssets.BACKGROUND_SMALL_MAP, 5, 6),
LARGE_MAP(InTheDarknessAssets.BACKGROUND_LARGE_MAP, 7, 6);
private String mapTexture;
private int sizeX;
private int sizeY;
InTheDarknessMap(String mapTexture, int sizeX, int sizeY) {
this.mapTexture = mapTexture;
this.sizeX = sizeX;
this.sizeY = sizeY;
}
public String getMapTexture() {
return mapTexture;
}
public int getSizeY() {
return sizeY;
}
public int getSizeX() {
return sizeX;
}
}
...@@ -142,7 +142,7 @@ public class MapGenerator implements IMapProvider { ...@@ -142,7 +142,7 @@ public class MapGenerator implements IMapProvider {
if (lastEndTile == null) { if (lastEndTile == null) {
// create entry tile // create entry tile
startPosition = InTheDarknessGame.DEFAULT_MAP_START_POSITION; startPosition = InTheDarknessGame.defaultMapStartPosition;
startTile = new Tile(TileType.getRandomTileTypeForAvailableDoors(null, true, null, null, true, randomAccess)); startTile = new Tile(TileType.getRandomTileTypeForAvailableDoors(null, true, null, null, true, randomAccess));
} else { } else {
startPosition = lastEndTile.getTileMapPosition(); startPosition = lastEndTile.getTileMapPosition();
...@@ -324,7 +324,7 @@ public class MapGenerator implements IMapProvider { ...@@ -324,7 +324,7 @@ public class MapGenerator implements IMapProvider {
private boolean generatePathFromPointToPoint(TileMap tileMap, TileMapPosition startPosition, TileMapPosition finishPosition, boolean useOnlyFreeTiles, boolean generateFinalTile, List<TileMapPosition> bannedPositions) { private boolean generatePathFromPointToPoint(TileMap tileMap, TileMapPosition startPosition, TileMapPosition finishPosition, boolean useOnlyFreeTiles, boolean generateFinalTile, List<TileMapPosition> bannedPositions) {
int generatorMaxCycleCounter = 0; int generatorMaxCycleCounter = 0;
int generatorMaxCycleCount = InTheDarknessGame.MAP_X_SIZE * InTheDarknessGame.MAP_Y_SIZE; int generatorMaxCycleCount = InTheDarknessGame.mapSizeX * InTheDarknessGame.mapSizeY;
int lastXPosition = startPosition.getPositionX(); int lastXPosition = startPosition.getPositionX();
int lastYPosition = startPosition.getPositionY(); int lastYPosition = startPosition.getPositionY();
......
...@@ -35,7 +35,7 @@ public class MapTutorial implements IMapProvider { ...@@ -35,7 +35,7 @@ public class MapTutorial implements IMapProvider {
public TileMap prepareMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey) { public TileMap prepareMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey) {
TileMap tileMap = new TileMap(mapXSize, mapYSize); TileMap tileMap = new TileMap(mapXSize, mapYSize);
TileMapPosition position1 = InTheDarknessGame.DEFAULT_MAP_START_POSITION; TileMapPosition position1 = InTheDarknessGame.defaultMapStartPosition;
TileMapPosition position2 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY()); TileMapPosition position2 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY());
TileMapPosition position3 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY() - 1); TileMapPosition position3 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY() - 1);
tileMap.setMapStartPosition(position1); tileMap.setMapStartPosition(position1);
......