added more logic for the server state diagram
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.PauseGame;
|
||||
import pp.mdga.message.server.PossibleCard;
|
||||
import pp.mdga.message.server.RankingResponce;
|
||||
|
||||
public class GameState extends ServerState {
|
||||
private final GameStateMachine gameStateMachine = new GameStateMachine(this, logic);
|
||||
@@ -18,58 +19,50 @@ public void entry() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedAnimationEnd(AnimationEnd msg) {
|
||||
gameStateMachine.receivedAnimationEnd(msg);
|
||||
}
|
||||
|
||||
// todo piece?
|
||||
@Override
|
||||
public void receivedConfirmPiece(Piece piece) {
|
||||
gameStateMachine.receivedConfirmPiece(piece);
|
||||
public void exit() {
|
||||
parent.gotoState(new Ceremony(parent, logic));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedNoPowerCard(NoPowerCard msg) {
|
||||
gameStateMachine.receivedNoPowerCard(msg);
|
||||
public void receivedAnimationEnd(AnimationEnd msg, int from) {
|
||||
gameStateMachine.receivedAnimationEnd(msg, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedSelectCard(SelectCard msg) {
|
||||
gameStateMachine.receivedSelectCard(msg);
|
||||
public void receivedNoPowerCard(NoPowerCard msg, int from) {
|
||||
gameStateMachine.receivedNoPowerCard(msg, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedRequestDice(RequestDice msg) {
|
||||
gameStateMachine.receivedRequestDice(msg);
|
||||
}
|
||||
|
||||
// todo msg?
|
||||
@Override
|
||||
public void receivedRollRankingDice() {
|
||||
gameStateMachine.receivedRollRankingDice();
|
||||
public void receivedSelectCard(SelectCard msg, int from) {
|
||||
gameStateMachine.receivedSelectCard(msg, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedSelectedPieces(SelectedPieces msg) {
|
||||
gameStateMachine.receivedSelectedPieces(msg);
|
||||
public void receivedRequestDice(RequestDice msg, int from) {
|
||||
gameStateMachine.receivedRequestDice(msg, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sentPossibleCard(PossibleCard msg) {
|
||||
gameStateMachine.sentPossibleCard(msg);
|
||||
public void receivedSelectedPieces(SelectedPieces msg, int from) {
|
||||
gameStateMachine.receivedSelectedPieces(msg, from);
|
||||
}
|
||||
|
||||
// todo msg?, sent to everyone?
|
||||
@Override
|
||||
public void sentRankingResponse() {
|
||||
gameStateMachine.sentRankingResponse();
|
||||
public void sentPossibleCard(PossibleCard msg, int from) {
|
||||
gameStateMachine.sentPossibleCard(msg, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sentRankingResponse(RankingResponce msg, int from) {
|
||||
gameStateMachine.sentRankingResponse(msg, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (logic.getGame().playerHasDisconnected()) {
|
||||
parent.gotoState(new Interrupt(parent, logic));
|
||||
// todo: change to interrupt, save the last state of gamestatemachine, change from interrupt to gamestate has to restore the last state
|
||||
if (Boolean.TRUE.equals(logic.getGame().playerHasDisconnected())) {
|
||||
broadcastUpdate(new PauseGame());
|
||||
parent.gotoState(new Interrupt(parent, logic, this));
|
||||
logic.getGame().removeObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user