Commit 3fb22eab authored by Aneta Steimarova's avatar Aneta Steimarova

#941 Refactoring i-test for game In The Darkness

parent e5999e80
TestGameShootingRangeBonusNoneStar
TestGameShootingRangeBonusOneStar
TestGameShootingRangeBonusTwoStar
TestGameShootingRangeBonusThreeStar
TestGameRobberyBonusNoneStar
TestGameRobberyBonusOneStar
TestGameRobberyBonusTwoStars
TestGameRobberyBonusThreeStars
TestGameInTheDarknessEasy
TestGameInTheDarknessMedium
TestGameInTheDarknessHard
......@@ -13,28 +5,4 @@ TestGameInTheDarknessBonus
TestGameInTheDarknessEasyScenario
TestGameInTheDarknessMediumScenario
TestGameInTheDarknessHardScenario
TestGameInTheDarknessBonusScenario
TestGameNightWatchBonusNoneStar
TestGameNightWatchBonusOneStar
TestGameNightWatchBonusTwoStars
TestGameNightWatchBonusThreeStars
TestGamePursuitBonusNoneStar
TestGamePursuitBonusOneStar
TestGamePursuitBonusTwoStars
TestGamePursuitBonusThreeStars
TestGameCrimeSceneBonusNoneStar
TestGameCrimeSceneBonusOneStar
TestGameCrimeSceneBonusTwoStar
TestGameCrimeSceneBonusThreeStar
TestGameKidnappingBonusNoneStar
TestGameKidnappingBonusOneStar
TestGameKidnappingBonusTwoStars
TestGameKidnappingBonusThreeStars
TestGameRunesBonusNoneStar
TestGameRunesBonusOneStar
TestGameRunesBonusTwoStars
TestGameRunesBonusThreeStars
TestGameSafeBonusNoneStars
TestGameSafeBonusOneStars
TestGameSafeBonusTwoStars
TestGameSafeBonusThreeStars
\ No newline at end of file
TestGameInTheDarknessBonusScenario
\ No newline at end of file
......@@ -56,7 +56,6 @@ import cz.nic.tablexia.shared.model.resolvers.InTheDarknessScoreResolver;
import cz.nic.tablexia.testing.games.AbstractTestGame;
import cz.nic.tablexia.testing.games.in_the_darkness.util.AStar;
import cz.nic.tablexia.testing.games.in_the_darkness.util.Node;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.actionwidget.Action;
import cz.nic.tablexia.util.ui.actionwidget.ActionsStripWidget;
......@@ -309,21 +308,12 @@ public class TestGameInTheDarkness extends AbstractTestGame {
if (findKey){
//first path for key first floor
aStar.setEndX(keyX);
aStar.setEndY(keyY);
setEnd(aStar, keyX, keyY);
aStar.resetData();
}
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);
playerPosition = findPathAndSetActions(aStar, actionsWidget, playerPosition);
if (playerPosition == -1){
logError("A star find path failed!");
......@@ -334,22 +324,8 @@ public class TestGameInTheDarkness extends AbstractTestGame {
//second path from key to stairs first floor
addActionsByTime(InTheDarknessActionType.KEY,actionsWidget.getAction(),1);
aStar.setStartX(keyX);
aStar.setStartY(keyY);
aStar.setEndX(stairsFirstFloorX);
aStar.setEndY(stairsFirstFloorY);
aStar.resetData();
path = aStar.findPath();
if (path.isEmpty()){
logError("A star cannot find path");
stopTheTest();
}
//pop start node
path.pop();
playerPosition = setActionByPath(path,actionsWidget,playerPosition);
setStartAndEnd(aStar, keyX, keyY, stairsFirstFloorX, stairsFirstFloorY);
findPathAndSetActions(aStar, actionsWidget, playerPosition);
}
addActionsByTime(InTheDarknessActionType.STAIRS,actionsWidget.getAction(),1);
......@@ -367,23 +343,43 @@ public class TestGameInTheDarkness extends AbstractTestGame {
if (findFinish){
//path from stairs to finish second floor
a2Star.setEndX(finishX);
a2Star.setEndY(finishY);
setEnd(a2Star, finishX, finishY);
a2Star.resetData();
}
path = a2Star.findPath();
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();
}
//pop start node
path.pop();
setActionByPath(path,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);
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){
......@@ -400,21 +396,12 @@ public class TestGameInTheDarkness extends AbstractTestGame {
if (findKey){
//first path for key
aStar.setEndX(keyX);
aStar.setEndY(keyY);
setEnd(aStar, keyX, keyY);
aStar.resetData();
}
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);
playerPosition = findPathAndSetActions(aStar, actionsWidget, playerPosition);
if (playerPosition == -1){
logError("A start find path failed!");
......@@ -425,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);
}
}
......
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