From e416d44400f0bb22e61ad48ee2d7d71f3a28f807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Fri, 22 Jun 2012 01:31:41 +0200 Subject: [PATCH] added extra state to table game --- src/de/ctdo/crashtest/game/Statemachine.java | 34 ++++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/de/ctdo/crashtest/game/Statemachine.java b/src/de/ctdo/crashtest/game/Statemachine.java index a51d3a9..04a2076 100644 --- a/src/de/ctdo/crashtest/game/Statemachine.java +++ b/src/de/ctdo/crashtest/game/Statemachine.java @@ -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 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;