Fix: Replaced Model With MiniModel in the client implementation and in the view
This commit is contained in:
@@ -4,9 +4,11 @@ package it.polimi.ingsw.gc14;
|
||||
import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.ApplyNextRound;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer;
|
||||
import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
|
||||
import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
|
||||
@@ -110,10 +112,22 @@ public class ServerLauncher {
|
||||
disconnectionTimer.cancel(false);
|
||||
disconnectionTimer = null;
|
||||
}
|
||||
int roundPrec=gameController.getModel().getCurrentState().getRound();
|
||||
synchronized(gameController){
|
||||
event.setIsError(!event.apply(gameController));
|
||||
if(!event.getIsError())
|
||||
{
|
||||
event.setData(gameController.getModel().getSlotMap(),gameController.getModel().orderLogicCard,gameController.getModel().getCurrentState(),gameController.getModel().getPlayerByUsername(event.getUsername()));
|
||||
}
|
||||
serverRMI.notifyAll(event);
|
||||
serverTCP.notifyAll(event);
|
||||
if(gameController.getModel().getCurrentState().getRound()!=roundPrec)
|
||||
{
|
||||
Game game=gameController.getModel();
|
||||
ApplyNextRound nextRound=new ApplyNextRound(game.getSlotMap(), game.orderLogicCard, game.getCurrentState(),game.getPlayers());
|
||||
serverRMI.notifyAll(nextRound);
|
||||
serverTCP.notifyAll(nextRound);
|
||||
}
|
||||
if(!event.getIsError()){
|
||||
if(this.gameController.getModel().getCurrentState().getGameStage() == GameStages.ENDED){
|
||||
this.deleteSave();
|
||||
@@ -196,9 +210,14 @@ public class ServerLauncher {
|
||||
new Thread(()->{
|
||||
try {
|
||||
System.out.println("\n\nNotifying model");
|
||||
serverRMI.notifyAll(gameController.getModel());
|
||||
serverTCP.notifyAll(gameController.getModel());
|
||||
view = new TUI(gameController.getModel());
|
||||
MiniModel miniModel;
|
||||
synchronized (gameController) {
|
||||
Game game = gameController.getModel();
|
||||
miniModel= new MiniModel(game.getBoard(),game.getSlotMap(), game.orderLogicCard,game.getCurrentState(),game.getPlayers());
|
||||
}
|
||||
serverRMI.notifyAll(miniModel);
|
||||
serverTCP.notifyAll(miniModel);
|
||||
view = new TUI(miniModel);
|
||||
view.fullRender();
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user