added extra state to table game

This commit is contained in:
Lucas Pleß 2012-06-22 01:31:41 +02:00
parent e95ea0359f
commit e416d44400
1 changed files with 20 additions and 14 deletions

View File

@ -1,7 +1,5 @@
package de.ctdo.crashtest.game;
import de.ctdo.crashtest.log.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
@ -18,17 +16,18 @@ public class Statemachine implements IStatemachine {
TABLE_GAME_FIVE,
TABLE_GAME_SIX,
TABLE_GAME_DONE,
TABLE_GAME_WRONG,
ROKET_STARTED,
ROKET_DONE,
NEUTRAL
}
private final char BLUE_BUTTON = 'E';
private final char LIGHT_BARRIER = 'F';
private final char TABLE_ONE = 'G';
private final char TABLE_TWO = 'H';
private final char TABLE_THREE = 'I';
private final char ROKET_INPUT = 'B';
public static final char BLUE_BUTTON = 'E';
public static final char LIGHT_BARRIER = 'F';
public static final char TABLE_ONE = 'G';
public static final char TABLE_TWO = 'H';
public static final char TABLE_THREE = 'I';
public static final char ROKET_INPUT = 'B';
private final List<StatemachineListener> statemachineListenerList;
private Timer timer;
@ -53,7 +52,7 @@ public class Statemachine implements IStatemachine {
public state getCurrentState() {
return currentState;
}
@Override
public void setNewState(state newState) {
currentState = newState;
@ -160,41 +159,43 @@ public class Statemachine implements IStatemachine {
case TABLE_GAME_ONE:
if(input == TABLE_TWO) {
retVal = state.TABLE_GAME_TWO;
} else if (input == TABLE_THREE) {
retVal = state.TABLE_GAME_WRONG;
}
break;
case TABLE_GAME_TWO:
if(input == TABLE_THREE) {
retVal = state.TABLE_GAME_THREE;
} else if (input == TABLE_ONE) {
retVal = state.TABLE_GAME_ONE;
retVal = state.TABLE_GAME_WRONG;
}
break;
case TABLE_GAME_THREE:
if(input == TABLE_TWO) {
retVal = state.TABLE_GAME_FOUR;
} else if (input == TABLE_ONE) {
retVal = state.TABLE_GAME_ONE;
retVal = state.TABLE_GAME_WRONG;
}
break;
case TABLE_GAME_FOUR:
if(input == TABLE_THREE) {
retVal = state.TABLE_GAME_FIVE;
} else if (input == TABLE_ONE) {
retVal = state.TABLE_GAME_ONE;
retVal = state.TABLE_GAME_WRONG;
}
break;
case TABLE_GAME_FIVE:
if(input == TABLE_ONE) {
retVal = state.TABLE_GAME_SIX;
} else if (input == TABLE_TWO) {
retVal = state.TABLE_GAME_ONE;
retVal = state.TABLE_GAME_WRONG;
}
break;
case TABLE_GAME_SIX:
if(input == TABLE_THREE) {
retVal = state.TABLE_GAME_DONE;
} else if (input == TABLE_TWO) {
retVal = state.TABLE_GAME_ONE;
retVal = state.TABLE_GAME_WRONG;
}
break;
case TABLE_GAME_DONE:
@ -202,6 +203,11 @@ public class Statemachine implements IStatemachine {
retVal = state.ROKET_STARTED;
}
break;
case TABLE_GAME_WRONG:
if(input == TABLE_ONE) {
retVal = state.TABLE_GAME_ONE;
}
break;
case ROKET_STARTED:
if(input == ROKET_INPUT) {
retVal = state.ROKET_DONE;