Commit f4a43980 authored by Aneta Steimarova's avatar Aneta Steimarova

#929 Removed static wait from test game rune

parent 0f400511
......@@ -69,7 +69,7 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
public static final String RUNES_GROUP = "runes group";
public static final String HEALTH_BAR = "health bar";
public static final String EVENT_NEXT_ROUND = "next round";
public static final String EVENT_ROUND_READY = "round ready";
private static final int ONE_SECOND_DELAY = 1;
private static final int START_SOUND_BOUND = 8;
......@@ -295,7 +295,12 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
private void nextRound() {
runesGroup.addAction(Actions.fadeIn(FADE_ANIMATION_DURATION));
runesGroup.addAction(Actions.sequence(Actions.fadeIn(FADE_ANIMATION_DURATION), Actions.run(new Runnable() {
@Override
public void run() {
triggerScenarioStepEvent(EVENT_ROUND_READY);
}
})));
getData().setPhase(RunesGameState.RunesGamePhase.GAME);
timeBar.startGameState();
targetPlate.changeTargets(getData().getRound());
......@@ -304,8 +309,6 @@ public class RunesGame extends AbstractTablexiaGame<RunesGameState> {
holderManager.clearHolders();
runesGroup.clearChildren();
initHolders();
testCountRound++;
triggerScenarioStepEvent(EVENT_NEXT_ROUND+testCountRound);
}
/**
......
......@@ -28,6 +28,7 @@ public interface IRune {
Color DEFAULT_COLOR = Color.BLACK;
float CORRECT_ANIMATION_DURATION = 0.5f;
float WRONG_ANIMATION_DURATION = 0.3f;
String EVENT_ANIMATE_RUNE_DONE = "animation of rune done";
enum AnimationType{
CORRECT(Color.GREEN, CORRECT_ANIMATION_DURATION),
......
......@@ -24,6 +24,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.games.runes.assets.RuneDefinition;
import cz.nic.tablexia.game.games.runes.helper.RuneDescription;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
/**
* Created by Vitaliy Vashchenko on 8.4.16.
......@@ -57,7 +58,12 @@ public class Rune extends Image implements IRune {
public void showAnimation(AnimationType animationType) {
if (!hasActions()) {
addAction(Actions.sequence(Actions.color(animationType.getColor(), animationType.getDuration()), Actions.color(DEFAULT_COLOR, animationType.getDuration())));
addAction(Actions.after(Actions.color(DEFAULT_COLOR)));
addAction(Actions.after(Actions.sequence(Actions.color(DEFAULT_COLOR), Actions.run(new Runnable() {
@Override
public void run() {
AbstractTablexiaScreen.triggerScenarioStepEvent(EVENT_ANIMATE_RUNE_DONE);
}
}))));
}
}
......
......@@ -26,6 +26,7 @@ import cz.nic.tablexia.game.common.TablexiaRandom;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.games.runes.assets.RuneDefinition;
import cz.nic.tablexia.game.games.runes.helper.RuneDescription;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
/**
* Created by Vitaliy Vashchenko on 27.4.16.
......@@ -103,7 +104,12 @@ public class RunesCluster extends Group implements IRune{
private void animateRune(Rune rune, AnimationType animationType) {
if (!rune.hasActions()) {
rune.addAction(Actions.sequence(Actions.color(animationType.getColor()), Actions.color(DEFAULT_COLOR, animationType.getDuration())));
rune.addAction(Actions.after(Actions.color(DEFAULT_COLOR)));
rune.addAction(Actions.after(Actions.sequence(Actions.color(DEFAULT_COLOR), Actions.run(new Runnable() {
@Override
public void run() {
AbstractTablexiaScreen.triggerScenarioStepEvent(EVENT_ANIMATE_RUNE_DONE);
}
}))));
}
}
......
......@@ -33,6 +33,7 @@ import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.runes.RunesGame;
import cz.nic.tablexia.game.common.ui.health_bar.HealthBar;
import cz.nic.tablexia.game.games.runes.actors.IRune;
import cz.nic.tablexia.game.games.runes.actors.Rune;
import cz.nic.tablexia.game.games.runes.actors.RunesCluster;
import cz.nic.tablexia.game.games.runes.actors.RunesHolder;
......@@ -131,17 +132,16 @@ public class TestGameRunes extends AbstractTestGame {
int mistakesCounter = 0;
while (round < RunesGameProperties.GAME_ROUNDS){
if(round > 0) waitForEvent(incGetSteps() + ". Wait for event round ready", RunesGame.EVENT_ROUND_READY);
round++;
boolean mistakeInRound = playRound(targetPlate,runes);
if(mistakeInRound==true) mistakesCounter++;
if(!healthBar.hasHealthsLeft() || mistakesCounter >= 3){
if(!healthBar.hasHealthsLeft() || mistakesCounter >= 3 || round >= RunesGameProperties.GAME_ROUNDS){
break;
}
if(round != RunesGameProperties.GAME_ROUNDS)
waitForEvent(incGetSteps() + ". Wait for event next round", RunesGame.EVENT_NEXT_ROUND+round);
}
}
......@@ -169,7 +169,6 @@ public class TestGameRunes extends AbstractTestGame {
//Click on holder
if(TablexiaSettings.getInstance().isRunningOnMobileDevice()) clickOnHolder(incGetSteps() + ". Click on holder with target: " + targetRune,holderWithTarget);
wait(WAIT_TIME);
//Click on rune
if(doMistake()){
clickOnRune(incGetSteps() + ". Click on wrong rune: ", findWrongRune(targetRune,holderWithTarget));
......@@ -179,6 +178,7 @@ public class TestGameRunes extends AbstractTestGame {
gameScore++;
}
if (i < (size-1)) waitForEvent(incGetSteps() + ". Wait for event correct/wrong rune", IRune.EVENT_ANIMATE_RUNE_DONE);
}
......
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