de.limdul.cassiopeia.control.servermodus
Class ServerModus

java.lang.Object
  extended by de.limdul.cassiopeia.control.servermodus.ServerModus
All Implemented Interfaces:
CassiopeiaListener, GameCommandListener, TCPCommandListener
Direct Known Subclasses:
ServerConnecting, ServerDragonUpdatePoints, ServerEnchantedTunnel, ServerEndGame, ServerGameInfo, ServerLobby, ServerMoveDragon, ServerPlaceDragon, ServerPlaceFairy, ServerPlaceRiver2Crossing, ServerPlayCard, ServerPlayCastleMiss, ServerPlayFigure, ServerPlayKatharer, ServerSelectMoveDragon, ServerSelectPlaceDragon, ServerStartGame, ServerUpdatePoints

public abstract class ServerModus
extends Object
implements TCPCommandListener, GameCommandListener

Oberklasse für alle Servermodi. Stellt Grundlegende Methoden zur Behandlung zur Verfügung.

Version:
$Revision: 69 $
Author:
Martin Köhler

Field Summary
static int CONNECTING
           
static int END_GAME
           
static int GAME_CASTLE_MISS
           
static int GAME_DRAGON_UPDATE_POINTS
           
static int GAME_ENCHANTED_TUNNEL
           
static int GAME_INFO
           
static int GAME_MOVE_DRAGON
           
static int GAME_PLACE_DRAGON
           
static int GAME_PLACE_FAIRY
           
static int GAME_PLACE_RIVER_2_CROSSING
           
static int GAME_PLAY_CARD
           
static int GAME_PLAY_FIGURE
           
static int GAME_PLAY_KATHARER
           
static int GAME_SELECT_MOVE_DRAGON
           
static int GAME_SELECT_PLACE_DRAGON
           
static int GAME_UPDATE_POINTS
           
static int LOBBY
           
static int START_GAME
           
static int UNKNOWN_MODUS
          Gibt an, dass die Spiellogik den Modus entscheidet.
 
Constructor Summary
ServerModus(EventHandler handler)
          Erzeugt einen Servermodus.
 
Method Summary
 void addClient(String client)
          Fügt einen Client zur Liste der betroffenen Clients hinzu.
protected  void addExpectedTCP(int command)
          Fügt einen BEfehl zur Liste der erwarteten TCP Befehle hinzu.
protected  void addToReplay(TCPCommand command)
          Fügt einen Befehl zum Replay hinzu.
protected  void clearExpectedTCP()
          Löscht die Liste der erwarten TCP Befehle.
protected  void createModus(int newModus)
          Erzeugt einen neuen Servermodus.
protected  EventHandler getEventHandler()
          Liefert den Eventhandler.
protected  CassiopeiaGame getGame()
          Liefert das Spiel.
protected  GameLogic getGameLogic()
          Liefert das Spiellogik Objekt.
abstract  int getType()
          Liefert den Typ des Modus.
protected  void initialize()
          Wird aufgerufen, nachdem das Objekt erfolgreich erzeugt wurde.
protected  boolean isLocalGame()
          Liefert zurück, ob es sich um ein lokales Spiel handelt.
protected  void parseChatMessage(TCPChatMessage command)
          Verarbeitet eine Chatnachricht.
 void parseGameCommand(GameCommand command)
          Verarbeitet ein GameCommand.
 void removeClient(String client)
          Entfernt einen Client vone der Liste der betroffenen Clients.
protected  void sendCommand(TCPCommand command)
          Sendet den Befehl nur an die Clients, die von diesem Modus betroffen sind.
protected  void sendCommand(TCPCommand command, boolean save)
          Sendet den Befehl nur an die Clients, die von diesem Modus betroffen sind.
protected  void sendGameOptions()
          Sendet die Spieloptionen.
 void setConnection(ConnectionWaiting conWait)
          Setzt das ConnectioNWaiting Objekt.
 void setEventHandler(EventHandler handler)
          Setzt den Ereignisshandler, der für die Verteilung von Ereignissen zuständig ist.
protected  void setGameLogic(GameLogic logic)
          Setzt das Spiellogik Objekt.
 void shutdown()
          Beendet den Server.
protected  boolean testTCPCommand(TCPCommand command)
          Testet, ob das TCPCommand verarbeitet werden soll.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.limdul.cassiopeia.control.TCPCommandListener
parseTCPCommand
 

Field Detail

UNKNOWN_MODUS

public static final int UNKNOWN_MODUS
Gibt an, dass die Spiellogik den Modus entscheidet.

See Also:
Constant Field Values

CONNECTING

public static final int CONNECTING
See Also:
ServerConnecting, Constant Field Values

LOBBY

public static final int LOBBY
See Also:
ServerLobby, Constant Field Values

GAME_PLAY_CARD

public static final int GAME_PLAY_CARD
See Also:
ServerPlayCard, Constant Field Values

START_GAME

public static final int START_GAME
See Also:
ServerStartGame, Constant Field Values

GAME_PLAY_FIGURE

public static final int GAME_PLAY_FIGURE
See Also:
ServerPlayFigure, Constant Field Values

GAME_UPDATE_POINTS

public static final int GAME_UPDATE_POINTS
See Also:
ServerUpdatePoints, Constant Field Values

GAME_ENCHANTED_TUNNEL

public static final int GAME_ENCHANTED_TUNNEL
See Also:
ServerEnchantedTunnel, Constant Field Values

GAME_CASTLE_MISS

public static final int GAME_CASTLE_MISS
See Also:
ServerPlayCastleMiss, Constant Field Values

GAME_PLACE_FAIRY

public static final int GAME_PLACE_FAIRY
See Also:
ServerPlaceFairy, Constant Field Values

END_GAME

public static final int END_GAME
See Also:
ServerEndGame, Constant Field Values

GAME_PLACE_DRAGON

public static final int GAME_PLACE_DRAGON
See Also:
ServerPlaceDragon, Constant Field Values

GAME_SELECT_PLACE_DRAGON

public static final int GAME_SELECT_PLACE_DRAGON
See Also:
ServerSelectPlaceDragon, Constant Field Values

GAME_SELECT_MOVE_DRAGON

public static final int GAME_SELECT_MOVE_DRAGON
See Also:
ServerSelectMoveDragon, Constant Field Values

GAME_MOVE_DRAGON

public static final int GAME_MOVE_DRAGON
See Also:
ServerMoveDragon, Constant Field Values

GAME_DRAGON_UPDATE_POINTS

public static final int GAME_DRAGON_UPDATE_POINTS
See Also:
ServerDragonUpdatePoints, Constant Field Values

GAME_PLAY_KATHARER

public static final int GAME_PLAY_KATHARER
See Also:
ServerPlayFigure, Constant Field Values

GAME_PLACE_RIVER_2_CROSSING

public static final int GAME_PLACE_RIVER_2_CROSSING
See Also:
ServerPlaceRiver2Crossing, Constant Field Values

GAME_INFO

public static final int GAME_INFO
See Also:
ServerGameInfo, Constant Field Values
Constructor Detail

ServerModus

public ServerModus(EventHandler handler)
Erzeugt einen Servermodus.

Parameters:
handler - Der Ereignisshandler.
Method Detail

getType

public abstract int getType()
Liefert den Typ des Modus.

Returns:
Der Typ des Modus.

addClient

public void addClient(String client)
Fügt einen Client zur Liste der betroffenen Clients hinzu.

Parameters:
client - Die Nummer des hinzufügenden Clients.

removeClient

public void removeClient(String client)
Entfernt einen Client vone der Liste der betroffenen Clients.

Parameters:
client - Die Nummer des zu entfernden Clients.

setConnection

public void setConnection(ConnectionWaiting conWait)
Setzt das ConnectioNWaiting Objekt.

Parameters:
conWait - Das ConnectionWaiting Objekt.

parseGameCommand

public void parseGameCommand(GameCommand command)
Description copied from interface: GameCommandListener
Verarbeitet ein GameCommand.

Specified by:
parseGameCommand in interface GameCommandListener
Parameters:
command - Das GameCommand
See Also:
GameCommandListener.parseGameCommand(de.limdul.cassiopeia.control.gamecommands.GameCommand)

shutdown

public void shutdown()
Beendet den Server.


createModus

protected final void createModus(int newModus)
Erzeugt einen neuen Servermodus. Der hört auf die gleichen Clients wie der alte Modus.

Parameters:
newModus - Der gewünschte Modus.

testTCPCommand

protected final boolean testTCPCommand(TCPCommand command)
Testet, ob das TCPCommand verarbeitet werden soll. Die Logeinträge bei unerwarteten TCPCommands sind vom Level Normal, da der Client auch veraltete Befehle schicken kann.

Parameters:
command - Der Befehl
Returns:
true wenn es nicht verarbeitet werden soll, false sonst.

sendCommand

protected final void sendCommand(TCPCommand command,
                                 boolean save)
Sendet den Befehl nur an die Clients, die von diesem Modus betroffen sind.

Parameters:
command - Der zu sendende Befehl.
save - Ob der Befehl gespeichert werden soll für Zuschauer, die beitreten

sendCommand

protected final void sendCommand(TCPCommand command)
Sendet den Befehl nur an die Clients, die von diesem Modus betroffen sind.

Parameters:
command - Der zu sendende Befehl.

setEventHandler

public final void setEventHandler(EventHandler handler)
Description copied from interface: CassiopeiaListener
Setzt den Ereignisshandler, der für die Verteilung von Ereignissen zuständig ist. Listener können dort neu generierte Ereignisse hinschicken, die dann an die angeschlossenen Listener verteilt werden.

Specified by:
setEventHandler in interface CassiopeiaListener
Parameters:
handler - Der Ereignisshandler
See Also:
CassiopeiaListener.setEventHandler(de.limdul.cassiopeia.control.EventHandler)

clearExpectedTCP

protected final void clearExpectedTCP()
Löscht die Liste der erwarten TCP Befehle.


addExpectedTCP

protected final void addExpectedTCP(int command)
Fügt einen BEfehl zur Liste der erwarteten TCP Befehle hinzu.

Parameters:
command - Der hinzuzufügenden Befehl.

getEventHandler

protected final EventHandler getEventHandler()
Liefert den Eventhandler.

Returns:
Der Eventhandler.

getGame

protected final CassiopeiaGame getGame()
Liefert das Spiel.

Returns:
Das Spiel.

sendGameOptions

protected final void sendGameOptions()
Sendet die Spieloptionen. Greift auf TCPTools.sendGameOptions(GameOptions, EventHandler, String) zurück.


initialize

protected void initialize()
Wird aufgerufen, nachdem das Objekt erfolgreich erzeugt wurde.


parseChatMessage

protected void parseChatMessage(TCPChatMessage command)
Verarbeitet eine Chatnachricht.

Parameters:
command - Die Chatnachricht.

getGameLogic

protected final GameLogic getGameLogic()
Liefert das Spiellogik Objekt.

Returns:
Das Spiellogik Objekt.

setGameLogic

protected final void setGameLogic(GameLogic logic)
Setzt das Spiellogik Objekt.

Parameters:
logic - Das Spiellogik Objekt.

addToReplay

protected final void addToReplay(TCPCommand command)
Fügt einen Befehl zum Replay hinzu.

Parameters:
command - Der Befehl, der zum Replay hinzugefügt werden soll.

isLocalGame

protected final boolean isLocalGame()
Liefert zurück, ob es sich um ein lokales Spiel handelt.

Returns:
Ob es sich um ein lokales Spiel handelt.