//TODO: JVD MISSING
This commit is contained in:
@@ -160,7 +160,7 @@ public class ClientLauncherTUI {
|
||||
view.setLineReader(gameReader);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
private boolean doLoginInner(ClientController controller, LineReader loginReader, LineReader ipReader) {
|
||||
String username, networkStr, ip;
|
||||
int nPlayers;
|
||||
|
||||
@@ -33,11 +33,15 @@ import java.util.stream.Collectors;
|
||||
* thread via {@link #doFirstEvent()}.
|
||||
*/
|
||||
public class GameEventProcessor {
|
||||
|
||||
//TODO
|
||||
private final BlockingQueue<NetworkEvent> actionQueue;
|
||||
//TODO
|
||||
private final GameController gameController;
|
||||
//TODO
|
||||
private final LimitedMap<String, Boolean> playerList;
|
||||
//TODO
|
||||
private final CompositeClientBroadcaster broadcaster;
|
||||
//TODO
|
||||
private final SaveManager saveManager;
|
||||
|
||||
/** Single-thread executor used exclusively for the forfeit timer. Daemon so it does not block JVM shutdown. */
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @param <V> the type of mapped values.
|
||||
*/
|
||||
public class LimitedMap<K, V> implements Map<K, V> {
|
||||
|
||||
//TODO
|
||||
private final ConcurrentHashMap<K, V> map = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -165,7 +165,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
this.effectType = effectTypeFromId(effectId);
|
||||
this.effectId = effectId;
|
||||
}
|
||||
|
||||
//TODO JV
|
||||
private static EffectType effectTypeFromId(int effectId) {
|
||||
switch (effectId) {
|
||||
case 2, 9, 7, 6, 5: return EffectType.ON_EVENT;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.*;
|
||||
*/
|
||||
public class DecksCreator {
|
||||
|
||||
private DecksCreator() {}
|
||||
|
||||
/**
|
||||
* Loads the tribe card deck for the specified era from the corresponding JSON resource file.
|
||||
|
||||
@@ -11,8 +11,9 @@ import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
|
||||
* broadcaster without knowing which protocols are active underneath.
|
||||
*/
|
||||
public class CompositeClientBroadcaster {
|
||||
|
||||
//TODO
|
||||
private final RMIServer rmiServer;
|
||||
//TODO
|
||||
private final TCPServer tcpServer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ public enum EventType {
|
||||
* Event used to notify that the game has ended.
|
||||
*/
|
||||
ENDED_GAME("Ended Game");
|
||||
|
||||
//TODO
|
||||
private final String description;
|
||||
EventType(String description) {
|
||||
this.description = description;
|
||||
|
||||
@@ -45,6 +45,7 @@ public class InterfaceResolver {
|
||||
return socket.getLocalAddress().getHostAddress();
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
private static boolean sameSubnet(InetAddress a, InetAddress b, int prefix) {
|
||||
if (prefix < 0 || prefix > 32) return false;
|
||||
int maskBits = prefix == 0 ? 0 : (0xFFFFFFFF << (32 - prefix));
|
||||
@@ -52,6 +53,7 @@ public class InterfaceResolver {
|
||||
int addrB = toInt(b.getAddress()) & maskBits;
|
||||
return addrA == addrB;
|
||||
}
|
||||
//TODO
|
||||
private static int toInt(byte[] bytes) {
|
||||
return ((bytes[0] & 0xFF) << 24) |
|
||||
((bytes[1] & 0xFF) << 16) |
|
||||
|
||||
@@ -25,10 +25,13 @@ import java.util.Map;
|
||||
* always returns {@code false}.
|
||||
*/
|
||||
public class ApplyNextRound extends NetworkEvent {
|
||||
|
||||
//TODO
|
||||
private final ArrayList<TribeCard> upperListTribeCards;
|
||||
//TODO
|
||||
private final ArrayList<TribeCard> lowerListTribeCards;
|
||||
//TODO
|
||||
private final ArrayList<BuildingCard> upperListBuildingCards;
|
||||
//TODO
|
||||
private final ArrayList<BuildingCard> lowerListBuildingCards;
|
||||
|
||||
|
||||
|
||||
@@ -14,14 +14,19 @@ import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer;
|
||||
* Client RMI. Uses the methods exposed by the server RMI.
|
||||
*/
|
||||
public class RMIClient implements IClient {
|
||||
|
||||
//TODO
|
||||
private final String host;
|
||||
//TODO
|
||||
private final int port;
|
||||
//TODO
|
||||
private IGameServer stub;
|
||||
//TODO
|
||||
private final ClientController controller;
|
||||
//TODO
|
||||
private final String myIp;
|
||||
//TODO
|
||||
private String username;
|
||||
|
||||
//TODO
|
||||
private volatile boolean running = false;
|
||||
|
||||
/** Scheduler that fires ping() every {@value NetworkConfig#KEEPALIVE_INTERVAL_MS} ms. */
|
||||
|
||||
@@ -26,16 +26,20 @@ import java.util.concurrent.*;
|
||||
* </ul>
|
||||
*/
|
||||
public class RMIHeartbeat {
|
||||
|
||||
//TODO
|
||||
private String username;
|
||||
//TODO
|
||||
private final LimitedMap<String, Boolean> playerList;
|
||||
//TODO
|
||||
private final Map<String, IClientCallback> clients;
|
||||
//TODO
|
||||
private final BlockingQueue<NetworkEvent> actionQueue;
|
||||
|
||||
/** Last time a ping was received from this client. */
|
||||
private volatile long lastPingTime = System.currentTimeMillis();
|
||||
//TODO
|
||||
private volatile boolean running = true;
|
||||
|
||||
//TODO
|
||||
private final ScheduledExecutorService watchdog =
|
||||
Executors.newSingleThreadScheduledExecutor(r -> {
|
||||
Thread t = new Thread(r, "rmi-watchdog-" + username);
|
||||
|
||||
@@ -33,8 +33,11 @@ import java.util.stream.Collectors;
|
||||
* shared network event queue.
|
||||
*/
|
||||
public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
//TODO
|
||||
private final String host;
|
||||
//TODO
|
||||
private final GameController controller;
|
||||
//TODO
|
||||
private final int nPort;
|
||||
|
||||
/** username → callback */
|
||||
@@ -46,8 +49,9 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* HeartbeatHandler in the TCP stack.
|
||||
*/
|
||||
private final Map<String, RMIHeartbeat> watchdogs = new ConcurrentHashMap<>();
|
||||
|
||||
//TODO
|
||||
private final BlockingQueue<NetworkEvent> actionQueue;
|
||||
//TODO
|
||||
private final LimitedMap<String, Boolean> playerList;
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* Client TCP. Sends and receives messages with the TCP server.
|
||||
*/
|
||||
public class TCPClient implements IClient {
|
||||
//TODO
|
||||
private static final int PING = 1;
|
||||
//TODO
|
||||
private static final int PONG = 2;
|
||||
|
||||
/** Socket TCP */
|
||||
@@ -35,14 +37,17 @@ public class TCPClient implements IClient {
|
||||
|
||||
/** IP address of the server to connect to */
|
||||
private final String hostname;
|
||||
|
||||
//TODO
|
||||
private boolean running;
|
||||
/** TCP port */
|
||||
private final int mainPort;
|
||||
|
||||
//TODO
|
||||
private final int heartbeatPort;
|
||||
//TODO
|
||||
private Socket heartbeatSocket;
|
||||
//TODO
|
||||
private OutputStream heartbeatOut;
|
||||
//TODO
|
||||
private InputStream heartbeatIn;
|
||||
|
||||
|
||||
@@ -108,7 +113,7 @@ public class TCPClient implements IClient {
|
||||
return ErrorType.SERVER_UNREACHABLE;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
private void heartbeatLoop() {
|
||||
ScheduledExecutorService sender = Executors.newSingleThreadScheduledExecutor();
|
||||
sender.scheduleAtFixedRate(() -> {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ClientHandler implements Runnable {
|
||||
* The username of the connected client on this handler
|
||||
*/
|
||||
private final String username;
|
||||
|
||||
//TODO
|
||||
private volatile boolean running;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,10 +16,13 @@ import it.polimi.ingsw.gc14.Network.NetworkConfig;
|
||||
* both the heartbeat connection and the main client connection are disconnected.
|
||||
*/
|
||||
public class HeartbeatHandler implements Runnable {
|
||||
|
||||
//TODO
|
||||
private final String username;
|
||||
//TODO
|
||||
private final Socket socket;
|
||||
//TODO
|
||||
private final InputStream in;
|
||||
//TODO
|
||||
private final OutputStream out;
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,10 +34,13 @@ import java.util.*;
|
||||
* <p>Displays the final player rankings and a winner/game-over banner.
|
||||
*/
|
||||
public class LeaderboardFXMLController {
|
||||
|
||||
//TODO
|
||||
@FXML private StackPane rootPane;
|
||||
//TODO
|
||||
@FXML private VBox mainVBox;
|
||||
//TODO
|
||||
@FXML private VBox rankingList;
|
||||
|
||||
/** Client controller for fetching game state and sending actions. */
|
||||
private ClientController controller;
|
||||
/** Auto-hiding popup that shows detailed player card information. */
|
||||
@@ -163,9 +166,9 @@ public class LeaderboardFXMLController {
|
||||
Label posLabel = new Label(position + "°");
|
||||
posLabel.setMinWidth(55);
|
||||
String medalColor = switch (position) {
|
||||
case 1 -> "#FFD700";
|
||||
case 2 -> "#C0C0C0";
|
||||
case 3 -> "#CD7F32";
|
||||
case 1 -> "#FFD700"; // oro
|
||||
case 2 -> "#C0C0C0"; // argento
|
||||
case 3 -> "#CD7F32"; // bronzo
|
||||
default -> "#EEEEEE";
|
||||
};
|
||||
posLabel.setStyle("-fx-font-size: 28px; -fx-font-weight: bold; -fx-text-fill: " + medalColor + ";");
|
||||
@@ -324,7 +327,7 @@ public class LeaderboardFXMLController {
|
||||
scrollPane.setStyle("-fx-background: transparent; -fx-background-color: transparent;");
|
||||
|
||||
Window window = rootPane.getScene().getWindow();
|
||||
scrollPane.setMaxHeight(window.getHeight() * 0.8);
|
||||
scrollPane.setMaxHeight(window.getHeight() * 0.8); // cap scroll area to 80% of window height
|
||||
popupContent.getChildren().add(scrollPane);
|
||||
popup.show(window, 0, 0);
|
||||
popup.getScene().setFill(Color.TRANSPARENT);
|
||||
|
||||
@@ -7,13 +7,14 @@ package it.polimi.ingsw.gc14.View.TUI;
|
||||
* <p>Each style stores the characters needed to draw table corners,
|
||||
* horizontal and vertical lines, and junctions.
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
public enum BorderStyle {
|
||||
|
||||
/**
|
||||
* Rounded Unicode border style.
|
||||
*/
|
||||
ROUNDED("╭","╮","╰","╯","─","│","├","┤","┬","┴","┼","├","┤","┼");
|
||||
|
||||
//TODO
|
||||
private final String tl,tr,bl,br,h,v,ml,mr,mt,mb,x,sl,sr,sx;
|
||||
|
||||
BorderStyle(String tl,String tr,String bl,String br,
|
||||
|
||||
Reference in New Issue
Block a user