Add: Endgame event creation end sending
This commit is contained in:
@@ -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.EndedGame;
|
||||
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;
|
||||
@@ -119,15 +120,21 @@ public class ServerLauncher {
|
||||
Game game=gameController.getModel();
|
||||
if(!event.getIsError())
|
||||
{
|
||||
if(event.getEventType().equals(EventType.DISCONNECTED_PLAYER)&& game.getCurrentState().getGameStage().equals(GameStages.WAITING))
|
||||
if(game.getCurrentState().getGameStage().equals(GameStages.ENDED))
|
||||
{
|
||||
playerList.remove(event.getUsername());
|
||||
}else {
|
||||
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());
|
||||
} else if (event.getEventType().equals(EventType.DISCONNECTED_PLAYER) && game.getCurrentState().equals(GameStages.WAITING)) {
|
||||
actionQueue.offer(new EndedGame(game.getSlotMap(), game.orderLogicCard, game.getCurrentState(),game.getPlayerStanding()));
|
||||
}
|
||||
else {
|
||||
if(event.getEventType().equals(EventType.DISCONNECTED_PLAYER)&& game.getCurrentState().getGameStage().equals(GameStages.WAITING))
|
||||
{
|
||||
playerList.remove(event.getUsername());
|
||||
}else {
|
||||
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());
|
||||
} else if (event.getEventType().equals(EventType.DISCONNECTED_PLAYER) && game.getCurrentState().equals(GameStages.WAITING)) {
|
||||
playerList.remove(event.getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,6 +168,7 @@ public class ServerLauncher {
|
||||
}
|
||||
disconnectionTimer = timerExecutor.schedule(() -> {
|
||||
game.EndGameForFeit(game.getPlayerByUsername(playerList.keySet().stream().toList().getFirst()));
|
||||
actionQueue.offer(new EndedGame(game.getSlotMap(), game.orderLogicCard, game.getCurrentState(),game.getPlayerStanding()));
|
||||
System.out.println("Timer expired: no player reconnected in 60s.");
|
||||
}, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user