the game will now create a new clg when entering the main view
This commit is contained in:
@@ -84,7 +84,7 @@ public class MdgaApp extends SimpleApplication {
|
|||||||
/**
|
/**
|
||||||
* The client game logic.
|
* The client game logic.
|
||||||
*/
|
*/
|
||||||
private final ClientGameLogic clientGameLogic;
|
private ClientGameLogic clientGameLogic;
|
||||||
|
|
||||||
private ExecutorService executor;
|
private ExecutorService executor;
|
||||||
|
|
||||||
@@ -204,6 +204,7 @@ public void enter(MdgaState state) {
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case MAIN:
|
case MAIN:
|
||||||
view = mainView;
|
view = mainView;
|
||||||
|
clientGameLogic.clear();
|
||||||
break;
|
break;
|
||||||
case LOBBY:
|
case LOBBY:
|
||||||
view = lobbyView;
|
view = lobbyView;
|
||||||
|
|||||||
@@ -76,6 +76,15 @@ private Piece getPiece(UUID pieceId) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear(){
|
||||||
|
game = new Game();
|
||||||
|
notifications.clear();
|
||||||
|
setState(dialogsState);
|
||||||
|
isHost = false;
|
||||||
|
ownPlayerID = 0;
|
||||||
|
ownPlayerName = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the clientSender
|
* This method returns the clientSender
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -175,4 +175,16 @@ public void received(StartGameMessage msg, int from) {
|
|||||||
this.logic.getServerSender().send(from, new IncorrectRequestMessage(5));
|
this.logic.getServerSender().send(from, new IncorrectRequestMessage(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removed the player after receiving a LeaveGameMessage message.
|
||||||
|
*
|
||||||
|
* @param msg as the message which was sent by the player as a LeaveGameMessage object.
|
||||||
|
* @param from as the client id of the player as an Integer.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void received(LeaveGameMessage msg, int from) {
|
||||||
|
this.logic.getGame().removePlayer(from);
|
||||||
|
this.logic.getServerSender().broadcast(new LobbyPlayerLeaveMessage(from));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ public void received(AnimationEndMessage msg, int from) {
|
|||||||
if (finishedAnimations.size() == logic.getGame().getPlayers().size()) {
|
if (finishedAnimations.size() == logic.getGame().getPlayers().size()) {
|
||||||
if (logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).isFinished()) {
|
if (logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).isFinished()) {
|
||||||
logic.getGame().getPlayerRanking().put(logic.getGame().getPlayerRanking().size(), logic.getGame().getActivePlayer());
|
logic.getGame().getPlayerRanking().put(logic.getGame().getPlayerRanking().size(), logic.getGame().getActivePlayer());
|
||||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(logic.getGame().getActiveColor()), new SpectatorMessage());
|
|
||||||
setActivePlayer(logic.getGame().getActiveColor());
|
|
||||||
if (logic.getGame().getPlayerRanking().size() == logic.getGame().getPlayers().size() - 1) {
|
if (logic.getGame().getPlayerRanking().size() == logic.getGame().getPlayers().size() - 1) {
|
||||||
logic.getGame().getPlayerRanking().put(logic.getGame().getPlayerRanking().size(), logic.getGame().getActivePlayer());
|
logic.getGame().getPlayerRanking().put(logic.getGame().getPlayerRanking().size(), logic.getGame().getPlayerByColor(logic.getGame().getActiveColor().next(logic.getGame())));
|
||||||
logic.setCurrentState(logic.getCeremonyState());
|
logic.setCurrentState(logic.getCeremonyState());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(logic.getGame().getActiveColor()), new SpectatorMessage());
|
||||||
|
setActivePlayer(logic.getGame().getActiveColor());
|
||||||
this.turnAutomaton.getGameAutomaton().setCurrentState(this.turnAutomaton.getGameAutomaton().getTurnState());
|
this.turnAutomaton.getGameAutomaton().setCurrentState(this.turnAutomaton.getGameAutomaton().getTurnState());
|
||||||
}
|
}
|
||||||
else if (logic.getGame().getDiceEyes() == 6) {
|
else if (logic.getGame().getDiceEyes() == 6) {
|
||||||
|
|||||||
Reference in New Issue
Block a user