Interpreter fuer messages hinzugefuegt

This commit is contained in:
Johannes Schmelz 2024-11-13 18:54:24 +01:00
parent 6773e18d34
commit f7149f225c
5 changed files with 257 additions and 1 deletions

View File

@ -8,7 +8,18 @@
package pp.monopoly.game.client; package pp.monopoly.game.client;
import pp.monopoly.message.client.ClientMessage; import pp.monopoly.message.client.ClientMessage;
import pp.monopoly.message.server.BuyPropertyResponse;
import pp.monopoly.message.server.DiceResult;
import pp.monopoly.message.server.EventDrawCard;
import pp.monopoly.message.server.GameOver;
import pp.monopoly.message.server.GameStart;
import pp.monopoly.message.server.JailEvent;
import pp.monopoly.message.server.PlayerStatusUpdate;
import pp.monopoly.message.server.ServerInterpreter; import pp.monopoly.message.server.ServerInterpreter;
import pp.monopoly.message.server.TimeOutWarning;
import pp.monopoly.message.server.TradeRequest;
import pp.monopoly.message.server.UpdatePlayerAssets;
import pp.monopoly.message.server.ViewAssetsResponse;
import pp.monopoly.model.IntPoint; import pp.monopoly.model.IntPoint;
import pp.monopoly.model.Board; import pp.monopoly.model.Board;
import pp.monopoly.notification.ClientStateEvent; import pp.monopoly.notification.ClientStateEvent;
@ -170,4 +181,70 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
public void update(float delta) { public void update(float delta) {
state.update(delta); state.update(delta);
} }
@Override
public void received(BuyPropertyResponse msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(DiceResult msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(EventDrawCard msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(GameOver msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(GameStart msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(JailEvent msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(PlayerStatusUpdate msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(TimeOutWarning msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(TradeRequest msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(UpdatePlayerAssets msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(ViewAssetsResponse msg) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
} }

View File

@ -8,7 +8,14 @@
package pp.monopoly.game.server; package pp.monopoly.game.server;
import pp.monopoly.MonopolyConfig; import pp.monopoly.MonopolyConfig;
import pp.monopoly.message.client.BuyPropertyRequest;
import pp.monopoly.message.client.ClientInterpreter; import pp.monopoly.message.client.ClientInterpreter;
import pp.monopoly.message.client.EndTurn;
import pp.monopoly.message.client.PlayerReady;
import pp.monopoly.message.client.RollDice;
import pp.monopoly.message.client.TradeOffer;
import pp.monopoly.message.client.TradeResponse;
import pp.monopoly.message.client.ViewAssetsRequest;
import pp.monopoly.message.server.ServerMessage; import pp.monopoly.message.server.ServerMessage;
import pp.monopoly.model.IntPoint; import pp.monopoly.model.IntPoint;
@ -122,4 +129,46 @@ public class ServerGameLogic implements ClientInterpreter {
throw new UnsupportedOperationException("Unimplemented method"); throw new UnsupportedOperationException("Unimplemented method");
} }
@Override
public void received(BuyPropertyRequest msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(EndTurn msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(PlayerReady msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(RollDice msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(TradeOffer msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(TradeResponse msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
@Override
public void received(ViewAssetsRequest msg, int from) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'received'");
}
} }

View File

@ -11,5 +11,59 @@ package pp.monopoly.message.client;
* Visitor interface for processing all client messages. * Visitor interface for processing all client messages.
*/ */
public interface ClientInterpreter { public interface ClientInterpreter {
/**
* Processes a received BuyPropertyRequest.
*
* @param msg the BuyPropertyRequest to be processed
* @param from the connection ID from which the message was received
*/
void received(BuyPropertyRequest msg, int from);
/**
* Processes a received EndTurn.
*
* @param msg the EndTurn to be processed
* @param from the connection ID from which the message was received
*/
void received(EndTurn msg, int from);
/**
* Processes a received PlayerReady.
*
* @param msg the PlayerReady to be processed
* @param from the connection ID from which the message was received
*/
void received(PlayerReady msg, int from);
/**
* Processes a received RollDice.
*
* @param msg the RollDice to be processed
* @param from the connection ID from which the message was received
*/
void received(RollDice msg, int from);
/**
* Processes a received TradeOffer.
*
* @param msg the TradeOffer to be processed
* @param from the connection ID from which the message was received
*/
void received(TradeOffer msg, int from);
/**
* Processes a received TradeResponse.
*
* @param msg the TradeResponse to be processed
* @param from the connection ID from which the message was received
*/
void received(TradeResponse msg, int from);
/**
* Processes a received ViewAssetsRequest.
*
* @param msg the ViewAssetsRequest to be processed
* @param from the connection ID from which the message was received
*/
void received(ViewAssetsRequest msg, int from);
} }

View File

@ -13,4 +13,80 @@ package pp.monopoly.message.server;
*/ */
public interface ServerInterpreter { public interface ServerInterpreter {
/**
* Handles a BuyPropertyResponse message received from the server.
*
* @param msg the BuyPropertyResponse message received
*/
void received(BuyPropertyResponse msg);
/**
* Handles a DiceResult message received from the server.
*
* @param msg the DiceResult message received
*/
void received(DiceResult msg);
/**
* Handles a EventDrawCard message received from the server.
*
* @param msg the EventDrawCard message received
*/
void received(EventDrawCard msg);
/**
* Handles a GameOver message received from the server.
*
* @param msg the GameOver message received
*/
void received(GameOver msg);
/**
* Handles a GameStart message received from the server.
*
* @param msg the GameStart message received
*/
void received(GameStart msg);
/**
* Handles a JailEvent message received from the server.
*
* @param msg the JailEvent message received
*/
void received(JailEvent msg);
/**
* Handles a PlayerStatusUpdate message received from the server.
*
* @param msg the PlayerStatusUpdate message received
*/
void received(PlayerStatusUpdate msg);
/**
* Handles a TimeOutWarning message received from the server.
*
* @param msg the TimeOutWarning message received
*/
void received(TimeOutWarning msg);
/**
* Handles a TradeRequest message received from the server.
*
* @param msg the TradeRequest message received
*/
void received(TradeRequest msg);
/**
* Handles a UpdatePlayerAssets message received from the server.
*
* @param msg the UpdatePlayerAssets message received
*/
void received(UpdatePlayerAssets msg);
/**
* Handles a ViewAssetsResponse message received from the server.
*
* @param msg the ViewAssetsResponse message received
*/
void received(ViewAssetsResponse msg);
} }

View File

@ -1,6 +1,6 @@
package pp.monopoly.message.server; package pp.monopoly.message.server;
public class TradeResponse extends ServerMessage{ public class TradeRequest extends ServerMessage{
@Override @Override
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {