Add: Added Coverage Screenshots And htlmReport.

This commit is contained in:
GabrieleRadice
2026-06-19 21:50:38 +02:00
parent 6aca188aa3
commit d78b8bbd93
316 changed files with 86329 additions and 0 deletions
@@ -0,0 +1,314 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > ClientController</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.Controller</a>
</div>
<h1>Coverage Summary for Class: ClientController (it.polimi.ingsw.gc14.Controller)</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">ClientController</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/16)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/8)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/21)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Controller;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.MiniModel;
&nbsp;import it.polimi.ingsw.gc14.Network.IClient;
&nbsp;import it.polimi.ingsw.gc14.View.IView;
&nbsp;
&nbsp;
&nbsp;/**
&nbsp; * Controller responsible for coordinating the client-side components,
&nbsp; * including the view, the network client and the local mini model.
&nbsp; *
&nbsp; * &lt;p&gt;It receives user actions from the view, performs basic client-side
&nbsp; * checks and forwards valid requests to the network client.
&nbsp; */
&nbsp;public class ClientController {
&nbsp;
&nbsp; /** Local mini model representing the client-side game state. */
&nbsp; private MiniModel miniModel;
&nbsp;
&nbsp; /** View of the client. */
&nbsp; private IView view;
&nbsp;
&nbsp; /** Network client, either TCP or RMI. */
&nbsp; private IClient client;
&nbsp;
&nbsp; /** Username associated with this client. */
&nbsp; private String myUsername;
&nbsp;
&nbsp; /**
&nbsp; * Constructs a client controller with the specified view.
&nbsp; *
&nbsp; * &lt;p&gt;The network client is initially unset and an empty local mini model
&nbsp; * is created.
&nbsp; *
&nbsp; * @param view the client view, either TUI or GUI.
&nbsp; */
<b class="nc">&nbsp; public ClientController(IView view) {</b>
<b class="nc">&nbsp; this.view = view;</b>
<b class="nc">&nbsp; this.client = null;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the local mini model.
&nbsp; *
&nbsp; * @return the local mini model.
&nbsp; */
&nbsp; public MiniModel getMiniModel() {
<b class="nc">&nbsp; return miniModel;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the client view.
&nbsp; *
&nbsp; * @return the client view.
&nbsp; */
&nbsp; public IView getView() {
<b class="nc">&nbsp; return view;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the username associated with this client.
&nbsp; *
&nbsp; * @return the username.
&nbsp; */
&nbsp; public String getMyUsername() {
<b class="nc">&nbsp; return myUsername;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the network client.
&nbsp; *
&nbsp; * @param client the client to set, either TCP or RMI.
&nbsp; */
&nbsp; public void setClient(IClient client) {
<b class="nc">&nbsp; this.client = client;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Gets the network client.
&nbsp; *
&nbsp; * @return client return the client, either TCP or RMI.
&nbsp; */
&nbsp; public IClient getClient() {
<b class="nc">&nbsp; return this.client;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the local mini model and updates the view accordingly.
&nbsp; *
&nbsp; * @param model the mini model to set.
&nbsp; */
&nbsp; public void setModel(MiniModel model) {
<b class="nc">&nbsp; this.miniModel = model;</b>
<b class="nc">&nbsp; view.setModel(miniModel);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the username associated with this client.
&nbsp; *
&nbsp; * @param username the username to set.
&nbsp; */
&nbsp; public void setMyUsername(String username) {
<b class="nc">&nbsp; this.myUsername = username;</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a tribe card from the upper list.
&nbsp; *
&nbsp; * &lt;p&gt;The request is forwarded to the network client; the server validates it.
&nbsp; *
&nbsp; * @param pos the index of the card to draw.
&nbsp; */
&nbsp; public void drawUpperTribeCard(int pos) {
<b class="nc">&nbsp; client.drawUpperTribeCard(myUsername, pos);</b>
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a tribe card from the lower list.
&nbsp; *
&nbsp; * &lt;p&gt;The request is forwarded to the network client; the server validates it.
&nbsp; *
&nbsp; * @param pos the index of the card to draw.
&nbsp; */
&nbsp; public void drawLowerTribeCard(int pos) {
<b class="nc">&nbsp; client.drawLowerTribeCard(myUsername, pos);</b>
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a building card from the upper list.
&nbsp; *
&nbsp; * &lt;p&gt;The request is forwarded to the network client; the server validates it.
&nbsp; *
&nbsp; * @param pos the index of the card to draw.
&nbsp; */
&nbsp; public void drawUpperBuildingCard(int pos) {
<b class="nc">&nbsp; client.drawUpperBuildingCard(myUsername, pos);</b>
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Requests to draw a building card from the lower list.
&nbsp; *
&nbsp; * &lt;p&gt;The request is forwarded to the network client; the server validates it.
&nbsp; *
&nbsp; * @param pos the index of the card to draw.
&nbsp; */
&nbsp; public void drawLowerBuildingCard(int pos) {
<b class="nc">&nbsp; client.drawLowerBuildingCard(myUsername, pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Requests to skip the current turn.
&nbsp; *
&nbsp; * &lt;p&gt;The request is forwarded to the network client; the server validates it.
&nbsp; */
&nbsp; public void skipTurn() {
<b class="nc">&nbsp; client.skipTurn(myUsername);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Requests the selection of a slot by the specified player.
&nbsp; *
&nbsp; * &lt;p&gt;The request is forwarded to the network client; the server validates it.
&nbsp; *
&nbsp; * @param pos the index of the selected slot.
&nbsp; */
&nbsp; public void slotChoice(int pos) {
<b class="nc">&nbsp; client.slotChoice(myUsername, pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Handles the selection of a totem by the specified player.
&nbsp; *
&nbsp; * &lt;p&gt;If the specified player is not the current player, an error message
&nbsp; * is shown. Otherwise, the selected totem is retrieved from the available
&nbsp; * totems list and the choice is forwarded to the network client.
&nbsp; *
&nbsp; * @param pos the index of the selected totem in the available totems list.
&nbsp; */
&nbsp; public void totemChoice(int pos) {
<b class="nc">&nbsp; if (miniModel == null || miniModel.availableTotems == null</b>
<b class="nc">&nbsp; || pos &lt; 0 || pos &gt;= miniModel.availableTotems.size())</b>
&nbsp; return;
<b class="nc">&nbsp; client.totemChoice(myUsername, String.valueOf(miniModel.availableTotems.get(pos)));</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Notifies the server of a voluntary disconnection and closes the
&nbsp; * network client connection.
&nbsp; */
&nbsp; public void disconnect()
&nbsp; {
<b class="nc">&nbsp; client.notifyDisconnection();</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-14 21:53</div>
</div>
</body>
</html>
@@ -0,0 +1,332 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > GameController</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.Controller</a>
</div>
<h1>Coverage Summary for Class: GameController (it.polimi.ingsw.gc14.Controller)</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">GameController</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
93.3%
</span>
<span class="absValue">
(14/15)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(18/18)
</span>
</td>
<td class="coverageStat">
<span class="percent">
97.7%
</span>
<span class="absValue">
(42/43)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Controller;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Game;
&nbsp;import it.polimi.ingsw.gc14.Model.Player;
&nbsp;import it.polimi.ingsw.gc14.Model.Totems;
&nbsp;
&nbsp;/**
&nbsp; * Controller responsible for managing interactions with the {@link Game} model.
&nbsp; *
&nbsp; * &lt;p&gt;It provides methods to update the game state by delegating player-related
&nbsp; * actions and game actions to the underlying model.
&nbsp; */
&nbsp;public class GameController {
&nbsp;
&nbsp; /**
&nbsp; * The game model managed by this controller.
&nbsp; */
&nbsp; private Game model;
&nbsp;
&nbsp; /**
&nbsp; * Creates a GameController associated with the specified game model.
&nbsp; *
&nbsp; * @param model the game model managed by this controller.
&nbsp; */
<b class="fc">&nbsp; public GameController(Game model) {</b>
<b class="fc">&nbsp; this.model = model;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a GameController without an associated game model.
&nbsp; */
<b class="fc">&nbsp; public GameController() {</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Marks the player associated with the specified username as disconnected.
&nbsp; *
&nbsp; * @param username the username of the player who disconnected.
&nbsp; * @return {@code true} if the disconnection is handled successfully,
&nbsp; * {@code false} if no player with the specified username exists
&nbsp; * or if the operation fails.
&nbsp; */
&nbsp; public synchronized boolean disconnectedPlayer(String username)
&nbsp; {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(username);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.disconnectedPlayer(player);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Marks the player associated with the specified username as reconnected.
&nbsp; *
&nbsp; * @param username the username of the player who reconnected.
&nbsp; * @return {@code true} if the reconnection is handled successfully,
&nbsp; * {@code false} if no player with the specified username exists
&nbsp; * or if the operation fails.
&nbsp; */
&nbsp; public synchronized boolean reconnectPlayer(String username)
&nbsp; {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(username);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.reconnectPlayer(player);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the game model managed by this controller.
&nbsp; *
&nbsp; * @return the game model managed by this controller.
&nbsp; */
&nbsp; public synchronized Game getModel() {
<b class="fc">&nbsp; return model;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Updates the game model managed by this controller.
&nbsp; *
&nbsp; * @param model the new game model managed by this controller.
&nbsp; */
&nbsp; public synchronized void setModel(Game model) {
<b class="fc">&nbsp; this.model = model;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to add a new player with the specified username to the game model.
&nbsp; *
&nbsp; * @param username the username of the player to add.
&nbsp; * @return {@code true} if the player is successfully added,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; public synchronized boolean addPlayer(String username) {
<b class="fc">&nbsp; return model.addPlayer(new Player(username));</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to draw an upper tribe card for the specified player
&nbsp; * from the specified position.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the upper tribe card to draw.
&nbsp; * @return {@code true} if the action succeeds,
&nbsp; * {@code false} if the player does not exist or if the draw operation fails.
&nbsp; */
&nbsp; public synchronized boolean drawUpperTribeCard(String playerUsername,int pos) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.drawUpperTribeCardByIndex(player, pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to draw a lower tribe card for the specified player
&nbsp; * from the specified position.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the lower tribe card to draw.
&nbsp; * @return {@code true} if the action succeeds,
&nbsp; * {@code false} if the player does not exist or if the draw operation fails.
&nbsp; */
&nbsp; public synchronized boolean drawLowerTribeCard(String playerUsername,int pos) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.drawLowerTribeCardByIndex(player, pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to draw an upper building card for the specified player
&nbsp; * from the specified position.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the upper building card to draw.
&nbsp; * @return {@code true} if the action succeeds,
&nbsp; * {@code false} if the player does not exist or if the draw operation fails.
&nbsp; */
&nbsp; public synchronized boolean drawUpperBuildingCard(String playerUsername,int pos) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.drawUpperBuildingCardByIndex(player, pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to draw a lower building card for the specified player
&nbsp; * from the specified position.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the lower building card to draw.
&nbsp; * @return {@code true} if the action succeeds,
&nbsp; * {@code false} if the player does not exist or if the draw operation fails.
&nbsp; */
&nbsp; public synchronized boolean drawLowerBuildingCard(String playerUsername,int pos) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.drawLowerBuildingCardByIndex(player, pos);</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Skips the card drawing action for the specified player.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @return {@code true} if the skip action is valid and successfully performed,
&nbsp; * {@code false} if the player does not exist or if the action is not valid.
&nbsp; */
&nbsp; public synchronized boolean skipTurn(String playerUsername) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.skipTurn(player);</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Attempts to perform the slot choice action for the specified player
&nbsp; * at the specified position.
&nbsp; *
&nbsp; * @param playerUsername the username of the player performing the action.
&nbsp; * @param pos the position of the chosen slot.
&nbsp; * @return {@code true} if the action succeeds,
&nbsp; * {@code false} if the player does not exist or if the slot choice operation fails.
&nbsp; */
&nbsp; public synchronized boolean slotChoice(String playerUsername,int pos) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.slotChoiceByIndex(player, pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the totem choice made by the player associated with the specified username.
&nbsp; *
&nbsp; * @param playerUsername the username of the player making the choice.
&nbsp; * @param totem the name of the selected totem.
&nbsp; * @return {@code true} if the choice is handled successfully,
&nbsp; * {@code false} if no player with the specified username exists
&nbsp; * or if the choice operation fails.
&nbsp; */
&nbsp; public synchronized boolean totemChoice(String playerUsername,String totem) {
<b class="fc">&nbsp; Player player= model.getPlayerByUsername(playerUsername);</b>
<b class="fc">&nbsp; if(player==null)</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; return model.totemChoice(player, Totems.valueOf(totem));</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Ends the game due to forfeit: all remaining players are absent,
&nbsp; * so the game is terminated and final scores are computed.
&nbsp; */
&nbsp; public synchronized void endGameForfeit() {
<b class="nc">&nbsp; model.endGameForfeit();</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-14 21:53</div>
</div>
</body>
</html>