Fix: Only one player logic (todo go to end-game)

This commit is contained in:
rubenpirreram
2026-05-11 18:05:53 +02:00
parent ef34f780a3
commit 3a39d889e4
6 changed files with 80 additions and 30 deletions
@@ -14,7 +14,7 @@ public enum EventType {
PICK_OPTIONAL_TRIBE,
PICK_OPTIONAL_BUILD,
SKIP_NO_DRAWABLE,
SKIP_PLAYER_DISCONNECTED,
DISCONNECTED_PLAYER,
RECONNECT_PLAYER,
NO_OPTIONAL_CARD
}
@@ -17,7 +17,7 @@ public class DisconnectedPlayer extends NetworkEvent implements Serializable{
* @param username the name of the player requesting the event
*/
public DisconnectedPlayer(String username){
super(username, EventType.SKIP_PLAYER_DISCONNECTED, false);
super(username, EventType.DISCONNECTED_PLAYER, false);
}
/**
@@ -17,7 +17,7 @@ public class SkipNoDrawable extends NetworkEvent implements Serializable{
* @param username the name of the player requesting the event
*/
public SkipNoDrawable(String username){
super(username, EventType.SKIP_PLAYER_DISCONNECTED, false);
super(username, EventType.SKIP_NO_DRAWABLE, false);
}
/**
@@ -43,6 +43,9 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
private LimitedMap<String, Boolean> playerList;
private boolean serverCrashed;
public void setServerCrashed(boolean serverCrashed) {
this.serverCrashed = serverCrashed;
}
public RMIServer(GameController controller, int nPort,
BlockingQueue<NetworkEvent> actionQueue,
@@ -36,6 +36,10 @@ public class TCPServer {
List<ClientHandler> clientHandlers;
boolean serverCrashed;
public void setServerCrashed(boolean serverCrashed) {
this.serverCrashed = serverCrashed;
}
// Mappa temporanea: username → ClientHandler
// Serve per associare il socket heartbeat al giusto ClientHandler
private final Map<String, ClientHandler> pendingHeartbeat = new ConcurrentHashMap<>();