FIx: Fixed Coverage Screenshots And htmlRepot.

This commit is contained in:
GabrieleRadice
2026-06-19 22:57:43 +02:00
parent a4dc8b2540
commit 0129efe400
316 changed files with 4566 additions and 4497 deletions
@@ -0,0 +1,155 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > CompositeClientBroadcaster</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Network</a>
</div>
<h1>Coverage Summary for Class: CompositeClientBroadcaster (it.polimi.ingsw.gc14.Network)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">CompositeClientBroadcaster</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/3)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/7)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.MiniModel;
&nbsp;import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
&nbsp;import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
&nbsp;
&nbsp;/**
&nbsp; * Forwards every notification to both the RMI and the TCP transport layers.
&nbsp; *
&nbsp; * &lt;p&gt;This follows the Composite pattern: the caller interacts with a single
&nbsp; * broadcaster without knowing which protocols are active underneath.
&nbsp; */
&nbsp;public class CompositeClientBroadcaster {
&nbsp; /** RMI transport used to reach RMI-connected clients. */
&nbsp; private final RMIServer rmiServer;
&nbsp; /** TCP transport used to reach TCP-connected clients. */
&nbsp; private final TCPServer tcpServer;
&nbsp;
&nbsp; /**
&nbsp; * Constructs a composite broadcaster backed by the given RMI and TCP servers.
&nbsp; *
&nbsp; * @param rmiServer the RMI server used to reach RMI clients.
&nbsp; * @param tcpServer the TCP server used to reach TCP clients.
&nbsp; */
<b class="nc">&nbsp; public CompositeClientBroadcaster(RMIServer rmiServer, TCPServer tcpServer) {</b>
<b class="nc">&nbsp; this.rmiServer = rmiServer;</b>
<b class="nc">&nbsp; this.tcpServer = tcpServer;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Forwards the event to both the RMI and the TCP server.
&nbsp; * Each server is responsible for filtering error events to the
&nbsp; * requesting player only.
&nbsp; *
&nbsp; * @param event the network event to broadcast.
&nbsp; */
&nbsp; public void notifyAll(NetworkEvent event) {
<b class="nc">&nbsp; rmiServer.notifyAll(event);</b>
<b class="nc">&nbsp; tcpServer.notifyAll(event);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Forwards the model snapshot to every client on both transports.
&nbsp; *
&nbsp; * @param model the mini model snapshot to broadcast.
&nbsp; */
&nbsp; public void notifyAll(MiniModel model) {
<b class="nc">&nbsp; rmiServer.notifyAll(model);</b>
<b class="nc">&nbsp; tcpServer.notifyAll(model);</b>
&nbsp; }
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>
@@ -0,0 +1,181 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > EventType</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Network</a>
</div>
<h1>Coverage Summary for Class: EventType (it.polimi.ingsw.gc14.Network)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">EventType</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/4)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/16)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network;
&nbsp;
&nbsp; /**
&nbsp; * Represents the different types of network events that can be sent between
&nbsp; * client and server.
&nbsp; */
<b class="nc">&nbsp;public enum EventType {</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to add a player to the game.
&nbsp; */
<b class="nc">&nbsp; ADD_PLAYER(&quot;Add Player Event&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to submit a player&#39;s totem choice.
&nbsp; */
<b class="nc">&nbsp; TOTEM_CHOICE(&quot;Totem Choice&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to submit a player&#39;s slot choice.
&nbsp; */
<b class="nc">&nbsp; SLOT_CHOICE(&quot;Slot Choice&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to draw a tribe card from the upper card list.
&nbsp; */
<b class="nc">&nbsp; DRAW_UPPER_TRIBE(&quot;Drawing Upper Tribe&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to draw a tribe card from the lower card list.
&nbsp; */
<b class="nc">&nbsp; DRAW_LOWER_TRIBE(&quot;Drawing Lower Tribe&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to draw a building card from the upper card list.
&nbsp; */
<b class="nc">&nbsp; DRAW_UPPER_BUILD(&quot;Drawing Upper Build&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to draw a building card from the lower card list.
&nbsp; */
<b class="nc">&nbsp; DRAW_LOWER_BUILD(&quot;Drawing Lower Build&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to skip the current turn or optional action.
&nbsp; */
<b class="nc">&nbsp; SKIP_TURN(&quot;Skip Turn&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to notify that a player has disconnected.
&nbsp; */
<b class="nc">&nbsp; DISCONNECTED_PLAYER(&quot;Disconnected Player&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to notify that a player has reconnected.
&nbsp; */
<b class="nc">&nbsp; RECONNECT_PLAYER(&quot;Reconnect Player&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to apply the transition to the next round.
&nbsp; */
<b class="nc">&nbsp; NEXT_ROUND(&quot;Next Round&quot;),</b>
&nbsp;
&nbsp; /**
&nbsp; * Event used to notify that the game has ended.
&nbsp; */
<b class="nc">&nbsp; ENDED_GAME(&quot;Ended Game&quot;);</b>
&nbsp; /** Human-readable label for this event type, returned by {@link #toString()}. */
&nbsp; private final String description;
<b class="nc">&nbsp; EventType(String description) {</b>
<b class="nc">&nbsp; this.description = description;</b>
&nbsp; }
&nbsp; @Override
&nbsp; public String toString() {
<b class="nc">&nbsp; return description;</b>
&nbsp; }
&nbsp; }
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > InterfaceResolver</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Network</a>
</div>
<h1>Coverage Summary for Class: InterfaceResolver (it.polimi.ingsw.gc14.Network)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Branch, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">InterfaceResolver</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/3)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/26)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/22)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network;
&nbsp;
&nbsp;import java.net.*;
&nbsp;import java.util.Enumeration;
&nbsp;
&nbsp;/** Utility class for resolving the local network interface to use when connecting to a server. */
&nbsp;public class InterfaceResolver {
&nbsp; private InterfaceResolver() {}
&nbsp;
&nbsp; /**
&nbsp; * Returns the local IPv4 address that can reach the given server IP.
&nbsp; *
&nbsp; * &lt;p&gt;If the server is localhost, returns {@code &quot;127.0.0.1&quot;}.
&nbsp; * Otherwise, iterates active non-loopback interfaces to find one on the same subnet;
&nbsp; * falls back to a UDP connect trick if no matching subnet is found.
&nbsp; *
&nbsp; * @param serverIp the server IP address or hostname.
&nbsp; * @return the local IP address string to use for outbound connections.
&nbsp; * @throws Exception if no suitable interface can be determined.
&nbsp; */
&nbsp; public static String resolveLocalInterface(String serverIp) throws Exception {
<b class="nc">&nbsp; if (serverIp.equalsIgnoreCase(&quot;localhost&quot;) || serverIp.startsWith(&quot;127.&quot;) || serverIp.isEmpty()) {</b>
<b class="nc">&nbsp; return &quot;127.0.0.1&quot;;</b>
&nbsp; }
&nbsp;
<b class="nc">&nbsp; InetAddress serverAddr = InetAddress.getByName(serverIp);</b>
<b class="nc">&nbsp; Enumeration&lt;NetworkInterface&gt; ifaces = NetworkInterface.getNetworkInterfaces();</b>
<b class="nc">&nbsp; while (ifaces.hasMoreElements()) {</b>
<b class="nc">&nbsp; NetworkInterface ni = ifaces.nextElement();</b>
<b class="nc">&nbsp; if (!ni.isUp() || ni.isLoopback()) continue;</b>
&nbsp;
<b class="nc">&nbsp; for (InterfaceAddress ia : ni.getInterfaceAddresses()) {</b>
<b class="nc">&nbsp; InetAddress localAddr = ia.getAddress();</b>
<b class="nc">&nbsp; if (!(localAddr instanceof Inet4Address)) continue;</b>
&nbsp;
<b class="nc">&nbsp; int prefix = ia.getNetworkPrefixLength();</b>
<b class="nc">&nbsp; if (sameSubnet(localAddr, serverAddr, prefix)) {</b>
<b class="nc">&nbsp; return localAddr.getHostAddress();</b>
&nbsp; }
&nbsp; }
&nbsp; }
&nbsp;
<b class="nc">&nbsp; try (DatagramSocket socket = new DatagramSocket()) {</b>
<b class="nc">&nbsp; socket.connect(serverAddr, 9);</b>
<b class="nc">&nbsp; return socket.getLocalAddress().getHostAddress();</b>
&nbsp; }
&nbsp; }
&nbsp; /**
&nbsp; * Returns {@code true} if {@code a} and {@code b} share the same subnet given a CIDR {@code prefix} length.
&nbsp; *
&nbsp; * @param a first IPv4 address.
&nbsp; * @param b second IPv4 address.
&nbsp; * @param prefix CIDR prefix length (032).
&nbsp; * @return {@code true} if both addresses belong to the same subnet.
&nbsp; */
&nbsp; private static boolean sameSubnet(InetAddress a, InetAddress b, int prefix) {
<b class="nc">&nbsp; if (prefix &lt; 0 || prefix &gt; 32) return false;</b>
<b class="nc">&nbsp; int maskBits = prefix == 0 ? 0 : (0xFFFFFFFF &lt;&lt; (32 - prefix));</b>
<b class="nc">&nbsp; int addrA = toInt(a.getAddress()) &amp; maskBits;</b>
<b class="nc">&nbsp; int addrB = toInt(b.getAddress()) &amp; maskBits;</b>
<b class="nc">&nbsp; return addrA == addrB;</b>
&nbsp; }
&nbsp; /**
&nbsp; * Converts a 4-byte big-endian IPv4 address array to a signed 32-bit integer.
&nbsp; *
&nbsp; * @param bytes the 4-byte address array.
&nbsp; * @return the corresponding signed integer.
&nbsp; */
&nbsp; private static int toInt(byte[] bytes) {
<b class="nc">&nbsp; return ((bytes[0] &amp; 0xFF) &lt;&lt; 24) |</b>
&nbsp; ((bytes[1] &amp; 0xFF) &lt;&lt; 16) |
&nbsp; ((bytes[2] &amp; 0xFF) &lt;&lt; 8) |
&nbsp; (bytes[3] &amp; 0xFF);
&nbsp; }
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>
@@ -0,0 +1,317 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > NetworkEvent</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Network</a>
</div>
<h1>Coverage Summary for Class: NetworkEvent (it.polimi.ingsw.gc14.Network)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Branch, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">NetworkEvent</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/10)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/2)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/19)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Controller.GameController;
&nbsp;import it.polimi.ingsw.gc14.ErrorType;
&nbsp;import it.polimi.ingsw.gc14.Model.Game;
&nbsp;import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
&nbsp;import it.polimi.ingsw.gc14.Model.MiniModel;
&nbsp;import it.polimi.ingsw.gc14.Model.OrderLogicCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Player;
&nbsp;import it.polimi.ingsw.gc14.Model.Slot;
&nbsp;
&nbsp;import java.io.Serializable;
&nbsp;import java.util.ArrayList;
&nbsp;import java.util.List;
&nbsp;import java.util.Map;
&nbsp;
&nbsp;/**
&nbsp; * Represents an event sent over the network.
&nbsp; *
&nbsp; * &lt;p&gt;A network event contains the information required to identify
&nbsp; * the requested action, determine whether it produced an error,
&nbsp; * and apply it either to the server-side {@link GameController}
&nbsp; * or to the client-side {@link MiniModel}.
&nbsp; */
&nbsp;public abstract class NetworkEvent implements Serializable {
&nbsp;
&nbsp; /** The error type associated with this event; set when the event failed to apply. */
&nbsp; protected ErrorType errorType;
&nbsp;
&nbsp; /**
&nbsp; * Returns the error type associated with this event.
&nbsp; *
&nbsp; * @return the error type, or {@code null} if no error occurred.
&nbsp; */
&nbsp; public ErrorType getErrorType() {
<b class="nc">&nbsp; return errorType;</b>
&nbsp; }
&nbsp; /**
&nbsp; * Username of the player requesting the event.
&nbsp; */
&nbsp; protected final String username;
&nbsp;
&nbsp; /**
&nbsp; * Returns the username of the player requesting the event.
&nbsp; *
&nbsp; * @return the username associated with the event.
&nbsp; */
&nbsp; public String getUsername() {
<b class="nc">&nbsp; return username;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Type of the network event.
&nbsp; */
&nbsp; protected final EventType eventType;
&nbsp;
&nbsp; /**
&nbsp; * Map associating each occupied slot with the corresponding player.
&nbsp; */
&nbsp; protected Map&lt;Slot, Player&gt; slotPlayerMap;
&nbsp;
&nbsp; /**
&nbsp; * Order logic card used to manage the player turn order.
&nbsp; */
&nbsp; protected OrderLogicCard orderLogicCard;
&nbsp;
&nbsp; /**
&nbsp; * Current state of the game associated with the event.
&nbsp; */
&nbsp; protected CurrentState currentState;
&nbsp;
&nbsp; /**
&nbsp; * List of all players.
&nbsp; */
&nbsp; protected List&lt;Player&gt; playerList;
&nbsp;
&nbsp; /**
&nbsp; * Usernames of players currently disconnected from the game.
&nbsp; * Sent with every event so clients always have an up-to-date list.
&nbsp; */
&nbsp; protected ArrayList&lt;String&gt; disconnectedPlayers;
&nbsp;
&nbsp; /**
&nbsp; * Populates this event with the current game state so clients can
&nbsp; * update their local model after receiving it.
&nbsp; * Subclasses that carry extra state (available totems, etc.) override
&nbsp; * this method and call {@code super} first.
&nbsp; *
&nbsp; * @param game the current game model.
&nbsp; * @param disconnectedUsernames usernames of currently disconnected players.
&nbsp; */
&nbsp; public void enrichWithGameState(Game game, ArrayList&lt;String&gt; disconnectedUsernames) {
<b class="nc">&nbsp; setData(game.getSlotMap(), game.getOrderLogicCard(), game.getCurrentState(), game.getPlayers());</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the game data associated with this network event.
&nbsp; *
&nbsp; * @param slotPlayerMap the map associating each slot with the player occupying it.
&nbsp; * @param orderLogicCard the order logic card used to manage turn order.
&nbsp; * @param currentState the current state of the game.
&nbsp; * @param playerList the list of the actual state of the players
&nbsp; */
&nbsp; public void setData(Map&lt;Slot, Player&gt; slotPlayerMap,
&nbsp; OrderLogicCard orderLogicCard,
&nbsp; CurrentState currentState,
&nbsp; List&lt;Player&gt; playerList) {
<b class="nc">&nbsp; this.slotPlayerMap = slotPlayerMap;</b>
<b class="nc">&nbsp; this.orderLogicCard = orderLogicCard;</b>
<b class="nc">&nbsp; this.currentState = currentState;</b>
<b class="nc">&nbsp; this.playerList = playerList;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the type of this event.
&nbsp; *
&nbsp; * @return the event type.
&nbsp; */
&nbsp; public EventType getEventType() {
<b class="nc">&nbsp; return eventType;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Flag indicating whether the event could not be applied successfully.
&nbsp; */
&nbsp; protected boolean isError;
&nbsp;
&nbsp; /**
&nbsp; * Returns whether the event represents an error.
&nbsp; *
&nbsp; * @return {@code true} if the event could not be applied successfully,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; public boolean isError() {
<b class="nc">&nbsp; return isError;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets whether the event represents an error.
&nbsp; *
&nbsp; * @param isError {@code true} if the event could not be applied successfully,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; public void setIsError(boolean isError) {
<b class="nc">&nbsp; this.isError = isError;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Overrides the error type for this event.
&nbsp; *
&nbsp; * @param errorType the error type to set.
&nbsp; */
&nbsp; public void setErrorType(ErrorType errorType) {
<b class="nc">&nbsp; this.errorType = errorType;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Constructs a network event.
&nbsp; *
&nbsp; * @param username the username of the player requesting the event.
&nbsp; * @param eventType the type of the event.
&nbsp; * @param isError {@code true} if the event represents an error,
&nbsp; * {@code false} otherwise.
&nbsp; */
<b class="nc">&nbsp; protected NetworkEvent(String username, EventType eventType, boolean isError, ErrorType errorType) {</b>
<b class="nc">&nbsp; this.username = username;</b>
<b class="nc">&nbsp; this.eventType = eventType;</b>
<b class="nc">&nbsp; this.isError = isError;</b>
<b class="nc">&nbsp; this.errorType = errorType;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns a textual description of the event and its outcome.
&nbsp; *
&nbsp; * @return a string describing the event type and whether it represents an error.
&nbsp; */
&nbsp; @Override
&nbsp; public String toString() {
<b class="nc">&nbsp; if (isError) {</b>
<b class="nc">&nbsp; return &quot;ERROR: &quot; + eventType;</b>
&nbsp; } else {
<b class="nc">&nbsp; return &quot;ACTION: &quot; + eventType;</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies this event to the specified server-side game controller.
&nbsp; *
&nbsp; * @param gameController the game controller on which the event must be applied.
&nbsp; * @return {@code true} if the event is applied successfully,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; public abstract boolean apply(GameController gameController);
&nbsp;
&nbsp; /**
&nbsp; * Applies this event to the specified client-side mini model.
&nbsp; *
&nbsp; * @param model the mini model on which the event must be applied.
&nbsp; */
&nbsp; public abstract void apply(MiniModel model);
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > NetworkConfig</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Network</a>
</div>
<h1>Coverage Summary for Class: NetworkConfig (it.polimi.ingsw.gc14.Network)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
</tr>
<tr>
<td class="name">NetworkConfig</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network;
&nbsp;
&nbsp;/** Shared network constants used by both server and client components. */
&nbsp;public final class NetworkConfig {
&nbsp; /** Port on which the RMI registry listens. */
&nbsp; public static final int RMI_PORT = 1099;
&nbsp; /** Port on which the TCP game server listens. */
&nbsp; public static final int TCP_PORT = 8080;
&nbsp; /** Port on which the TCP heartbeat server listens. */
&nbsp; public static final int HEARTBEAT_PORT = 8081;
&nbsp; /** Milliseconds of silence before a client is considered disconnected. */
&nbsp; public static final long SILENCE_THRESHOLD_MS = 5_000;
&nbsp; /** Milliseconds between keep-alive pings sent by the client. */
&nbsp; public static final long KEEPALIVE_INTERVAL_MS = 3_000;
&nbsp; /** Minimum number of players required to start a game. */
&nbsp; public static final int MIN_PLAYERS = 2;
&nbsp; /** Maximum number of players allowed in a game. */
&nbsp; public static final int MAX_PLAYERS = 5;
&nbsp;
&nbsp; private NetworkConfig() {}
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>
@@ -0,0 +1,146 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > IClient</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Network</a>
</div>
<h1>Coverage Summary for Class: IClient (it.polimi.ingsw.gc14.Network)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
</tr>
<tr>
<td class="name">IClient</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.ErrorType;
&nbsp;
&nbsp;/**
&nbsp; * Defines the operations that a client can request during the game.
&nbsp; */
&nbsp;public interface IClient {
&nbsp;
&nbsp; /**
&nbsp; * Connects the client to the server using the specified username
&nbsp; * and preferred connection type.
&nbsp; *
&nbsp; * @param username the username chosen by the player.
&nbsp; * @param proposedNPlayers the desired number of players proposed by this client.
&nbsp; * @return {@code true} if the connection is established successfully,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; ErrorType connect(String username, int proposedNPlayers);
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a tribe card from the upper tribe card list.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the selected card in the upper tribe card list.
&nbsp; */
&nbsp; void drawUpperTribeCard(String playerUsername, int pos);
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a tribe card from the lower tribe card list.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the selected card in the lower tribe card list.
&nbsp; */
&nbsp; void drawLowerTribeCard(String playerUsername, int pos);
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a building card from the upper building card list.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the selected card in the upper building card list.
&nbsp; */
&nbsp; void drawUpperBuildingCard(String playerUsername, int pos);
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a building card from the lower building card list.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the selected card in the lower building card list.
&nbsp; */
&nbsp; void drawLowerBuildingCard(String playerUsername, int pos);
&nbsp;
&nbsp; /**
&nbsp; * Requests to skip the current player&#39;s optional action.
&nbsp; *
&nbsp; * @param playerUsername the username of the player skipping the action.
&nbsp; */
&nbsp; void skipTurn(String playerUsername);
&nbsp;
&nbsp; /**
&nbsp; * Requests to assign the specified player to a slot.
&nbsp; *
&nbsp; * @param playerUsername the username of the player making the slot choice.
&nbsp; * @param pos the position of the selected slot.
&nbsp; */
&nbsp; void slotChoice(String playerUsername, int pos);
&nbsp;
&nbsp; /**
&nbsp; * Requests to assign the selected totem to the specified player.
&nbsp; *
&nbsp; * @param playerUsername the username of the player making the totem choice.
&nbsp; * @param totem the name of the selected totem.
&nbsp; */
&nbsp; void totemChoice(String playerUsername, String totem);
&nbsp;
&nbsp; /** Notifies the server of a voluntary disconnection and closes the connection. */
&nbsp; void notifyDisconnection();
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>