java.lang.Object
org.zazof.jteg.JTEGStateMachine
- public class JTEGStateMachine
- extends java.lang.Object
This class encapsulates the current state of the JTEGClient
It implements Model-View-Controller.
Classes can subscribe to the JTEGStateMachine,
and they will be notified of changes in the state of the client.
JTEGStateMachine implements the Singleton Pattern
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
$transitionMatrix
private boolean[][] $transitionMatrix
$listeners
private java.util.Vector $listeners
$currentState
private static int $currentState
$instance
private static JTEGStateMachine $instance
DISCONNECTED
public static final int DISCONNECTED
- See Also:
- Constant Field Values
CONNECTING
public static final int CONNECTING
- See Also:
- Constant Field Values
CHOOSING_COLORS
public static final int CHOOSING_COLORS
- See Also:
- Constant Field Values
CONNECTED
public static final int CONNECTED
- See Also:
- Constant Field Values
OBSERVING
public static final int OBSERVING
- See Also:
- Constant Field Values
GAME_STARTED
public static final int GAME_STARTED
- See Also:
- Constant Field Values
EXCHANGING_CARDS
public static final int EXCHANGING_CARDS
- See Also:
- Constant Field Values
PLACING_ARMIES
public static final int PLACING_ARMIES
- See Also:
- Constant Field Values
ARMIES_PLACED
public static final int ARMIES_PLACED
- See Also:
- Constant Field Values
ATTACKING
public static final int ATTACKING
- See Also:
- Constant Field Values
MOVING_AFTER_ATTACK
public static final int MOVING_AFTER_ATTACK
- See Also:
- Constant Field Values
REGROUPING_ARMIES
public static final int REGROUPING_ARMIES
- See Also:
- Constant Field Values
ARMIES_REGROUPED
public static final int ARMIES_REGROUPED
- See Also:
- Constant Field Values
GETTING_CARD
public static final int GETTING_CARD
- See Also:
- Constant Field Values
WAITING_FOR_OTHER_PLAYERS
public static final int WAITING_FOR_OTHER_PLAYERS
- See Also:
- Constant Field Values
NB_OF_STATES
static final int NB_OF_STATES
- See Also:
- Constant Field Values
DEBUG
static final boolean DEBUG
- See Also:
- Constant Field Values
JTEGStateMachine
private JTEGStateMachine()
getInstance
public static JTEGStateMachine getInstance()
- Returns a reference to the StateMachine
(Implementation of the Singleton Pattern)
getCurrentState
public int getCurrentState()
- Returns the current state
setCurrentState
public void setCurrentState(int newState)
throws java.lang.IllegalStateException
- Sets the current state
subscribe
public void subscribe(StateListener newListener)
- Adds a listener to the listenerlist.
unsubscribe
public void unsubscribe(StateListener listenerToBeRemoved)
- Removes a listener from the listenerlist.
notifyListeners
private void notifyListeners()
matrixInit
private void matrixInit()
possibleTransition
private boolean possibleTransition(int sourceState,
int destinationState)