Files
Progetto-ingegneria-del-sof…/README.md
T
2026-06-19 22:16:34 +02:00

11 KiB
Raw Blame History

Mesos — Software Engineering 2026

Group GC14 — Pirrera · Radice · Pagani · Pellegrino


Implemented Features

Feature Status
Full game rules
TUI (Text User Interface)
GUI (JavaFX)
Network — RMI
Network — Socket/TCP
AF1 — Persistence
AF2 — Disconnection resilience

Notes on advanced features

AF1 — Persistence The server automatically saves the game state to disk (GameSaves/save.dat) after every game event. If the server is restarted, the saved game is automatically restored and clients can reconnect. The save is discarded only if, at the time of the crash, all players except at most one were disconnected.

AF2 — Disconnection resilience A client that loses connection is marked as disconnected but the game does not end. The game continues with the remaining players. The disconnected player can reconnect at any time with the same username and find the game in its current state.


System Requirements

  • Java 25 or higher
  • JARs are fat-jars (all dependencies included), no external libraries need to be installed

Launch — Server

java -jar Server.jar

On startup the server lists the active IPv4 network interfaces and asks the operator to choose one (required for correct RMI operation on a local network). If only one interface is present, it is selected automatically.

Example output:

[0] eth0 -> 192.168.1.10
[1] eth1 -> 192.168.95.7
Choose interface: 0
192.168.1.10
Server RMI: 192.168.1.10

Ports used by the server (must not be blocked by the firewall):

Protocol Port
RMI registry 1099
TCP game 8080
TCP heartbeat 8081

Launch — TUI Client

java -jar ClientTUI.jar

On startup the client interactively asks:

Field Accepted values
Username free string, max 10 characters
Number of players [2-5] integer between 2 and 5
Network [rmi/tcp] rmi or tcp
Server IP [localhost] server IP address; empty enter uses localhost

Available in-game commands (TUI)

Command Description
slot <pos> Moves the totem to the slot at position <pos>
draw upper tribe <pos> Draws the tribe card at position <pos> from the upper row
draw upper building <pos> Draws the building card at position <pos> from the upper row
draw lower tribe <pos> Draws the tribe card at position <pos> from the lower row
draw lower building <pos> Draws the building card at position <pos> from the lower row
totem <pos> Chooses the totem at position <pos> (totem selection phase)
skip Skips the turn (if no other actions can be performed)
clear Redraws the board on screen
details buildings Shows the description of all buildings
details events Shows the description of all events
details characters Shows the description of all characters
rematch Returns to the login screen (end of game only)
quit Disconnects and closes the client

The TUI supports Tab autocomplete for all commands.


Launch — GUI Client

java -jar ClientGUI.jar

The graphical window opens directly. Fill in the fields on the login screen:

  • Username — player name
  • N. players — number of players (25)
  • Protocol — RMI / TCP toggle (click to switch)
  • Server IP — server IP address

Press Login to connect. The GUI starts in fullscreen mode; press ESC to exit fullscreen and F11 to re-enter it.


Local Testing (all on localhost)

  1. Open a terminal and start the server:

    java -jar Server.jar
    
  2. Open N terminals (one per client) and start the clients:

    # TUI
    java -jar ClientTUI.jar
    
    # or GUI
    java -jar ClientGUI.jar
    
  3. As soon as the configured number of players has connected, the game starts automatically.


LAN Testing

  1. The server runs on the machine with IP e.g. 192.168.1.10.
  2. Start the server and choose the 192.168.1.10 interface.
  3. Clients on other machines enter that IP as Server IP.
  4. Make sure ports 1099, 8080, 8081 are reachable from the network.

Project Structure

src/main/java/it/polimi/ingsw/gc14/
├── Controller/          # GameController (server) and ClientController (client)
├── Model/               # Game entities: Player, Game, Board, Card, Slot, ...
│   ├── Cards/           # BuildingCard, TribeCard, EventCard, Character
│   ├── GamePackage/     # Board, CurrentState, GameStages
│   └── Orders/          # Player ordering logic
├── Network/             # Network protocols
│   ├── RMI/             # RMI client and server
│   ├── TCP/             # TCP client and server
│   └── NetworkEvents/   # All serializable network events
├── View/
│   ├── GUI/             # JavaFX screens (Login, Totem, Main, Leaderboard)
│   └── TUI/             # Text renderer with JLine
├── ServerLauncher.java
├── ClientLauncherGUI.java
└── ClientLauncherTUI.java

Persistence — Technical Details

The save file is created in the directory from which the server JAR is launched:

./GameSaves/save.dat

To force a new game (ignoring the save) simply delete this file before starting the server.



Mesos — Ingegneria del Software 2026

Gruppo GC14 — Pirrera · Radice · Pagani · Pellegrino


Funzionalità implementate

Funzionalità Stato
Regole complete del gioco
Interfaccia TUI (Text User Interface)
Interfaccia GUI (JavaFX)
Rete — RMI
Rete — Socket/TCP
FA1 — Persistenza
FA2 — Resilienza alla disconnessione

Note sulle funzionalità avanzate

FA1 — Persistenza Il server salva automaticamente lo stato della partita su disco (GameSaves/save.dat) dopo ogni evento di gioco. Se il server viene riavviato, la partita salvata viene ripristinata automaticamente e i client possono riconnettersi. Il salvataggio viene scartato solo se al momento del crash erano disconnessi tutti i giocatori tranne al massimo uno.

FA2 — Resilienza alla disconnessione Un client che perde la connessione viene marcato come disconnesso ma non termina la partita. La partita continua con gli altri giocatori. Il giocatore disconnesso può riconnettersi in qualsiasi momento con lo stesso username e ritrovare la partita nello stato corrente.


Requisiti di sistema

  • Java 25 o superiore
  • I JAR sono fat-jar (tutte le dipendenze incluse), non è necessario installare librerie esterne

Avvio — Server

java -jar Server.jar

All'avvio il server elenca le interfacce di rete IPv4 attive e chiede all'operatore di sceglierne una (necessario per il corretto funzionamento di RMI in rete locale). Se è presente una sola interfaccia, viene selezionata automaticamente.

Esempio di output:

[0] eth0 -> 192.168.1.10
[1] eth1 -> 192.168.95.7
Choose interface: 0
192.168.1.10
Server RMI: 192.168.1.10

Porte utilizzate dal server (non devono essere bloccate dal firewall):

Protocollo Porta
RMI registry 1099
TCP gioco 8080
TCP heartbeat 8081

Avvio — Client TUI

java -jar ClientTUI.jar

All'avvio il client chiede interattivamente:

Campo Valori accettati
Username stringa libera, max 10 caratteri
Number of players [2-5] intero tra 2 e 5
Network [rmi/tcp] rmi oppure tcp
Server IP [localhost] indirizzo IP del server; invio vuoto usa localhost

Comandi disponibili in-game (TUI)

Comando Descrizione
slot <pos> Sposta il totem nello slot in posizione <pos>
draw upper tribe <pos> Pesca la carta tribù in posizione <pos> dalla riga superiore
draw upper building <pos> Pesca la carta edificio in posizione <pos> dalla riga superiore
draw lower tribe <pos> Pesca la carta tribù in posizione <pos> dalla riga inferiore
draw lower building <pos> Pesca la carta edificio in posizione <pos> dalla riga inferiore
totem <pos> Sceglie il totem in posizione <pos> (fase di selezione totem)
skip Passa il turno (se non si possono eseguire altre azioni)
clear Ridisegna la board a schermo
details buildings Mostra la descrizione di tutti gli edifici
details events Mostra la descrizione di tutti gli eventi
details characters Mostra la descrizione di tutti i personaggi
rematch Torna alla schermata di login (solo a fine partita)
quit Disconnette e chiude il client

La TUI supporta il completamento automatico con Tab per tutti i comandi.


Avvio — Client GUI

java -jar ClientGUI.jar

Si apre direttamente la finestra grafica. Compilare i campi nella schermata di login:

  • Username — nome del giocatore
  • N. players — numero di giocatori (25)
  • Protocollo — toggle RMI / TCP (click per cambiare)
  • Server IP — indirizzo IP del server

Premere Accedi per connettersi. La GUI si avvia in modalità fullscreen; premere ESC per uscire dal fullscreen e F11 per rientrarci.


Test in locale (tutti su localhost)

  1. Aprire un terminale e avviare il server:

    java -jar Server.jar
    
  2. Aprire N terminali (uno per client) e avviare i client:

    # TUI
    java -jar ClientTUI.jar
    
    # oppure GUI
    java -jar ClientGUI.jar
    
  3. Non appena il numero di giocatori configurato si è connesso, la partita parte automaticamente.


Test in rete locale

  1. Il server gira sulla macchina con IP es. 192.168.1.10.
  2. Avviare il server e scegliere l'interfaccia 192.168.1.10.
  3. I client su altre macchine inseriscono quell'IP come Server IP.
  4. Assicurarsi che le porte 1099, 8080, 8081 siano raggiungibili dalla rete.

Struttura del progetto

src/main/java/it/polimi/ingsw/gc14/
├── Controller/          # GameController (server) e ClientController (client)
├── Model/               # Entità di gioco: Player, Game, Board, Card, Slot, ...
│   ├── Cards/           # BuildingCard, TribeCard, EventCard, Character
│   ├── GamePackage/     # Board, CurrentState, GameStages
│   └── Orders/          # Logica di ordinamento dei giocatori
├── Network/             # Protocolli di rete
│   ├── RMI/             # Client e server RMI
│   ├── TCP/             # Client e server TCP
│   └── NetworkEvents/   # Tutti gli eventi di rete serializzabili
├── View/
│   ├── GUI/             # Schermate JavaFX (Login, Totem, Main, Leaderboard)
│   └── TUI/             # Renderer testuale con JLine
├── ServerLauncher.java
├── ClientLauncherGUI.java
└── ClientLauncherTUI.java

Persistenza — dettagli tecnici

Il file di salvataggio viene creato nella directory da cui si lancia il JAR del server:

./GameSaves/save.dat

Per forzare una partita nuova (ignorando il salvataggio) è sufficiente eliminare questo file prima di avviare il server.