Commit 6e844525 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

#550 Swapped medium and hard difficulty. Code refactoring.

parent da1a3943
......@@ -96,8 +96,8 @@ game_runes_title = Symboly
game_runes_description = Procvičování zrakového rozlišování
game_runes_preloader1=Podívej se na symboly v\u00A0pásu vpravo.
game_runes_preloader2_easy=Najdi je na domech a\u00A0označ dřív, než ti dojde čas.
game_runes_preloader2_medium=Najdi na domech jejich zrcadlově otočené varianty a\u00A0označ je dřív, než ti dojde čas.
game_runes_preloader2_hard=Najdi je na domech schované mezi jednotlivými symboly a\u00A0označ je dřív, než ti dojde čas.
game_runes_preloader2_medium=Najdi je na domech schované mezi jednotlivými symboly a\u00A0označ je dřív, než ti dojde čas.
game_runes_preloader2_hard=Najdi na domech jejich zrcadlově otočené varianty a\u00A0označ je dřív, než ti dojde čas.
# <!-- Robbery -->
robbery_1_finished=Pouta standard
......
......@@ -96,8 +96,8 @@ game_runes_title=Symbole
game_runes_description=Training der Visuellen Unterscheidung
game_runes_preloader1=Sieh dir die Symbole auf dem rechten Balken an.
game_runes_preloader2_easy=Finde sie auf den Häusern und markiere sie, bevor die Zeit abgelaufen ist.
game_runes_preloader2_medium=Finde die gespiegelten Varianten der Zeichen auf den Häusern und markiere sie, bevor die Zeit abgelaufen ist.
game_runes_preloader2_hard=Finde sie auf den Häusern, wo sie zwischen anderen Symbolen versteckt sind, und markiere sie, bevor die Zeit abgelaufen ist.
game_runes_preloader2_medium=Finde sie auf den Häusern, wo sie zwischen anderen Symbolen versteckt sind, und markiere sie, bevor die Zeit abgelaufen ist.
game_runes_preloader2_hard=Finde die gespiegelten Varianten der Zeichen auf den Häusern und markiere sie, bevor die Zeit abgelaufen ist.
# <!-- Robbery -->
robbery_1_finished=Handschellen Standard
......
......@@ -98,8 +98,8 @@ game_runes_title=Symboly
game_runes_description=Precvičovanie zrakového rozlišovania
game_runes_preloader1=Pozri sa na symboly v páse vpravo.
game_runes_preloader2_easy=Nájdi ich na domoch a označ skôr, ako ti vyprší čas.
game_runes_preloader2_medium=Nájdi na domoch ich zrkadlovo otočené varianty a označ ich skôr, ako ti vyprší čas.
game_runes_preloader2_hard=Nájdi ich na domoch skryté medzi inými symbolmi a označ ich skôr, ako ti vyprší čas.
game_runes_preloader2_medium=Nájdi ich na domoch skryté medzi inými symbolmi a označ ich skôr, ako ti vyprší čas.
game_runes_preloader2_hard=Nájdi na domoch ich zrkadlovo otočené varianty a označ ich skôr, ako ti vyprší čas.
# <!-- Robbery -->
robbery_1_finished=Púta štandard
......
......@@ -29,6 +29,7 @@ import cz.nic.tablexia.game.games.runes.assets.RuneDefinition;
import cz.nic.tablexia.game.games.runes.assets.RunesGameAssets;
import cz.nic.tablexia.game.games.runes.helper.HolderManager;
import cz.nic.tablexia.game.games.runes.helper.PositionDefinition;
import cz.nic.tablexia.game.games.runes.model.RunesDifficultyDefinition;
import cz.nic.tablexia.game.games.runes.model.RunesGameProperties;
import cz.nic.tablexia.game.games.runes.model.RunesGameState;
import cz.nic.tablexia.loader.TablexiaAbstractFileManager;
......@@ -90,7 +91,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
getStage().addActor(content);
targetPlate.changeTargets(getGameDifficulty(), getData().getRound());
targetPlate.changeTargets(getData().getRound());
placeRunes();
}
......@@ -110,7 +111,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
* Init scene elements with certain positions
*/
private void initScene() {
holderManager = new HolderManager(runesLibrary, correctRuneListener, getGameDifficulty(), getRandom());
holderManager = new HolderManager(runesLibrary, correctRuneListener, RunesDifficultyDefinition.getRunesDifficultyForGameDifficulty(getGameDifficulty()), getRandom());
content = new Group();
runesGroup = new Group();
runesGroup.setVisible(false);
......@@ -142,7 +143,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
sidebarBackground.setFillParent(true);
healthBar = new HealthBar(gfxLibrary.getTextureRegion(RunesGameAssets.GLASS));
targetPlate = new TargetPlate(runesLibrary, getRandom());
targetPlate = new TargetPlate(runesLibrary, getRandom(), RunesDifficultyDefinition.getRunesDifficultyForGameDifficulty(getGameDifficulty()));
score = new TablexiaLabel(getFormattedText(RunesGameAssets.SCORE_TEXT.getResource(), getData().getScore(), RunesGameProperties.RUNES_TO_FIND_TOTAL), new TablexiaLabel.TablexiaLabelStyle(ApplicationFontManager.FontType_NEW.BOLD_18, Color.BLACK));
......@@ -267,7 +268,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
private void placeRunes() {
int maxGroups = PositionDefinition.getGroupsCount(getData().getRound(), getGameDifficulty());
for (int i = 0; i < maxGroups; i++) {
runesGroup.addActor(holderManager.createHolder(targetPlate.getActiveTargetsDescriptions(), getGameDifficulty()));
runesGroup.addActor(holderManager.createHolder(targetPlate.getActiveTargetsDescriptions()));
}
updateBoard();
}
......@@ -286,7 +287,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
runesGroup.addAction(Actions.fadeIn(FADE_ANIMATION_DURATION));
getData().setPhase(RunesGameState.RunesGamePhase.GAME);
timeBar.startGameState();
targetPlate.changeTargets(getGameDifficulty(), getData().getRound());
targetPlate.changeTargets(getData().getRound());
targetPlate.addAction(Actions.fadeIn(FADE_ANIMATION_DURATION));
holderManager.clearHolders();
......@@ -301,7 +302,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
private void updateBoard() {
List<PositionDefinition> newPositions = PositionDefinition.getRandomPositions(getGameDifficulty(), getData().getRound(), getRandom());
holderManager.moveHolders(newPositions, getSceneWidth(), getSceneInnerHeight()); // TODO: 6.9.16 set w/h at beginning
holderManager.updateHolders(targetPlate.getActiveTargetsDescriptions(), getData().getRound(), getGameDifficulty());
holderManager.updateHolders(targetPlate.getActiveTargetsDescriptions(), getData().getRound());
holderManager.foldAll();
}
......@@ -336,7 +337,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
};
private boolean correctHit(IRune iRune) {
return targetPlate.isTarget(iRune, getGameDifficulty());
return targetPlate.isTarget(iRune);
}
private void finishGame() {
......
......@@ -58,14 +58,6 @@ public class RuneInstance implements RuneDescription {
return new RuneInstance(RuneDefinition.getRandomRuneDefinition(runeGroup, runeExceptions, tablexiaRandom), flipped);
}
public static RuneInstance getSimilarRuneInstance(RuneDefinition runeDefinition, List<RuneDescription> runeExceptions, TablexiaRandom tablexiaRandom) {
return getSimilarRuneInstance(runeDefinition, runeExceptions, tablexiaRandom, false);
}
public static List<RuneDescription> getSimilarRuneInstances(List<RuneDescription> targetRunes, List<RuneDescription> runeExceptions, TablexiaRandom tablexiaRandom, int count) {
return getSimilarRuneInstances(targetRunes, runeExceptions, tablexiaRandom, count, false);
}
public static List<RuneDescription> getSimilarRuneInstances(List<RuneDescription> targetRunes, List<RuneDescription> runeExceptions, TablexiaRandom tablexiaRandom, int count, boolean flipped) {
List<RuneDescription> newDefinitionsList = new ArrayList();
if (targetRunes.size() > 0) {
......
......@@ -34,10 +34,9 @@ public class RunesHolder extends Group {
private HorizontalGroup runesGroup;
private List<RuneDescription> allHolderRunes;
private ClickListener clickListener;
private GameDifficulty gameDifficulty;
private RunesDifficultyDefinition runesDifficultyDefinition;
private int runesCount;
private boolean folded = false;
private boolean flipped;
private float alternativeScale; //scale value that can be changed for every defined map position
private List<RuneDescription> roundTargets;
......@@ -47,17 +46,16 @@ public class RunesHolder extends Group {
private float prevX = 0; //save previous position because of shifting to center when unfolding
public RunesHolder(GfxLibrary runesLibrary, List<RuneDescription> roundTargets, GameDifficulty gameDifficulty, ClickListener clickListener) {
public RunesHolder(GfxLibrary runesLibrary, List<RuneDescription> roundTargets, RunesDifficultyDefinition runesDifficultyDefinition, ClickListener clickListener) {
this.runesLibrary = runesLibrary;
this.clickListener = clickListener;
this.holderTargets = new ArrayList<RuneDescription>();
this.roundTargets = roundTargets;
this.gameDifficulty = gameDifficulty;
this.runesDifficultyDefinition = runesDifficultyDefinition;
setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes());
this.flipped = gameDifficulty.equals(GameDifficulty.MEDIUM);
runesGroup = new HorizontalGroup();
runesGroup.setFillParent(true);
runesGroup.space(RunesDifficultyDefinition.getRunesDifficultyForGameDifficulty(gameDifficulty).getSpace());
runesGroup.space(runesDifficultyDefinition.getTargetType().getSpace());
runesGroup.padLeft(PAD);
runesGroup.padRight(PAD);
setHeight(HEIGHT);
......@@ -94,11 +92,11 @@ public class RunesHolder extends Group {
runesGroup.clearChildren();
}
allHolderRunes.addAll(wrongRunesDescription);
if (!flipped) {
if (!runesDifficultyDefinition.isFlipRunes()) {
allHolderRunes.addAll(holderTargets);
} else {
for (RuneDescription runeDescription : holderTargets) {
allHolderRunes.add(new RuneInstance(runeDescription.getRuneDefinition(), flipped)); //add flipped targets (correct ones)
allHolderRunes.add(new RuneInstance(runeDescription.getRuneDefinition(), runesDifficultyDefinition.isFlipRunes())); //add flipped targets (correct ones)
}
}
}
......@@ -114,7 +112,7 @@ public class RunesHolder extends Group {
}
public void addRunes(TablexiaRandom tablexiaRandom) {
if (gameDifficulty.equals(GameDifficulty.HARD)){
if (runesDifficultyDefinition.getTargetType().equals(RunesDifficultyDefinition.TargetType.CLUSTER)){
for(RuneDescription runeDescription : allHolderRunes){
addRuneActor(RunesCluster.createRuneCluster(runesLibrary, runeDescription, roundTargets, tablexiaRandom));
}
......@@ -197,7 +195,7 @@ public class RunesHolder extends Group {
prevX = 0;
setAlternativeScale(positionDefinition.getScale());
setPosition(positionDefinition.getX() * width, positionDefinition.getY() * height);
maxEntities = PositionDefinition.getMaxChildrenCount(gameDifficulty,positionDefinition);
maxEntities = PositionDefinition.getMaxChildrenCount(runesDifficultyDefinition.getGameDifficulty(),positionDefinition);
}
public boolean isFolded() {
......
......@@ -29,10 +29,12 @@ public class TargetPlate extends Group{
private GfxLibrary runesLibrary;
private TablexiaRandom tablexiaRandom;
private List<RuneDescription> activeTargetsDefinitions = new ArrayList<RuneDescription>();
private RunesDifficultyDefinition runesDifficultyDefinition;
public TargetPlate(GfxLibrary runesLibrary, TablexiaRandom tablexiaRandom) {
public TargetPlate(GfxLibrary runesLibrary, TablexiaRandom tablexiaRandom, RunesDifficultyDefinition runesDifficultyDefinition) {
this.runesLibrary = runesLibrary;
this.tablexiaRandom = tablexiaRandom;
this.runesDifficultyDefinition = runesDifficultyDefinition;
plate = new Group();
addActor(plate);
root = new Table();
......@@ -49,9 +51,9 @@ public class TargetPlate extends Group{
root.setX(getWidth()/2 - root.getWidth()/2);
}
public void changeTargets(GameDifficulty gameDifficulty, int round) {
public void changeTargets(int round) {
RuneDefinition[] runesPool = RunesDifficultyDefinition.getRunesDifficultyForGameDifficulty(gameDifficulty).getRuneDefinitions();
RuneDefinition[] runesPool =runesDifficultyDefinition.getRuneDefinitions();
int targetsCount = RunesGameProperties.RUNES_TO_FIND[round];
if (activeTargetsDefinitions.size()!=0) activeTargetsDefinitions.clear();
......@@ -86,9 +88,9 @@ public class TargetPlate extends Group{
return activeTargetsDefinitions.size() == 0;
}
public boolean isTarget(IRune iRune, GameDifficulty gameDifficulty){
public boolean isTarget(IRune iRune){
Rune rune = findRuneByRuneDefinition(iRune.getType());
if (gameDifficulty.equals(GameDifficulty.MEDIUM)) return isInTargets(iRune.getType()) && rune!=null && rune.isFlipped()!= iRune.isFlipped(); //control if runes are with different mirroring
if (runesDifficultyDefinition.isFlipRunes()) return isInTargets(iRune.getType()) && rune!=null && rune.isFlipped()!= iRune.isFlipped(); //control if runes are with different mirroring
return isInTargets(iRune.getType());
}
......
......@@ -11,6 +11,7 @@ import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.runes.actors.RuneInstance;
import cz.nic.tablexia.game.games.runes.actors.RunesHolder;
import cz.nic.tablexia.game.games.runes.model.RunesDifficultyDefinition;
import cz.nic.tablexia.game.games.runes.model.RunesGameProperties;
/**
......@@ -22,14 +23,14 @@ public class HolderManager {
private GfxLibrary gfxLibrary;
private ClickListener correctRuneListener;
private TablexiaRandom tablexiaRandom;
private GameDifficulty gameDifficulty;
private RunesDifficultyDefinition runesDifficultyDefinition;
public HolderManager(GfxLibrary gfxLibrary, ClickListener correctRuneListener, GameDifficulty gameDifficulty, TablexiaRandom tablexiaRandom) {
public HolderManager(GfxLibrary gfxLibrary, ClickListener correctRuneListener, RunesDifficultyDefinition runesDifficultyDefinition, TablexiaRandom tablexiaRandom) {
this.holders = new ArrayList<RunesHolder>();
this.gfxLibrary = gfxLibrary;
this.correctRuneListener = correctRuneListener;
this.tablexiaRandom = tablexiaRandom;
this.gameDifficulty = gameDifficulty;
this.runesDifficultyDefinition = runesDifficultyDefinition;
}
public void foldAll() {
......@@ -64,7 +65,7 @@ public class HolderManager {
}
}
public void updateHolders(List<RuneDescription> activeTargets, int round, GameDifficulty gameDifficulty) {
public void updateHolders(List<RuneDescription> activeTargets, int round) {
for (RunesHolder rh : holders){
rh.setRoundTargets(activeTargets); // set targets that are present in round
}
......@@ -77,7 +78,7 @@ public class HolderManager {
//distribute runes to holder and set how many will every holder have
runesCount = RunesGameProperties.RUNES_COUNT[round];
int mean = runesCount / RunesGameProperties.getGroupCount(gameDifficulty, round);
int mean = runesCount / RunesGameProperties.getGroupCount(runesDifficultyDefinition.getGameDifficulty(), round);
for (int i = 0; i < holders.size() - 1; i++) {
if (holders.get(i).setRunesCount(mean)) { //will return false if new runes count is bigger than max possible
runesCount -= mean;
......@@ -88,14 +89,13 @@ public class HolderManager {
//last holder will contain remaining runes
holders.get(holders.size() - 1).setRunesCount(runesCount); // TODO: 6.9.16 rework runes count in holders
boolean isMediumDifficulty = gameDifficulty.equals(GameDifficulty.MEDIUM);
for(RunesHolder rh : holders){
rh.updateHolder(tablexiaRandom,RuneInstance.getSimilarRuneInstances(rh.getHolderTargets(), activeTargets, tablexiaRandom, rh.getWrongRunesCount(), isMediumDifficulty));
rh.updateHolder(tablexiaRandom,RuneInstance.getSimilarRuneInstances(rh.getHolderTargets(), activeTargets, tablexiaRandom, rh.getWrongRunesCount(), runesDifficultyDefinition.isFlipRunes()));
}
}
public RunesHolder createHolder(List<RuneDescription> activeTargets, GameDifficulty gameDifficulty){
final RunesHolder runesHolder = new RunesHolder(gfxLibrary, activeTargets , gameDifficulty, correctRuneListener);
public RunesHolder createHolder(List<RuneDescription> activeTargets){
final RunesHolder runesHolder = new RunesHolder(gfxLibrary, activeTargets , runesDifficultyDefinition, correctRuneListener);
runesHolder.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
......
......@@ -9,38 +9,26 @@ import cz.nic.tablexia.game.games.runes.helper.PositionDefinition;
*/
public enum RunesDifficultyDefinition {
DIFFICULTY_EASY(GameDifficulty.EASY, RunesGameProperties.GROUPS_EASY, PositionDefinition.MAP_EASY , "help_easy"),
DIFFICULTY_MEDIUM(GameDifficulty.MEDIUM, RunesGameProperties.GROUPS_MEDIUM, PositionDefinition.MAP_MEDIUM, RuneDefinition.MIRROR_RUNES, "help_medium"),
DIFFICULTY_HARD(GameDifficulty.HARD, RunesGameProperties.GROUPS_HARD, PositionDefinition.MAP_HARD, "help_hard", 20);
private static final int DEFAULT_SPACE_BETWEEN_RUNES = 10;
DIFFICULTY_EASY(GameDifficulty.EASY, RunesGameProperties.GROUPS_EASY, PositionDefinition.MAP_EASY , RuneDefinition.ALL_RUNES, "help_easy", TargetType.DEFAULT, false),
DIFFICULTY_MEDIUM(GameDifficulty.MEDIUM, RunesGameProperties.GROUPS_MEDIUM, PositionDefinition.MAP_MEDIUM, RuneDefinition.ALL_RUNES, "help_medium", TargetType.CLUSTER, false),
DIFFICULTY_HARD(GameDifficulty.HARD, RunesGameProperties.GROUPS_HARD, PositionDefinition.MAP_HARD, RuneDefinition.MIRROR_RUNES, "help_hard", TargetType.DEFAULT, true);
private GameDifficulty gameDifficulty;
private int[] groupsCount;
private PositionDefinition[] positionDefinitions;
private RuneDefinition[] runeDefinitions;
private String ruleSound;
private int space;
private TargetType targetType;
private boolean flipRunes;
RunesDifficultyDefinition(GameDifficulty gameDifficulty, int[] groupsCount, PositionDefinition[] positionDefinitions, String ruleSound) {
this(gameDifficulty,groupsCount,positionDefinitions, RuneDefinition.ALL_RUNES , ruleSound, DEFAULT_SPACE_BETWEEN_RUNES);
}
RunesDifficultyDefinition(GameDifficulty gameDifficulty, int[] groupsCount, PositionDefinition[] positionDefinitions, String ruleSound, int space) {
this(gameDifficulty,groupsCount,positionDefinitions, RuneDefinition.ALL_RUNES , ruleSound, space);
}
RunesDifficultyDefinition(GameDifficulty gameDifficulty, int[] groupsCount, PositionDefinition[] positionDefinitions, RuneDefinition[] runeDefinitions, String ruleSound) {
this(gameDifficulty,groupsCount,positionDefinitions, runeDefinitions , ruleSound, DEFAULT_SPACE_BETWEEN_RUNES);
}
RunesDifficultyDefinition(GameDifficulty gameDifficulty, int[] groupsCount, PositionDefinition[] positionDefinitions, RuneDefinition[] runeDefinitions, String ruleSound, int space) {
RunesDifficultyDefinition(GameDifficulty gameDifficulty, int[] groupsCount, PositionDefinition[] positionDefinitions, RuneDefinition[] runeDefinitions, String ruleSound, TargetType targetType, boolean flipRunes) {
this.gameDifficulty = gameDifficulty;
this.groupsCount = groupsCount;
this.positionDefinitions = positionDefinitions;
this.runeDefinitions = runeDefinitions;
this.ruleSound = ruleSound;
this.space = space;
this.targetType = targetType;
this.flipRunes = flipRunes;
}
public String getRuleSound() {
......@@ -56,6 +44,18 @@ public enum RunesDifficultyDefinition {
return RunesDifficultyDefinition.DIFFICULTY_EASY;
}
public TargetType getTargetType() {
return targetType;
}
public GameDifficulty getGameDifficulty() {
return gameDifficulty;
}
public boolean isFlipRunes() {
return flipRunes;
}
public PositionDefinition[] getPositionDefinitions() {
return positionDefinitions;
}
......@@ -68,7 +68,18 @@ public enum RunesDifficultyDefinition {
return runeDefinitions;
}
public int getSpace() {
return space;
public enum TargetType{
DEFAULT(10),
CLUSTER(20);
int space;
TargetType(int space) {
this.space = space;
}
public int getSpace() {
return space;
}
}
}
......@@ -16,8 +16,9 @@ public class RunesGameProperties {
public static final int[] CUPS_HARD = {15, 26, 38};
public static final int[] GROUPS_EASY = {3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6};
public static final int[] GROUPS_MEDIUM = {3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6};
public static final int[] GROUPS_HARD = {3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7};
public static final int[] GROUPS_MEDIUM = {3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7};
public static final int[] GROUPS_HARD = {3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6};
public static final int[] RUNES_COUNT = {6, 7, 8, 9, 10, 11, 11, 12, 13, 13, 14, 15};
public static final int[] RUNES_TO_FIND = {2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6}; //44
......
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