Package pp.battleship.game.singlemode
Klasse ServerConnectionMockup
java.lang.Object
pp.battleship.game.singlemode.ServerConnectionMockup
- Alle implementierten Schnittstellen:
ClientSender,ServerConnection,ServerSender
A mock implementation of the ServerConnection interface for single mode.
Simulates a server connection without actual network communication.
Handles a mock player named RobotClient and schedules its shots when due.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungServerConnectionMockup(BattleshipClient playerClient) Constructs a ServerConnectionMockup instance for the given Battleship application. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidconnect()Simulates connecting to a server by adding the PlayerClient and the RobotClient to the serverGameLogic.voidDoes nothing upon shutdown of the app.booleanAlways returns true as this is a mock connection.voidsend(int id, ServerMessage message) Forwards the specified message received from the server logic either to the player client or to the robot client, depending on the specified id.voidsend(ClientMessage message) Forwards the specified message received from the player client to the server logic.
-
Konstruktordetails
-
ServerConnectionMockup
Constructs a ServerConnectionMockup instance for the given Battleship application. Creates a RobotClient instance and an instance of ServerGameLogic.- Parameter:
playerClient- The Battleship client instance, e.g., a BattleshipApp instance.
-
-
Methodendetails
-
isConnected
public boolean isConnected()Always returns true as this is a mock connection.- Angegeben von:
isConnectedin SchnittstelleServerConnection- Gibt zurück:
- true, indicating the mock connection is always considered connected.
-
connect
public void connect()Simulates connecting to a server by adding the PlayerClient and the RobotClient to the serverGameLogic. Loads the map of the PlayerClient and triggers sending it to the serverGameLogic.- Angegeben von:
connectin SchnittstelleServerConnection
-
disconnect
public void disconnect()Does nothing upon shutdown of the app.- Angegeben von:
disconnectin SchnittstelleServerConnection
-
send
Forwards the specified message received from the player client to the server logic.- Angegeben von:
sendin SchnittstelleClientSender- Parameter:
message- The message from the player client to be processed.
-
send
Forwards the specified message received from the server logic either to the player client or to the robot client, depending on the specified id.- Angegeben von:
sendin SchnittstelleServerSender- Parameter:
id- The recipient idmessage- The server message to be processed- Siehe auch:
-