Commit b3313042 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

Merge branch 'V3.7' into feature-protocol-wall-position

parents c9508b67 cc32f3aa
......@@ -88,6 +88,7 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
public static final String PLAYER = "player";
public static final String EVENT_SHOW_ANIMATION_FINISHED = "show animation finished";
public static final String EVENT_SHOW_OTHER_FLOOR = "show other floor";
public enum GameLayer {
......@@ -191,7 +192,7 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
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";
public static final String BOOKMARK_FLOOR_TEXT_KEY = "floor";
private static final String SCORE0_TEXT_KEY = "score_0";
private static final String SCORE1_TEXT_KEY = "score_1";
private static final String SCORE2_TEXT_KEY = "score_2";
......@@ -684,6 +685,7 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
}
}
GameLayer.PLAYER_LAYER.getLayerEntity().setVisible(player.getActualFloor() == mapWidgetNumber);
triggerScenarioStepEvent(EVENT_SHOW_OTHER_FLOOR);
}
@Override
......
......@@ -135,6 +135,7 @@ public class MapWidget extends Group {
}
}
});
bookmarkButton.setName((floorNumber + 1) + " " + InTheDarknessGame.BOOKMARK_FLOOR_TEXT_KEY);
backgroundLayer.addActor(bookmarkButton);
}
......
......@@ -48,6 +48,7 @@ public class GameRulesHelper {
public static final float BONUS_MAX_LID_TIME = 2.5f;
public static final float BONUS_MIN_LID_TIME = 1.2f;
public static final int NUMBER_OF_ROUNDS = 12;
public static final int BONUS_NUMBER_OF_ROUNDS = 20;
public static final int[] ZERO_NUMBER_OF_SHADOWED = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
public static float getCurrentLidTime(NightWatchDifficulty nightWatchDifficulty, int currentRound){
......
......@@ -30,8 +30,10 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import java.util.List;
import cz.nic.tablexia.game.games.safe.AbstractMechanics;
import cz.nic.tablexia.game.games.safe.SafeGame;
import cz.nic.tablexia.game.games.safe.assets.SafeAssets;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
/**
......@@ -80,6 +82,7 @@ public class BonusCableGroup extends Group {
@Override
public void clicked(InputEvent event, float x, float y) {
safeGame.setSelectedLight(lightImage, listOfLights, true);
AbstractTablexiaScreen.triggerScenarioStepEvent(AbstractMechanics.LIGHT_LIGHTED_UP);
}
});
lightImage.addListener(lightImage.getInputListener());
......
......@@ -23,6 +23,10 @@ TestGameShootingRangeHardNoneStar
TestGameShootingRangeHardOneStar
TestGameShootingRangeHardTwoStar
TestGameShootingRangeHardThreeStar
TestGameShootingRangeBonusNoneStar
TestGameShootingRangeBonusOneStar
TestGameShootingRangeBonusTwoStar
TestGameShootingRangeBonusThreeStar
TestGameRobberyEasyNoneStar
TestGameRobberyEasyOneStar
TestGameRobberyEasyTwoStar
......@@ -35,12 +39,18 @@ TestGameRobberyHardNoneStar
TestGameRobberyHardOneStar
TestGameRobberyHardTwoStar
TestGameRobberyHardThreeStar
TestGameRobberyBonusNoneStar
TestGameRobberyBonusOneStar
TestGameRobberyBonusTwoStars
TestGameRobberyBonusThreeStars
TestGameInTheDarknessEasy
TestGameInTheDarknessMedium
TestGameInTheDarknessHard
TestGameInTheDarknessBonus
TestGameInTheDarknessEasyScenario
TestGameInTheDarknessMediumScenario
TestGameInTheDarknessHardScenario
TestGameInTheDarknessBonusScenario
TestGameNightWatchEasyNoneStar
TestGameNightWatchEasyOneStar
TestGameNightWatchEasyTwoStar
......@@ -53,6 +63,10 @@ TestGameNightWatchHardNoneStar
TestGameNightWatchHardOneStar
TestGameNightWatchHardTwoStar
TestGameNightWatchHardThreeStar
TestGameNightWatchBonusNoneStar
TestGameNightWatchBonusOneStar
TestGameNightWatchBonusTwoStars
TestGameNightWatchBonusThreeStars
TestGamePursuitEasyNoneStar
TestGamePursuitEasyOneStar
TestGamePursuitEasyTwoStar
......@@ -65,6 +79,10 @@ TestGamePursuitHardNoneStar
TestGamePursuitHardOneStar
TestGamePursuitHardTwoStar
TestGamePursuitHardThreeStar
TestGamePursuitBonusNoneStar
TestGamePursuitBonusOneStar
TestGamePursuitBonusTwoStars
TestGamePursuitBonusThreeStars
TestGameCrimeSceneEasyNoneStar
TestGameCrimeSceneEasyOneStar
TestGameCrimeSceneEasyTwoStar
......@@ -77,6 +95,10 @@ TestGameCrimeSceneHardNoneStar
TestGameCrimeSceneHardOneStar
TestGameCrimeSceneHardTwoStar
TestGameCrimeSceneHardThreeStar
TestGameCrimeSceneBonusNoneStar
TestGameCrimeSceneBonusOneStar
TestGameCrimeSceneBonusTwoStar
TestGameCrimeSceneBonusThreeStar
TestGameKidnappingEasyNoneStar
TestGameKidnappingEasyOneStar
TestGameKidnappingEasyTwoStar
......@@ -89,6 +111,10 @@ TestGameKidnappingHardNoneStar
TestGameKidnappingHardOneStar
TestGameKidnappingHardTwoStar
TestGameKidnappingHardThreeStar
TestGameKidnappingBonusNoneStar
TestGameKidnappingBonusOneStar
TestGameKidnappingBonusTwoStars
TestGameKidnappingBonusThreeStars
TestGameRunesEasyNoneStar
TestGameRunesEasyOneStar
TestGameRunesEasyTwoStar
......@@ -101,6 +127,10 @@ TestGameRunesHardNoneStar
TestGameRunesHardOneStar
TestGameRunesHardTwoStar
TestGameRunesHardThreeStar
TestGameRunesBonusNoneStar
TestGameRunesBonusOneStar
TestGameRunesBonusTwoStars
TestGameRunesBonusThreeStars
TestGameProtocolEasyNoneStar <--This test could fail
TestGameProtocolEasyOneStar
TestGameProtocolEasyTwoStar
......@@ -125,6 +155,10 @@ TestGameSafeHardNoneStars
TestGameSafeHardOneStar
TestGameSafeHardTwoStars
TestGameSafeHardThreeStars
TestGameSafeBonusNoneStars
TestGameSafeBonusOneStars
TestGameSafeBonusTwoStars
TestGameSafeBonusThreeStars
TestStatisticsButtons
TestStatisticsRobbery
TestStatisticsCrimeScene
......
......@@ -43,12 +43,18 @@ import cz.nic.tablexia.testing.games.crime_scene.TestGameCrimeSceneMediumNoneSta
import cz.nic.tablexia.testing.games.crime_scene.TestGameCrimeSceneMediumOneStar;
import cz.nic.tablexia.testing.games.crime_scene.TestGameCrimeSceneMediumThreeStar;
import cz.nic.tablexia.testing.games.crime_scene.TestGameCrimeSceneMediumTwoStar;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessBonus;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessBonusScenario;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessEasy;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessEasyScenario;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessHard;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessHardScenario;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessMedium;
import cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknessMediumScenario;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingBonusNoneStar;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingBonusOneStar;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingBonusThreeStars;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingBonusTwoStars;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingEasyNoneStar;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingEasyOneStar;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingEasyThreeStar;
......@@ -61,6 +67,10 @@ import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingMediumNoneStar
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingMediumOneStar;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingMediumThreeStar;
import cz.nic.tablexia.testing.games.kidnapping.TestGameKidnappingMediumTwoStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchBonusNoneStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchBonusOneStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchBonusThreeStars;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchBonusTwoStars;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchEasyNoneStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchEasyOneStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchEasyThreeStar;
......@@ -85,6 +95,8 @@ import cz.nic.tablexia.testing.games.protocol.TestGameProtocolMediumNoneStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolMediumOneStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolMediumThreeStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolMediumTwoStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitBonusNoneStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitBonusOneStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitEasyNoneStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitEasyOneStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitEasyThreeStar;
......@@ -97,6 +109,12 @@ import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitMediumNoneStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitMediumOneStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitMediumThreeStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitMediumTwoStar;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitBonusThreeStars;
import cz.nic.tablexia.testing.games.pursiut.TestGamePursuitBonusTwoStars;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyBonusNoneStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyBonusOneStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyBonusThreeStars;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyBonusTwoStars;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyEasyNoneStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyEasyOneStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyEasyThreeStar;
......@@ -109,6 +127,10 @@ import cz.nic.tablexia.testing.games.robbery.TestGameRobberyMediumNoneStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyMediumOneStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyMediumThreeStar;
import cz.nic.tablexia.testing.games.robbery.TestGameRobberyMediumTwoStar;
import cz.nic.tablexia.testing.games.runes.TestGameRunesBonusNoneStar;
import cz.nic.tablexia.testing.games.runes.TestGameRunesBonusOneStar;
import cz.nic.tablexia.testing.games.runes.TestGameRunesBonusThreeStars;
import cz.nic.tablexia.testing.games.runes.TestGameRunesBonusTwoStars;
import cz.nic.tablexia.testing.games.runes.TestGameRunesEasyNoneStar;
import cz.nic.tablexia.testing.games.runes.TestGameRunesEasyOneStar;
import cz.nic.tablexia.testing.games.runes.TestGameRunesEasyThreeStar;
......@@ -133,6 +155,14 @@ import cz.nic.tablexia.testing.games.safe.TestGameSafeMediumNoneStars;
import cz.nic.tablexia.testing.games.safe.TestGameSafeMediumOneStar;
import cz.nic.tablexia.testing.games.safe.TestGameSafeMediumThreeStars;
import cz.nic.tablexia.testing.games.safe.TestGameSafeMediumTwoStars;
import cz.nic.tablexia.testing.games.safe.TestGameSafeBonusNoneStars;
import cz.nic.tablexia.testing.games.safe.TestGameSafeBonusOneStars;
import cz.nic.tablexia.testing.games.safe.TestGameSafeBonusThreeStars;
import cz.nic.tablexia.testing.games.safe.TestGameSafeBonusTwoStars;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeBonusNoneStar;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeBonusOneStar;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeBonusThreeStar;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeBonusTwoStar;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeEasyNoneStar;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeEasyOneStar;
import cz.nic.tablexia.testing.games.shooting_range.TestGameShootingRangeEasyThreeStar;
......@@ -187,6 +217,10 @@ public class TestRunner {
listOfTests.add(TestGameShootingRangeHardOneStar.class);
listOfTests.add(TestGameShootingRangeHardTwoStar.class);
listOfTests.add(TestGameShootingRangeHardThreeStar.class);
listOfTests.add(TestGameShootingRangeBonusNoneStar.class);
listOfTests.add(TestGameShootingRangeBonusOneStar.class);
listOfTests.add(TestGameShootingRangeBonusTwoStar.class);
listOfTests.add(TestGameShootingRangeBonusThreeStar.class);
listOfTests.add(TestGameRobberyEasyNoneStar.class);
listOfTests.add(TestGameRobberyEasyOneStar.class);
listOfTests.add(TestGameRobberyEasyTwoStar.class);
......@@ -199,12 +233,18 @@ public class TestRunner {
listOfTests.add(TestGameRobberyHardOneStar.class);
listOfTests.add(TestGameRobberyHardTwoStar.class);
listOfTests.add(TestGameRobberyHardThreeStar.class);
listOfTests.add(TestGameRobberyBonusNoneStar.class);
listOfTests.add(TestGameRobberyBonusOneStar.class);
listOfTests.add(TestGameRobberyBonusTwoStars.class);
listOfTests.add(TestGameRobberyBonusThreeStars.class);
listOfTests.add(TestGameInTheDarknessEasy.class);
listOfTests.add(TestGameInTheDarknessMedium.class);
listOfTests.add(TestGameInTheDarknessHard.class);
listOfTests.add(TestGameInTheDarknessEasyScenario.class);
listOfTests.add(TestGameInTheDarknessMediumScenario.class);
listOfTests.add(TestGameInTheDarknessHardScenario.class);
listOfTests.add(TestGameInTheDarknessBonus.class);
listOfTests.add(TestGameInTheDarknessBonusScenario.class);
listOfTests.add(TestGameNightWatchEasyNoneStar.class);
listOfTests.add(TestGameNightWatchEasyOneStar.class);
listOfTests.add(TestGameNightWatchEasyTwoStar.class);
......@@ -217,6 +257,10 @@ public class TestRunner {
listOfTests.add(TestGameNightWatchHardOneStar.class);
listOfTests.add(TestGameNightWatchHardTwoStar.class);
listOfTests.add(TestGameNightWatchHardThreeStar.class);
listOfTests.add(TestGameNightWatchBonusNoneStar.class);
listOfTests.add(TestGameNightWatchBonusOneStar.class);
listOfTests.add(TestGameNightWatchBonusTwoStars.class);
listOfTests.add(TestGameNightWatchBonusThreeStars.class);
listOfTests.add(TestGamePursuitEasyNoneStar.class);
listOfTests.add(TestGamePursuitEasyOneStar.class);
listOfTests.add(TestGamePursuitEasyTwoStar.class);
......@@ -229,6 +273,10 @@ public class TestRunner {
listOfTests.add(TestGamePursuitHardOneStar.class);
listOfTests.add(TestGamePursuitHardTwoStar.class);
listOfTests.add(TestGamePursuitHardThreeStar.class);
listOfTests.add(TestGamePursuitBonusNoneStar.class);
listOfTests.add(TestGamePursuitBonusOneStar.class);
listOfTests.add(TestGamePursuitBonusTwoStars.class);
listOfTests.add(TestGamePursuitBonusThreeStars.class);
listOfTests.add(TestGameCrimeSceneEasyNoneStar.class);
listOfTests.add(TestGameCrimeSceneEasyOneStar.class);
listOfTests.add(TestGameCrimeSceneEasyTwoStar.class);
......@@ -257,6 +305,10 @@ public class TestRunner {
listOfTests.add(TestGameKidnappingHardOneStar.class);
listOfTests.add(TestGameKidnappingHardTwoStar.class);
listOfTests.add(TestGameKidnappingHardThreeStar.class);
listOfTests.add(TestGameKidnappingBonusNoneStar.class);
listOfTests.add(TestGameKidnappingBonusOneStar.class);
listOfTests.add(TestGameKidnappingBonusTwoStars.class);
listOfTests.add(TestGameKidnappingBonusThreeStars.class);
listOfTests.add(TestGameRunesEasyNoneStar.class);
listOfTests.add(TestGameRunesEasyOneStar.class);
listOfTests.add(TestGameRunesEasyTwoStar.class);
......@@ -269,6 +321,10 @@ public class TestRunner {
listOfTests.add(TestGameRunesHardOneStar.class);
listOfTests.add(TestGameRunesHardTwoStar.class);
listOfTests.add(TestGameRunesHardThreeStar.class);
listOfTests.add(TestGameRunesBonusNoneStar.class);
listOfTests.add(TestGameRunesBonusOneStar.class);
listOfTests.add(TestGameRunesBonusTwoStars.class);
listOfTests.add(TestGameRunesBonusThreeStars.class);
listOfTests.add(TestGameProtocolEasyNoneStar.class);
listOfTests.add(TestGameProtocolEasyOneStar.class);
listOfTests.add(TestGameProtocolEasyTwoStar.class);
......@@ -293,6 +349,10 @@ public class TestRunner {
listOfTests.add(TestGameSafeHardOneStar.class);
listOfTests.add(TestGameSafeHardTwoStars.class);
listOfTests.add(TestGameSafeHardThreeStars.class);
listOfTests.add(TestGameSafeBonusNoneStars.class);
listOfTests.add(TestGameSafeBonusOneStars.class);
listOfTests.add(TestGameSafeBonusTwoStars.class);
listOfTests.add(TestGameSafeBonusThreeStars.class);
listOfTests.add(TestStatisticsButtons.class);
listOfTests.add(TestStatisticsRobbery.class);
listOfTests.add(TestStatisticsCrimeScene.class);
......
......@@ -99,6 +99,7 @@ public class TestGameCrimeScene extends AbstractTestGame {
clickAt(incGetSteps() + ". Click at medium difficulty button", GamePageGroup.DIFFICULTY_BUTTON_MEDIUM);
clickAt(incGetSteps() + ". Click at hard difficulty button", GamePageGroup.DIFFICULTY_BUTTON_HARD);
clickAt(incGetSteps() + ". Click at easy difficulty button", GamePageGroup.DIFFICULTY_BUTTON_EASY);
clickAt(incGetSteps() + ". Click at bonus difficulty button", GamePageGroup.DIFFICULTY_BUTTON_BONUS);
//setDifficulty
setGameDificulty();
......
......@@ -33,6 +33,7 @@ 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.InTheDarknessGame;
import cz.nic.tablexia.game.games.in_the_darkness.action.InTheDarknessActionType;
import cz.nic.tablexia.game.games.in_the_darkness.action.widget.ActionsWidget;
......@@ -65,6 +66,7 @@ import static cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarknes
import static cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarkness.TypeStep.KEY;
import static cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarkness.TypeStep.START;
import static cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarkness.TypeStep.WALL;
import static cz.nic.tablexia.testing.games.in_the_darkness.TestGameInTheDarkness.TypeStep.STAIRS;
/**
* Created by lmarik on 21.2.17.
......@@ -80,11 +82,10 @@ public class TestGameInTheDarkness extends AbstractTestGame {
FINISH,
DOOR,
DOG,
KEY
KEY,
STAIRS
}
private int indexFloor = 0;
private int startX = -1;
private int startY = -1;
......@@ -94,6 +95,11 @@ public class TestGameInTheDarkness extends AbstractTestGame {
private int keyX = -1;
private int keyY = -1;
private int stairsFirstFloorX = -1;
private int stairsFirstFloorY = -1;
private int stairsSecondFloorX = -1;
private int stairsSecondFloorY = -1;
private int stairsRevert = -1;
private int stepCount= 0;
private List<Node> openedDoors = new ArrayList<>();
......@@ -135,6 +141,7 @@ public class TestGameInTheDarkness extends AbstractTestGame {
clickAt(incGetSteps() + ". Click at medium difficulty button", GamePageGroup.DIFFICULTY_BUTTON_MEDIUM);
clickAt(incGetSteps() + ". Click at hard difficulty button", GamePageGroup.DIFFICULTY_BUTTON_HARD);
clickAt(incGetSteps() + ". Click at easy difficulty button", GamePageGroup.DIFFICULTY_BUTTON_EASY);
clickAt(incGetSteps() + ". Click at bonus difficulty button", GamePageGroup.DIFFICULTY_BUTTON_BONUS);
//setDifficulty
setGameDificulty();
......@@ -171,23 +178,45 @@ public class TestGameInTheDarkness extends AbstractTestGame {
//PlAY ROUND
takeScreenShot();
if(!haveScenario) {
int[][] matrixMap = parseMap();
if(difficulty == GameDifficulty.BONUS){
int[][] matrixMapFirstFloor = parseMap(0);
//test start exists
if(startX == -1 || startY == -1){
logError("Test not found start in map");
stopTheTest();
}
clickAt(incGetSteps() + "Click at second floor button", "2 " + InTheDarknessGame.BOOKMARK_FLOOR_TEXT_KEY);
waitForEvent(incGetSteps() + "Wait for second floor", InTheDarknessGame.EVENT_SHOW_OTHER_FLOOR);
//test safe exists
if(finishX == -1 || finishY == -1){
logError("Test not found finish in map");
stopTheTest();
}
int[][] matrixMapSecondFloor = parseMap(1);
setActionByAStar(matrixMap);
testStartAndFinishXAndY();
startGame();
//test stairs in first floor exists
if (stairsFirstFloorX == -1 || stairsFirstFloorY == -1) {
logError("Test not found stairs in first floor map");
stopTheTest();
}
//test stairs in second floor exists
if (stairsSecondFloorX == -1 || stairsSecondFloorY == -1) {
logError("Test not found stairs in second floor map");
stopTheTest();
}
clickAt(incGetSteps() + "Click at first floor button", "1 " + InTheDarknessGame.BOOKMARK_FLOOR_TEXT_KEY);
waitForEvent(incGetSteps() + "Wait for first floor", InTheDarknessGame.EVENT_SHOW_OTHER_FLOOR);
setActionByAStarBonus(matrixMapFirstFloor, matrixMapSecondFloor);
startGame();
} else {
int[][] matrixMap = parseMap(0);
testStartAndFinishXAndY();
setActionByAStar(matrixMap);
startGame();
}
}else{
playGameByScenario();
......@@ -210,6 +239,20 @@ public class TestGameInTheDarkness extends AbstractTestGame {
}
private void testStartAndFinishXAndY() {
//test start exists
if (startX == -1 || startY == -1) {
logError("Test not found start in map");
stopTheTest();
}
//test safe exists
if (finishX == -1 || finishY == -1) {
logError("Test not found finish in map");
stopTheTest();
}
}
private void startGame(){
clickAt(incGetSteps() + ". Click on start button",InTheDarknessGame.START_BUTTON);
playTheGame(stepCount*4,0,1);
......@@ -251,12 +294,12 @@ public class TestGameInTheDarkness extends AbstractTestGame {
}
}
private void setActionByAStar(int[][] matrixMap){
private void setActionByAStarBonus(int[][] matrixMapFirstFloor, int[][] matrixMapSecondFloor) {
ActionsWidget actionsWidget = (ActionsWidget) findGameActor(InTheDarknessGame.ACTIONS_WIDGET);
Player player = (Player) findGameActor(InTheDarknessGame.PLAYER);
AStar aStar = new AStar(matrixMap,matrixMap.length,matrixMap[0].length,startX,startY,finishX,finishY);
AStar aStar = new AStar(matrixMapFirstFloor,matrixMapFirstFloor.length,matrixMapFirstFloor[0].length,startX,startY,stairsFirstFloorX,stairsFirstFloorY);
boolean findKey = false;
if(keyX != -1 && keyY !=-1){
......@@ -264,22 +307,101 @@ public class TestGameInTheDarkness extends AbstractTestGame {
}
if (findKey){
//first path for key
aStar.setEndX(keyX);
aStar.setEndY(keyY);
//first path for key first floor
setEnd(aStar, keyX, keyY);
aStar.resetData();
}
int playerPosition = player.getActualPlayerOrientation().ordinal();
playerPosition = findPathAndSetActions(aStar, actionsWidget, playerPosition);
if (playerPosition == -1){
logError("A star find path failed!");
stopTheTest();
}
if(findKey){
//second path from key to stairs first floor
addActionsByTime(InTheDarknessActionType.KEY,actionsWidget.getAction(),1);
setStartAndEnd(aStar, keyX, keyY, stairsFirstFloorX, stairsFirstFloorY);
findPathAndSetActions(aStar, actionsWidget, playerPosition);
}
addActionsByTime(InTheDarknessActionType.STAIRS,actionsWidget.getAction(),1);
clickAt(incGetSteps() + "Click at second floor button", "2 " + InTheDarknessGame.BOOKMARK_FLOOR_TEXT_KEY);
waitForEvent(incGetSteps() + "Wait for second floor", InTheDarknessGame.EVENT_SHOW_OTHER_FLOOR);
AStar a2Star = new AStar(matrixMapSecondFloor,matrixMapSecondFloor.length,matrixMapSecondFloor[0].length,stairsSecondFloorX,stairsSecondFloorY,finishX,finishY);
playerPosition = stairsRevert;
boolean findFinish = false;
if(finishX != -1 && finishY !=-1){
findFinish = true;
}
if (findFinish){
//path from stairs to finish second floor
setEnd(a2Star, finishX, finishY);
a2Star.resetData();
}
findPathAndSetActions(a2Star, actionsWidget, playerPosition);
clickAt(incGetSteps() + "Click at first floor button", "1 " + InTheDarknessGame.BOOKMARK_FLOOR_TEXT_KEY);
waitForEvent(incGetSteps() + "Wait for first floor", InTheDarknessGame.EVENT_SHOW_OTHER_FLOOR);
}
private int findPathAndSetActions(AStar aStar, ActionsWidget actionsWidget, int playerPosition) {
Stack<Node> path = aStar.findPath();
if (path.isEmpty()){
logError("A star cannot find path");
stopTheTest();
}
int playerPosition = player.getActualPlayerOrientation().ordinal();
//pop start node
path.pop();
playerPosition = setActionByPath(path,actionsWidget,playerPosition);
return setActionByPath(path,actionsWidget,playerPosition);
}
private void setStartAndEnd(AStar aStar, int startX, int startY, int endX, int endY) {
setStart(aStar, startX, startY);
setEnd(aStar, endX, endY);
aStar.resetData();
}
private void setEnd(AStar aStar, int endX, int endY) {
aStar.setEndX(endX);
aStar.setEndY(endY);
}
private void setStart(AStar aStar, int startX, int startY) {
aStar.setStartX(startX);
aStar.setStartY(startY);
}
private void setActionByAStar(int[][] matrixMap){
ActionsWidget actionsWidget = (ActionsWidget) findGameActor(InTheDarknessGame.ACTIONS_WIDGET);
Player player = (Player) findGameActor(InTheDarknessGame.PLAYER);
AStar aStar = new AStar(matrixMap,matrixMap.length,matrixMap[0].length,startX,startY,finishX,finishY);
boolean findKey = false;
if(keyX != -1 && keyY !=-1){
findKey = true;
}
if (findKey){
//first path for key
setEnd(aStar, keyX, keyY);
aStar.resetData();
}
int playerPosition = player.getActualPlayerOrientation().ordinal();
playerPosition = findPathAndSetActions(aStar, actionsWidget, playerPosition);
if (playerPosition == -1){
logError("A start find path failed!");
......@@ -290,22 +412,8 @@ public class TestGameInTheDarkness extends AbstractTestGame {
//second path from key to safe
addActionsByTime(InTheDarknessActionType.KEY,actionsWidget.getAction(),1);
aStar.setStartX(keyX);
aStar.setStartY(keyY);
aStar.setEndX(finishX);
aStar.setEndY(finishY);
aStar.resetData();
path = aStar.findPath();
if (path.isEmpty()){
logError("A star cannot find path");
stopTheTest();
}
//pop start node
path.pop();
setActionByPath(path,actionsWidget,playerPosition);
setStartAndEnd(aStar, keyX, keyY, finishX, finishY);
findPathAndSetActions(aStar, actionsWidget, playerPosition);
}
}
......@@ -388,8 +496,8 @@ public class TestGameInTheDarkness extends AbstractTestGame {
}
private int[][] parseMap(){
MapWidget mapWidget = (MapWidget) findGameActor(InTheDarknessGame.MAP_WIDGET + indexFloor);
private int[][] parseMap(int floor){
MapWidget mapWidget = (MapWidget) findGameActor(InTheDarknessGame.MAP_WIDGET + floor);
Player player = (Player) findGameActor(InTheDarknessGame.PLAYER);
......@@ -419,11 +527,38 @@ public class TestGameInTheDarkness extends AbstractTestGame {
if(placeValue == FINISH.ordinal()){
finishX = xInMatrix;
finishY = yInMatrix;
if(difficulty == GameDifficulty.BONUS && floor!=1){
logError("Test not found finish in second floor");
stopTheTest();
}
}
if(placeValue == KEY.ordinal()){
keyX = xInMatrix;
keyY = yInMatrix;
if(difficulty == GameDifficulty.BONUS && floor!=0){
logError("Test not found key in first floor");
stopTheTest();
}
}
if(placeValue == STAIRS.ordinal() && floor == 0){
stairsFirstFloorX = xInMatrix;
stairsFirstFloorY = yInMatrix;
}
if(placeValue == STAIRS.ordinal() && floor == 1){
stairsSecondFloorX = xInMatrix;
stairsSecondFloorY = yInMatrix;
if (tileType.isLeftDoor()) {
stairsRevert = 3;
} else if (tileType.isTopDoor()) {
stairsRevert = 0;
} else if (tileType.isBottomDoor()) {
stairsRevert = 2;
} else if (tileType.isRightDoor()) {
stairsRevert = 1;
}
}
setDataToMatrixMap(matrixMap,xInMatrix,yInMatrix, tile.getMapObstacles() ,getPlaceValue(tile),tileType.isTopDoor(),tileType.isBottomDoor(),tileType.isLeftDoor(),tileType.isRightDoor());
......@@ -451,6 +586,10 @@ public class TestGameInTheDarkness extends AbstractTestGame {
return FINISH.ordinal();
}
if(tile.getMapObject() != null && tile.getMapObject().getMapObjectType() == MapObjectType.STAIRS){
return STAIRS.ordinal();
}
return GO.ordinal();
}
......
/*
* Copyright (C) 2017 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.testing.games.in_the_darkness;