179 lines
5.4 KiB
Markdown
179 lines
5.4 KiB
Markdown
# 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
|
||
|
||
```bash
|
||
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
|
||
|
||
```bash
|
||
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
|
||
|
||
```bash
|
||
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 (2–5)
|
||
- **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:
|
||
```bash
|
||
java -jar Server.jar
|
||
```
|
||
|
||
2. Open N terminals (one per client) and start the clients:
|
||
```bash
|
||
# 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.
|
||
|
||
--- |