Commit cb6c0d84 authored by Lukas Marik's avatar Lukas Marik

#945 bonus protocol itest, repair put on wall and furniture, descriptor repair

parent 420247c7
......@@ -30,9 +30,9 @@ public enum WallObjectDescriptor {
LANDSCAPE (GameObjectType.LANDSCAPE, WallType.RIGHT_WALL, new EdgePoints(new float[]{0.09f, 0.93f}, new float[]{0.08f, 0.38f}, new float[]{0.9f, 0.62f}, new float[]{0.9f, 0.05f}), Arrays.asList( new float[]{0.08f, 0.66f}, new float[]{0.57f, 0.87f}, new float[]{0.92f, 0.65f})),
MIRROR (GameObjectType.MIRROR, WallType.RIGHT_WALL, new EdgePoints(new float[]{0.2f, 0.97f}, new float[]{0.07f, 0.18f}, new float[]{0.91f, 0.82f}, new float[]{0.74f, 0.03f}), Arrays.asList( new float[]{0.08f, 0.52f}, new float[]{0.5f, 0.78f}, new float[]{0.92f, 0.52f})),
//BONUS
KABUKI (GameObjectType.KABUKI, WallType.LEFT_WALL, new EdgePoints(new float[]{0.07f, 0.9f}, new float[]{0.1f, -0.13f}, new float[]{0.9f, 1.07f}, new float[]{0.93f, 0.13f}), Arrays.asList( new float[]{0.04f, 0.75f}, new float[]{0.6f, 0.78f}, new float[]{0.83f, 0.74f})),
MASK_AFRICA (GameObjectType.MASK_AFRICA, WallType.RIGHT_WALL, new EdgePoints(new float[]{0.1f, 1.04f}, new float[]{0.07f, 0.12f}, new float[]{0.95f, 0.9f}, new float[]{0.74f, -0.02f}), Arrays.asList( new float[]{0.04f, 0.75f}, new float[]{0.4f, 0.78f}, new float[]{0.83f, 0.74f})),
TRAVEL_HAT (GameObjectType.TRAVEL_HAT, WallType.LEFT_WALL, new EdgePoints(new float[]{0.1f, 0.88f}, new float[]{0.1f, -0.1f}, new float[]{0.87f, 1.1f}, new float[]{0.87f, 0.15f}), Arrays.asList( new float[]{0.04f, 0.75f}, new float[]{0.5f, 0.9f}, new float[]{0.83f, 0.74f}));
KABUKI (GameObjectType.KABUKI, WallType.LEFT_WALL, new EdgePoints(new float[]{0.07f, 0.9f}, new float[]{0.1f, -0.13f}, new float[]{0.9f, 1.07f}, new float[]{0.93f, 0.13f}), Arrays.asList( new float[]{0.07f, 0.66f}, new float[]{0.6f, 0.78f}, new float[]{0.83f, 0.74f})),
MASK_AFRICA (GameObjectType.MASK_AFRICA, WallType.RIGHT_WALL, new EdgePoints(new float[]{0.1f, 1.04f}, new float[]{0.07f, 0.12f}, new float[]{0.95f, 0.9f}, new float[]{0.74f, -0.02f}), Arrays.asList( new float[]{0.07f, 0.66f}, new float[]{0.4f, 0.78f}, new float[]{0.83f, 0.74f})),
TRAVEL_HAT (GameObjectType.TRAVEL_HAT, WallType.LEFT_WALL, new EdgePoints(new float[]{0.1f, 0.88f}, new float[]{0.1f, -0.1f}, new float[]{0.87f, 1.1f}, new float[]{0.87f, 0.15f}), Arrays.asList( new float[]{0.07f, 0.66f}, new float[]{0.5f, 0.9f}, new float[]{0.83f, 0.74f}));
private GameObjectType objectType;
......
......@@ -204,7 +204,7 @@ public abstract class ProtocolGenerator {
TEXT_4_4(3, Arrays.asList(
new SentenceDescriptor(Sentence.S1_FW_S_2, new Integer[]{0, 0, 0}),
new SentenceDescriptor(Sentence.A1_FW_S_1, new Integer[]{1, 1, 1}),
new SentenceDescriptor(Sentence.A1_FW_S_1, new Integer[]{1, 1, 1}),
new SentenceDescriptor(Sentence.A2_FW_C_1, new Integer[]{2, 2, 2, 3, 3}),
new SentenceDescriptor(Sentence.A2_FW_C_1_A, new Integer[]{2, 2, 3, 2})
)),
TEXT_5_1(2, Arrays.asList(
......
......@@ -6,4 +6,7 @@ TestGameProtocolMediumTwoStar
TestGameProtocolMediumThreeStar
TestGameProtocolHardOneStar
TestGameProtocolHardTwoStar
TestGameProtocolHardThreeStar
\ No newline at end of file
TestGameProtocolHardThreeStar
TestGameProtocolBonusOneStar
TestGameProtocolBonusTwoStar
TestGameProtocolBonusThreeStar
\ No newline at end of file
This diff is collapsed.
......@@ -83,6 +83,10 @@ import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchMediumNoneSta
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchMediumOneStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchMediumThreeStar;
import cz.nic.tablexia.testing.games.night_watch.TestGameNightWatchMediumTwoStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolBonusNoneStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolBonusOneStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolBonusThreeStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolBonusTwoStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolEasyNoneStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolEasyOneStar;
import cz.nic.tablexia.testing.games.protocol.TestGameProtocolEasyThreeStar;
......@@ -337,6 +341,10 @@ public class TestRunner {
listOfTests.add(TestGameProtocolHardOneStar.class);
listOfTests.add(TestGameProtocolHardTwoStar.class);
listOfTests.add(TestGameProtocolHardThreeStar.class);
listOfTests.add(TestGameProtocolBonusNoneStar.class);
listOfTests.add(TestGameProtocolBonusOneStar.class);
listOfTests.add(TestGameProtocolBonusTwoStar.class);
listOfTests.add(TestGameProtocolBonusThreeStar.class);
listOfTests.add(TestGameSafeEasyNoneStars.class);
listOfTests.add(TestGameSafeEasyOneStars.class);
listOfTests.add(TestGameSafeEasyTwoStars.class);
......
......@@ -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.protocol.ProtocolGame;
import cz.nic.tablexia.game.games.protocol.controller.ObjectsController;
import cz.nic.tablexia.game.games.protocol.controller.PositionCounter;
......@@ -94,6 +95,10 @@ public class TestGameProtocol extends AbstractTestGame {
User user = createUser();
logIn(user);
if(difficulty == GameDifficulty.BONUS){
setDataForUnlockBonus(user, GameDefinition.PROTOCOL);
}
waitForEvent(incGetSteps() + ". Wait for event opened ready", AbstractMenu.SCENARIO_STEP_READY_MENU);
clickAt(incGetSteps() + ". Click at open/close menu button", AbstractMenu.OPEN_CLOSE_MENU_BUTTON_NAME);
......@@ -177,7 +182,6 @@ public class TestGameProtocol extends AbstractTestGame {
}
private void playRound() {
recountCorrectObjects();
takeScreenShot();
ProtocolGenerator generator = gameState.getProtocolGenerator();
......@@ -218,14 +222,6 @@ public class TestGameProtocol extends AbstractTestGame {
}
private void recountCorrectObjects() {
Game game = loadGameFromDao(1);
int actualGameScore = Integer.valueOf(game.getGameScore(ProtocolScoreResolver.SCORE_COUNT, "0"));
logInfo("Default correct item position/undefined item position: game score = " + gameScore + " changed to actual score = " + actualGameScore);
if(gameScore!=actualGameScore) gameScore = actualGameScore;
}
/////////////////////////////// ROOM ACTION
/**
......@@ -277,7 +273,7 @@ public class TestGameProtocol extends AbstractTestGame {
}
private void moveObjectToFurniture(GameObject gameObject, FurnitureType furnitureType) {
if (doCorrect()) {
if (doCorrect(gameObject.getType())) {
correct();
} else {
furnitureType = getDifferentFurniture(furnitureType);
......@@ -289,15 +285,15 @@ public class TestGameProtocol extends AbstractTestGame {
Vector2 furniturePosition = getActorPosition(furniture, ActorPosition.BOTTOM_LEFT);
float xPosition = furniturePosition.x + (furniture.getFurnitureImage().getWidth() * fixRatio[0])/* - gameObject.getCenterPosition().x*/;
float yPosition = furniturePosition.y + (furniture.getFurnitureImage().getHeight() * fixRatio[1])/* - gameObject.getCenterPosition().y*/;
float xPosition = furniturePosition.x + (furniture.getFurnitureImage().getWidth() * fixRatio[0]);
float yPosition = furniturePosition.y + (furniture.getFurnitureImage().getHeight() * fixRatio[1]);
logInfo(incGetSteps() + ". Move object [" + gameObject.getType() + "] on the furniture [" + furnitureType + "]");
moveGameObjectToFurniturePosition(gameObject, xPosition, yPosition);
}
private void moveObjectToWall(GameObject gameObject, WallType wallType) {
if (doCorrect()) {
if (doCorrect(gameObject.getType())) {
correct();
} else {
wallType = getDifferentWallType(wallType);
......@@ -306,9 +302,11 @@ public class TestGameProtocol extends AbstractTestGame {
WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(gameObject.getType());
float[] fixRatio = descriptor.getFixRatio(wallType);
Vector2 roomPosition = getActorPosition(roomGroup, ActorPosition.BOTTOM_LEFT);
float xPosition = roomPosition.x + roomGroup.getWidth() * fixRatio[0];
float yPosition = roomPosition.y + roomGroup.getHeight() * fixRatio[1];
float xPosition = roomGroup.getX() + roomGroup.getWidth() * fixRatio[0]/* - gameObject.getCenterPosition().x*/;
float yPosition = roomGroup.getY() + roomGroup.getHeight() * fixRatio[1]/* - gameObject.getCenterPosition().y*/;
logInfo(incGetSteps() + ". Move object [" + gameObject.getType() + "] on the wall [" + wallType + "]");
moveGameObjectToWallPosition(gameObject, xPosition, yPosition);
......@@ -330,7 +328,7 @@ public class TestGameProtocol extends AbstractTestGame {
GameObjectType objectType = (GameObjectType) positionPair.getObjectType();
GameObject gameObject = findGameObjectInMenu(objectType);
boolean needCorrect = doCorrect();
boolean needCorrect = doCorrect(objectType);
//Set move preposition
Preposition preposition;
......@@ -371,7 +369,7 @@ public class TestGameProtocol extends AbstractTestGame {
GameObject gameObject = findGameObjectInMenu(objectType);
boolean needCorrect = doCorrect();
boolean needCorrect = doCorrect(objectType);
//Set move preposition
Preposition preposition;
......@@ -487,8 +485,18 @@ public class TestGameProtocol extends AbstractTestGame {
final float duration = 0.5f;
Vector2 objectPosition = getActorPosition(object, ActorPosition.BOTTOM_LEFT);
float xPosition = objectPosition.x + ProtocolGame.CARD_SMALL_SIZE / 2;
float yPosition = objectPosition.y + 2*ProtocolGame.CARD_SMALL_SIZE / 3;
Vector2 wallPoint = object.getWallPoint();
if(wallPoint == null){
logError("Object " + object.getType() + " do not have wall point for move to wall");
stopTheTest();
return;
}
float xPosition = objectPosition.x + wallPoint.x;
float yPosition = objectPosition.y + wallPoint.y;
xFinish -= ProtocolGame.CARD_SMALL_SIZE / 2 - object.getImageWidth() / 2;
yFinish -= ProtocolGame.CARD_SMALL_SIZE / 3;
Stage stage = object.getStage();
clickAt((int)xFinish, (int)yFinish, stage);
......@@ -513,9 +521,18 @@ public class TestGameProtocol extends AbstractTestGame {
final float duration = 0.5f;
Vector2 objectPosition = getActorPosition(object, ActorPosition.BOTTOM_LEFT);
Vector2 putPoint = object.getPutPoint();
if(putPoint == null){
logError("Object " + object.getType() + " do not have put point for move to furniture");
stopTheTest();
return;
}
float xPosition = objectPosition.x + putPoint.x;
float yPosition = objectPosition.y + putPoint.y;
float xPosition = objectPosition.x + ProtocolGame.CARD_SMALL_SIZE / 2 - 5;
float yPosition = objectPosition.y + ProtocolGame.CARD_SMALL_SIZE / 2 - 7;
xFinish -= ProtocolGame.CARD_SMALL_SIZE / 2 - object.getImageWidth() / 2;
yFinish -= ProtocolGame.CARD_SMALL_SIZE / 3;
Stage stage = object.getStage();
clickAt((int)xFinish, (int)yFinish, stage);
......@@ -616,18 +633,27 @@ public class TestGameProtocol extends AbstractTestGame {
objectsCnt++;
}
private boolean doCorrect() {
private boolean doCorrect(GameObjectType objectType) {
if(!canMistake(objectType))
return true;
int sumObjectsCnt = LevelDefinition.DifficultyDefinition.getDefinitionByDifficulty(difficulty).getSumObjectCount();
int[] scoreResult = ProtocolScoreResolver.ResultStars.values()[difficulty.ordinal() - 1].getScoreResult();
if (expectedResult == AbstractTablexiaGame.GameResult.TWO_STAR && objectsCnt >= (sumObjectsCnt - scoreResult[1]+ gameScore))
int remainingObjects = sumObjectsCnt - objectsCnt;
if (expectedResult == AbstractTablexiaGame.GameResult.TWO_STAR && (objectsCnt >= (sumObjectsCnt - scoreResult[1]+ gameScore) || (remainingObjects <= scoreResult[1] && mistakeCnt < scoreResult[1])))
return true;
else if (expectedResult == AbstractTablexiaGame.GameResult.ONE_STAR && objectsCnt >= (sumObjectsCnt - scoreResult[0]+ gameScore))
else if (expectedResult == AbstractTablexiaGame.GameResult.ONE_STAR && (objectsCnt >= (sumObjectsCnt - scoreResult[0]+ gameScore)|| (remainingObjects <= scoreResult[0] && mistakeCnt < scoreResult[0])))
return true;
else if (expectedResult == AbstractTablexiaGame.GameResult.THREE_STAR) return true;
return false;
}
private boolean canMistake(GameObjectType objectType){
Map<GameObjectType, List<PositionPair>> solution = gameState.getProtocolGenerator().getController().getSolution();
return !(solution.containsKey(objectType) && solution.get(objectType).isEmpty());
}
private WallType getDifferentWallType(WallType wallType) {
for (WallType different : WallType.values()) {
if (different != wallType)
......@@ -734,7 +760,7 @@ public class TestGameProtocol extends AbstractTestGame {
@Override
protected void testVictoryData() {
Game game = loadGameFromDao(1);
Game game = loadGameFromDao(getGameID());
int daoScore = Integer.valueOf(game.getGameScore(ProtocolScoreResolver.SCORE_COUNT, "0"));
checkVictoryDialog(incGetSteps() + ". Check victory dialog", AbstractTablexiaGame.VICTORY_DIALOG, GameDefinition.PROTOCOL, game, daoScore);
......
/*
* Copyright (C) 2018 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.protocol;
public class TestGameProtocolBonusNoneStar {
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
public class TestGameProtocolBonusNoneStar extends TestGameProtocol {
public TestGameProtocolBonusNoneStar(Tablexia tablexia) {
super(tablexia);
difficulty = GameDifficulty.BONUS;
expectedResult = AbstractTablexiaGame.GameResult.NO_STAR;
}
}
/*
* Copyright (C) 2018 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.protocol;
public class TestGameProtocolBonusOneStar {
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
public class TestGameProtocolBonusOneStar extends TestGameProtocol {
public TestGameProtocolBonusOneStar(Tablexia tablexia) {
super(tablexia);
difficulty = GameDifficulty.BONUS;
expectedResult = AbstractTablexiaGame.GameResult.ONE_STAR;
}
}
/*
* Copyright (C) 2018 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.protocol;
public class TestGameProtocolBonusThreeStar {
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
public class TestGameProtocolBonusThreeStar extends TestGameProtocol {
public TestGameProtocolBonusThreeStar(Tablexia tablexia) {
super(tablexia);
difficulty = GameDifficulty.BONUS;
expectedResult = AbstractTablexiaGame.GameResult.THREE_STAR;
}
}
/*
* Copyright (C) 2018 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.protocol;
public class TestGameProtocolBonusTwoStar {
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
public class TestGameProtocolBonusTwoStar extends TestGameProtocol {
public TestGameProtocolBonusTwoStar(Tablexia tablexia) {
super(tablexia);
difficulty = GameDifficulty.BONUS;
expectedResult = AbstractTablexiaGame.GameResult.TWO_STAR;
}
}
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