Update: TUI totem choice impl

This commit is contained in:
rubenpirreram
2026-05-13 17:43:46 +02:00
parent 110526d836
commit c3095ae69d
4 changed files with 71 additions and 12 deletions
@@ -11,6 +11,7 @@ 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.NetworkEvents.TotemChoice;
import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
import it.polimi.ingsw.gc14.View.TUI.TUI;
@@ -116,21 +117,23 @@ public class ServerLauncher {
int roundPrec=gameController.getModel().getCurrentState().getRound();
synchronized(gameController){
event.setIsError(!event.apply(gameController));
Game game=gameController.getModel();
if(!event.getIsError())
{
event.setData(gameController.getModel().getSlotMap(),gameController.getModel().orderLogicCard,gameController.getModel().getCurrentState(),gameController.getModel().getPlayerByUsername(event.getUsername()));
event.setData(game.getSlotMap(),game.orderLogicCard,game.getCurrentState(),game.getPlayerByUsername(event.getUsername()));
if(event.getEventType().equals(EventType.TOTEM_CHOICE))
((TotemChoice)event).setAvailableTotems(gameController.getModel().getAvailableTotems());
}
serverRMI.notifyAll(event);
serverTCP.notifyAll(event);
if(gameController.getModel().getCurrentState().getRound()!=roundPrec)
if(game.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){
if(game.getCurrentState().getGameStage() == GameStages.ENDED){
if(!this.deleteSave()){
System.out.println("\n!!! Couldn't delete save !!!\n");
}