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