Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #147 from lorenzo-cmyk/just-checking
Browse files Browse the repository at this point in the history
Two known issues up until this point
  • Loading branch information
lorenzo-cmyk authored Jun 20, 2024
2 parents e711226 + bf37082 commit 7c2a848
Show file tree
Hide file tree
Showing 47 changed files with 540 additions and 359 deletions.
Binary file added .github/images/Cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/GUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 27 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,41 @@
# Software Engineering Project - A.A. 2023/2024
# Codex Naturalis 🌿🍄🦋🐺

## AM32 Group
## About

Group members:
<img src=".github/images/Cover.png" width=369px height=auto align="right"/>

Codex Naturalis is the final project of the "Software Engineering" course held at Politecnico di Milano (A.Y. 2023/2024).

The group members are:

- Matteo Bergagna
- Antony Brun
- Lorenzo Chiroli
- Jie Chen
- Matteo Bergagna

## Project Status

### General

| Tasks | Status | Notes |
|------------------------|--------|---------------------------------|
| UML (Class Diagram) | ☑️ | Model + Controller + Networking |
| UML (Sequence Diagram) | ☑️ | Communication Protocol |
| Peer Review 1 | ☑️ | Model |
| Peer Review 2 | ☑️ | Communication Protocol |

### Server
## Game Screenshot
<p align="center">
<img src=".github/images/GUI.png" width=738px height=auto>
</p>

| Feature | Status | Notes |
|------------|--------|----------------|
| Model | ☑️ | Complete Rules |
| Controller | ☑️ | N/A |
| Networking | ☑️ | RMI + Socket |

| Advanced Features | Status | Notes |
|------------------------------|--------|-----------------------|
| Multiple Matches | ☑️ | N/A |
| Resilience to Disconnections | ☑️ | N/A |
| Chat | ☑️ | N/A |
## Project Status

### Client
| Satisfied Requirements | Maximum Grade | Status |
|-----------------------------------------------------------------------------------------------------|---------------|--------|
| Simplified Rules + TUI + RMI or Socket | 18 | ☑️ |
| Complete Rules + TUI + RMI or Socket | 20 | ☑️ |
| Complete Rules + TUI + RMI or Socket + 1 FA (Chat) | 22 | ☑️ |
| Complete Rules + TUI + GUI + RMI or Socket + 1 FA (Chat) | 24 | ☑️ |
| Complete Rules + TUI + GUI + RMI + Socket + 1 FA (Chat) | 27 | ☑️ |
| Complete Rules + TUI + GUI + RMI + Socket + 2 FA (Chat & Multiple match) | 30 | ☑️ |
| Complete Rules + TUI + GUI + RMI + Socket + 3 FA (Chat & Multiple match & Disconnection resilience) | 30L | ⚠️ |

| Feature | Status | Notes |
|------------|--------|------------------|
| Networking | 🕑 | Socket only RN! |
| TUI | ☑️ | N/A |
| GUI | ‼️ | Not yet started! |
### Currently Known Issues

| Advanced Features | Status | Notes |
|------------------------------|--------|----------------|
| Multiple Matches | ☑️ | N/A |
| Resilience to Disconnections | 🕑 | Working on it! |
| Chat | ☑️ | N/A |
- 🟨 The branch with the correct version of the network stack is not yet merged. Therefore, the network is not informing the View if the initial connection was successful or not.
- 🟥 The branch with the correct version of the network stack is not yet merged. Therefore, the network is not activating the PingTask that allows (in both Client & Server) the disconnection discovery in RMI.

## Code Coverage

| Package | Role | Coverage (%Methods) | Coverage (%Line) | Testing Status |
|-------------|----------------------|---------------------|------------------|----------------|
| .model | Game Model | 100% | 97% | Completed ☑️ |
| .chat | Chat Model | 100% | 100% | Completed ☑️ |
| .controller | Game+Chat Controller | 90% | 63% | Ongoing 🕑 |
The average code coverage, between Model and Controller, is 96% for methods and 85% for lines, all (known) edge cases are covered.
The coverage is calculated using the IntelliJ IDEA built-in tool.
20 changes: 12 additions & 8 deletions src/main/java/it/polimi/ingsw/am32/client/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* Enumeration of the possible events that can occur during the game.
*/
public enum Event {
LOBBY(0),
PREPARATION(1),
PLAYING(2),
TERMINATING(3),
LAST_TURN(4),
TERMINATED(5),
LOBBY(0), // STATUS
PREPARATION(1), // STATUS
PLAYING(2), // STATUS
TERMINATING(3), // STATUS
LAST_TURN(4), // STATUS
TERMINATED(5), // STATUS
CHOOSE_CONNECTION (6),
SELECT_GAME_MODE(7),
CREATE_GAME(8),
Expand All @@ -31,12 +31,16 @@ public enum Event {
DRAW_CARD(24),
PLAYER_RECONNECTED(25),
DRAW_CARD_FAILURE(26),
WELCOME(27),
WELCOME(27), // STATUS
SELECTED_STARTER_CARD_SIDE(28),
SELECTED_SECRET_OBJ_CARD(29),
CARD_PLACED(30),
CARD_DRAWN(31),
WAITING_FOR_TURN(32), CHAT_ERROR(33);
WAITING_FOR_TURN(32),
CHAT_ERROR(33),
CREATE_GAME_FAILURE(34),
JOIN_GAME_FAILURE(35),
RECONNECT_GAME_FAILURE(36);

private final int value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public NonObjCardFactory(String cardType,int ID, int Value, String PointStrategy
this.ConditionCount=ConditionCount;
}

/**
* This method is used to create the cards from the JSON file.
* @return an ArrayList containing the cards
*/
public static ArrayList<NonObjCardFactory> setNonObjCardArray() {
// Initialize the ArrayList to store the cards
ArrayList<NonObjCardFactory> NonObjCards = new ArrayList<>();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/it/polimi/ingsw/am32/client/PlayerPub.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void updateResources(int[] resources){
}
/**
* Update the points of the player with the points updated received from the message.
* @param points the new version of the points.
*/
public void updatePoints(int points){
this.points = points;
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/it/polimi/ingsw/am32/client/View.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.polimi.ingsw.am32.client;


import it.polimi.ingsw.am32.network.exceptions.ConnectionSetupFailedException;
import it.polimi.ingsw.am32.utilities.IsValid;
import it.polimi.ingsw.am32.client.listener.AskListener;
import it.polimi.ingsw.am32.message.ClientToServer.CtoSLobbyMessage;
Expand All @@ -9,7 +10,6 @@
import it.polimi.ingsw.am32.network.ClientNode.RMIClientNode;
import it.polimi.ingsw.am32.network.ClientNode.SKClientNode;

import java.io.IOException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -170,26 +170,26 @@ public View() {
* Also, it creates a new thread to listen for messages from the client.
* @param serverIP The IP address of the server.
* @param port The port number of the server.
* @throws IOException If an I/O error occurs when creating the socket.
* @throws ConnectionSetupFailedException if the connection setup fails.
*/
public void setSocketClient(String serverIP, int port) throws IOException {
public void setSocketClient(String serverIP, int port) throws ConnectionSetupFailedException {
SKClientNode clientNode = new SKClientNode(this,serverIP,port);
this.clientNode = clientNode;
clientNode.startConnection();
this.askListener = new AskListener(clientNode);

this.askListener = new AskListener(clientNode);
Thread askListener = new Thread(this.askListener); // Create a new thread listen for messages from the client
askListener.start();
//TODO verify if this is correct
}

/**
* This method is used to set up an RMI client with the specified server IP and port.
* Also, it creates a new thread to listen for messages from the client.
* @param serverIP The IP address of the server.
* @param port The port number of the server.
* @throws ConnectionSetupFailedException if the connection setup fails.
*/
public void setRMIClient(String serverIP, int port) {
//TODO verify if this is correct
public void setRMIClient(String serverIP, int port) throws ConnectionSetupFailedException {
try{
RMIClientNode clientNode = new RMIClientNode(this, serverIP, port);
this.clientNode = clientNode;
Expand All @@ -199,7 +199,7 @@ public void setRMIClient(String serverIP, int port) {
Thread askListenerThread = new Thread(this.askListener);
askListenerThread.start();
}catch (RemoteException e) {
//TODO
throw new ConnectionSetupFailedException();
}
}
/**
Expand Down Expand Up @@ -514,6 +514,10 @@ public abstract void updateRollback(String playerNickname, int removedCard, int
* @param nickname The nickname of the player will be used to handle the event.
*/
public abstract void handleEvent(Event event, String nickname);

public abstract void nodeDisconnected();

public abstract void nodeReconnected();
}


12 changes: 8 additions & 4 deletions src/main/java/it/polimi/ingsw/am32/client/view/gui/ChatArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

import java.util.ArrayList;


/**
* This class represents the chat area in the GUI.
* It contains the message display area, the message input area, and the submit button.
* It also contains a combo box that allows the user to select a recipient for the message.
*/
public class ChatArea {
/**
* An object representing the chat area in the GUI
Expand Down Expand Up @@ -45,7 +49,7 @@ public class ChatArea {

/**
* Constructor for the ChatArea class
*
* @param gui A reference to the GUI
* @param X X coordinate of the chat area
* @param Y Y coordinate of the chat area
* @param width Width of the chat area
Expand Down Expand Up @@ -136,8 +140,8 @@ private void initializeChatArea(int X, int Y, int width, int height, ArrayList<S
* Adds an incoming message to the chat area send from another player.
* The message is appended to the end of the message display area.
* Called by outside classes to add messages to the chat area.
*
* @param message The message to be added
* @param message The message to be added.
* @param senderNickname The nickname of the player who sent the message.
*/
public void addIncomingMessageToChat(String message, String senderNickname) {
String sender = senderNickname.equals(gui.getThisPlayerNickname())?"Yourself": senderNickname;
Expand Down
Loading

0 comments on commit 7c2a848

Please sign in to comment.