added new server state chart
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
import pp.mdga.message.server.ServerState;
|
||||||
|
|
||||||
|
public class Ceremony extends ServerState {
|
||||||
|
public Ceremony(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class ChoosePiece extends Turn {
|
||||||
|
public ChoosePiece(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class DetermineStartPlayer extends Game {
|
||||||
|
public DetermineStartPlayer(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class FirstRoll extends RollDice {
|
||||||
|
public FirstRoll(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java
Normal file
10
Projekte/mdga/model/src/main/java/pp.mdga/server/Game.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
import pp.mdga.message.server.ServerState;
|
||||||
|
|
||||||
|
public class Game extends ServerState {
|
||||||
|
public Game(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
import pp.mdga.message.server.ServerState;
|
||||||
|
|
||||||
|
public class Interrupt extends ServerState {
|
||||||
|
public Interrupt(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java
Normal file
17
Projekte/mdga/model/src/main/java/pp.mdga/server/Lobby.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
import pp.mdga.message.server.ServerState;
|
||||||
|
|
||||||
|
public class Lobby extends ServerState {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a server state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param logic the game logic
|
||||||
|
*/
|
||||||
|
public Lobby(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class MovePiece extends Turn {
|
||||||
|
public MovePiece(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class NoPiece extends ChoosePiece {
|
||||||
|
public NoPiece(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class NoTurn extends ChoosePiece {
|
||||||
|
public NoTurn(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class PowerCard extends Turn {
|
||||||
|
public PowerCard(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class RollDice extends Turn {
|
||||||
|
public RollDice(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class SecondRoll extends RollDice {
|
||||||
|
public SecondRoll(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class SelectPiece extends ChoosePiece {
|
||||||
|
public SelectPiece(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package pp.mdga.message.server;
|
||||||
|
|
||||||
|
import com.jme3.network.Server;
|
||||||
|
import pp.mdga.game.Game;
|
||||||
|
import pp.mdga.message.client.*;
|
||||||
|
import pp.mdga.message.server.ServerSender;
|
||||||
|
import pp.mdga.message.server.ServerState;
|
||||||
|
import pp.mdga.server.Lobby;
|
||||||
|
|
||||||
|
import java.lang.System.Logger;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ServerGameLogic implements ClientInterpreter {
|
||||||
|
private static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName());
|
||||||
|
|
||||||
|
private final ServerSender serverSender;
|
||||||
|
|
||||||
|
private final Game game;
|
||||||
|
|
||||||
|
private final ServerState state;
|
||||||
|
|
||||||
|
private final ServerState lobby = new Lobby(this);
|
||||||
|
private final ServerState game = new Game(this);
|
||||||
|
private final ServerState interrupt = new Interrupt(this);
|
||||||
|
private final ServerState ceremony = new Ceremony(this);
|
||||||
|
private final ServerState turn = new Turn(this);
|
||||||
|
private final ServerState determineStartPlayer = new DetermineStartPlayer(this);
|
||||||
|
private final ServerState rollDice = new RollDice(this);
|
||||||
|
private final ServerState powerCard = new PowerCard(this);
|
||||||
|
private final ServerState movePiece = new MovePiece(this);
|
||||||
|
private final ServerState choosePiece = new ChoosePiece(this);
|
||||||
|
private final ServerState firstRoll = new FirstRoll(this);
|
||||||
|
private final ServerState secondRoll = new SecondRoll(this);
|
||||||
|
private final ServerState thirdRoll = new ThirdRoll(this);
|
||||||
|
private final ServerState noPiece = new NoPiece(this);
|
||||||
|
private final ServerState noTurn = new NoTurn(this);
|
||||||
|
private final ServerState waitingPiece = new WaitingPiece(this);
|
||||||
|
private final ServerState startPiece = new StartPiece(this);
|
||||||
|
private final ServerState selectPiece = new SelectPiece(this);
|
||||||
|
|
||||||
|
public ServerGameLogic(ServerSender serverSender, Game game) {
|
||||||
|
this.serverSender = serverSender;
|
||||||
|
this.game = game;
|
||||||
|
this.state = lobby;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(AnimationEnd msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(DeselectTSK msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(ForceStartGame msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(JoinServer msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(LeaveGame msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(LobbyNotReady msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(LobbyReady msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(RequestBriefing msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(RequestDice msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(RequestMove msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(RequestPlayCard msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(SelectCard msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(SelectTSK msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(ForceContinueGame msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(ClientStartGame msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(NoPowerCard msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(SelectedPieces msg, int from) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package pp.mdga.message.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for sending messages to a client.
|
||||||
|
*/
|
||||||
|
public interface ServerSender {
|
||||||
|
/**
|
||||||
|
* Send the specified message to the client.
|
||||||
|
*
|
||||||
|
* @param id the id of the client that shall receive the message
|
||||||
|
* @param message the message
|
||||||
|
*/
|
||||||
|
void send(int id, ServerMessage message);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class StartPiece extends ChoosePiece {
|
||||||
|
public StartPiece(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class ThirdRoll extends RollDice {
|
||||||
|
public ThirdRoll(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class Turn extends Game {
|
||||||
|
public Turn(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package pp.mdga.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.server.ServerGameLogic;
|
||||||
|
|
||||||
|
public class WaitingPiece extends ChoosePiece {
|
||||||
|
public WaitingPiece(ServerGameLogic logic) {
|
||||||
|
super(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user