FIx: Fixed Coverage Screenshots And htmlRepot.
This commit is contained in:
@@ -0,0 +1,317 @@
|
||||
|
||||
|
||||
|
||||
<!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/22)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Controller;
|
||||
|
||||
import it.polimi.ingsw.gc14.ErrorType;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
|
||||
/**
|
||||
* Controller responsible for coordinating the client-side components,
|
||||
* including the view, the network client and the local mini model.
|
||||
*
|
||||
* <p>It receives user actions from the view, performs basic client-side
|
||||
* checks and forwards valid requests to the network client.
|
||||
*/
|
||||
public class ClientController {
|
||||
|
||||
/** Local mini model representing the client-side game state. */
|
||||
private MiniModel miniModel;
|
||||
|
||||
/** View of the client. */
|
||||
private final IView view;
|
||||
|
||||
/** Network client, either TCP or RMI. */
|
||||
private IClient client;
|
||||
|
||||
/** Username associated with this client. */
|
||||
private String myUsername;
|
||||
|
||||
/**
|
||||
* Constructs a client controller with the specified view.
|
||||
*
|
||||
* <p>The network client is initially unset and an empty local mini model
|
||||
* is created.
|
||||
*
|
||||
* @param view the client view, either TUI or GUI.
|
||||
*/
|
||||
<b class="nc"> public ClientController(IView view) {</b>
|
||||
<b class="nc"> this.view = view;</b>
|
||||
<b class="nc"> this.client = null;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local mini model.
|
||||
*
|
||||
* @return the local mini model.
|
||||
*/
|
||||
public MiniModel getMiniModel() {
|
||||
<b class="nc"> return miniModel;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the client view.
|
||||
*
|
||||
* @return the client view.
|
||||
*/
|
||||
public IView getView() {
|
||||
<b class="nc"> return view;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username associated with this client.
|
||||
*
|
||||
* @return the username.
|
||||
*/
|
||||
public String getMyUsername() {
|
||||
<b class="nc"> return myUsername;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the network client.
|
||||
*
|
||||
* @param client the client to set, either TCP or RMI.
|
||||
*/
|
||||
public void setClient(IClient client) {
|
||||
<b class="nc"> this.client = client;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the network client.
|
||||
*
|
||||
* @return client return the client, either TCP or RMI.
|
||||
*/
|
||||
public IClient getClient() {
|
||||
<b class="nc"> return this.client;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the local mini model and updates the view accordingly.
|
||||
*
|
||||
* @param model the mini model to set.
|
||||
*/
|
||||
public void setModel(MiniModel model) {
|
||||
<b class="nc"> this.miniModel = model;</b>
|
||||
<b class="nc"> view.setModel(miniModel);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username associated with this client.
|
||||
*
|
||||
* @param username the username to set.
|
||||
*/
|
||||
public void setMyUsername(String username) {
|
||||
<b class="nc"> this.myUsername = username;</b>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requests to draw a tribe card from the upper list.
|
||||
*
|
||||
* <p>The request is forwarded to the network client; the server validates it.
|
||||
*
|
||||
* @param pos the index of the card to draw.
|
||||
*/
|
||||
public void drawUpperTribeCard(int pos) {
|
||||
<b class="nc"> client.drawUpperTribeCard(myUsername, pos);</b>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests to draw a tribe card from the lower list.
|
||||
*
|
||||
* <p>The request is forwarded to the network client; the server validates it.
|
||||
*
|
||||
* @param pos the index of the card to draw.
|
||||
*/
|
||||
public void drawLowerTribeCard(int pos) {
|
||||
<b class="nc"> client.drawLowerTribeCard(myUsername, pos);</b>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests to draw a building card from the upper list.
|
||||
*
|
||||
* <p>The request is forwarded to the network client; the server validates it.
|
||||
*
|
||||
* @param pos the index of the card to draw.
|
||||
*/
|
||||
public void drawUpperBuildingCard(int pos) {
|
||||
<b class="nc"> client.drawUpperBuildingCard(myUsername, pos);</b>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests to draw a building card from the lower list.
|
||||
*
|
||||
* <p>The request is forwarded to the network client; the server validates it.
|
||||
*
|
||||
* @param pos the index of the card to draw.
|
||||
*/
|
||||
public void drawLowerBuildingCard(int pos) {
|
||||
<b class="nc"> client.drawLowerBuildingCard(myUsername, pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests to skip the current turn.
|
||||
*
|
||||
* <p>The request is forwarded to the network client; the server validates it.
|
||||
*/
|
||||
public void skipTurn() {
|
||||
<b class="nc"> client.skipTurn(myUsername);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the selection of a slot by the specified player.
|
||||
*
|
||||
* <p>The request is forwarded to the network client; the server validates it.
|
||||
*
|
||||
* @param pos the index of the selected slot.
|
||||
*/
|
||||
public void slotChoice(int pos) {
|
||||
<b class="nc"> client.slotChoice(myUsername, pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the selection of a totem by the specified player.
|
||||
*
|
||||
* <p>If the specified player is not the current player, an error message
|
||||
* is shown. Otherwise, the selected totem is retrieved from the available
|
||||
* totems list and the choice is forwarded to the network client.
|
||||
*
|
||||
* @param pos the index of the selected totem in the available totems list.
|
||||
*/
|
||||
public void totemChoice(int pos) {
|
||||
<b class="nc"> if (miniModel == null || miniModel.availableTotems == null</b>
|
||||
<b class="nc"> || pos < 0 || pos >= miniModel.availableTotems.size()) {</b>
|
||||
<b class="nc"> view.showError(ErrorType.WRONG_ACTION, "ERROR: Invalid Totem Choice");</b>
|
||||
return;
|
||||
}
|
||||
<b class="nc"> client.totemChoice(myUsername, String.valueOf(miniModel.availableTotems.get(pos)));</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the server of a voluntary disconnection and closes the
|
||||
* network client connection.
|
||||
*/
|
||||
public void disconnect()
|
||||
{
|
||||
<b class="nc"> client.notifyDisconnection();</b>
|
||||
}
|
||||
}
|
||||
</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,338 @@
|
||||
|
||||
|
||||
|
||||
<!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">
|
||||
95.5%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(21/22)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
95.9%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(47/49)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Controller;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Totems;
|
||||
|
||||
/**
|
||||
* Controller responsible for managing interactions with the {@link Game} model.
|
||||
*
|
||||
* <p>It provides methods to update the game state by delegating player-related
|
||||
* actions and game actions to the underlying model.
|
||||
*/
|
||||
public class GameController {
|
||||
|
||||
/**
|
||||
* The game model managed by this controller.
|
||||
*/
|
||||
private Game model;
|
||||
|
||||
/**
|
||||
* Creates a GameController associated with the specified game model.
|
||||
*
|
||||
* @param model the game model managed by this controller.
|
||||
*/
|
||||
<b class="fc"> public GameController(Game model) {</b>
|
||||
<b class="fc"> this.model = model;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a GameController without an associated game model.
|
||||
*/
|
||||
<b class="fc"> public GameController() {</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the player associated with the specified username as disconnected.
|
||||
*
|
||||
* @param username the username of the player who disconnected.
|
||||
* @return {@code true} if the disconnection is handled successfully,
|
||||
* {@code false} if no player with the specified username exists
|
||||
* or if the operation fails.
|
||||
*/
|
||||
public synchronized boolean disconnectedPlayer(String username)
|
||||
{
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(username);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.disconnectedPlayer(player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the player associated with the specified username as reconnected.
|
||||
*
|
||||
* @param username the username of the player who reconnected.
|
||||
* @return {@code true} if the reconnection is handled successfully,
|
||||
* {@code false} if no player with the specified username exists
|
||||
* or if the operation fails.
|
||||
*/
|
||||
public synchronized boolean reconnectPlayer(String username)
|
||||
{
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(username);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.reconnectPlayer(player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the game model managed by this controller.
|
||||
*
|
||||
* @return the game model managed by this controller.
|
||||
*/
|
||||
public synchronized Game getModel() {
|
||||
<b class="fc"> return model;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the game model managed by this controller.
|
||||
*
|
||||
* @param model the new game model managed by this controller.
|
||||
*/
|
||||
public synchronized void setModel(Game model) {
|
||||
<b class="fc"> this.model = model;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to add a new player with the specified username to the game model.
|
||||
*
|
||||
* @param username the username of the player to add.
|
||||
* @return {@code true} if the player is successfully added,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public synchronized boolean addPlayer(String username) {
|
||||
<b class="pc"> if(username.trim().length()>10)</b>
|
||||
<b class="nc"> return false;</b>
|
||||
<b class="fc"> Player player = model.getPlayerByUsername(username);</b>
|
||||
<b class="fc"> if(player!=null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> player = new Player(username);</b>
|
||||
<b class="fc"> return model.addPlayer(player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to draw an upper tribe card for the specified player
|
||||
* from the specified position.
|
||||
*
|
||||
* @param playerUsername the username of the player performing the action.
|
||||
* @param pos the position of the upper tribe card to draw.
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public synchronized boolean drawUpperTribeCard(String playerUsername,int pos) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.drawUpperTribeCardByIndex(player, pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to draw a lower tribe card for the specified player
|
||||
* from the specified position.
|
||||
*
|
||||
* @param playerUsername the username of the player performing the action.
|
||||
* @param pos the position of the lower tribe card to draw.
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public synchronized boolean drawLowerTribeCard(String playerUsername,int pos) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.drawLowerTribeCardByIndex(player, pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to draw an upper building card for the specified player
|
||||
* from the specified position.
|
||||
*
|
||||
* @param playerUsername the username of the player performing the action.
|
||||
* @param pos the position of the upper building card to draw.
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public synchronized boolean drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.drawUpperBuildingCardByIndex(player, pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to draw a lower building card for the specified player
|
||||
* from the specified position.
|
||||
*
|
||||
* @param playerUsername the username of the player performing the action.
|
||||
* @param pos the position of the lower building card to draw.
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public synchronized boolean drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.drawLowerBuildingCardByIndex(player, pos);</b>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Skips the card drawing action for the specified player.
|
||||
*
|
||||
* @param playerUsername the username of the player performing the action.
|
||||
* @return {@code true} if the skip action is valid and successfully performed,
|
||||
* {@code false} if the player does not exist or if the action is not valid.
|
||||
*/
|
||||
public synchronized boolean skipTurn(String playerUsername) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.skipTurn(player);</b>
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to perform the slot choice action for the specified player
|
||||
* at the specified position.
|
||||
*
|
||||
* @param playerUsername the username of the player performing the action.
|
||||
* @param pos the position of the chosen slot.
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the slot choice operation fails.
|
||||
*/
|
||||
public synchronized boolean slotChoice(String playerUsername,int pos) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.slotChoiceByIndex(player, pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the totem choice made by the player associated with the specified username.
|
||||
*
|
||||
* @param playerUsername the username of the player making the choice.
|
||||
* @param totem the name of the selected totem.
|
||||
* @return {@code true} if the choice is handled successfully,
|
||||
* {@code false} if no player with the specified username exists
|
||||
* or if the choice operation fails.
|
||||
*/
|
||||
public synchronized boolean totemChoice(String playerUsername,String totem) {
|
||||
<b class="fc"> Player player= model.getPlayerByUsername(playerUsername);</b>
|
||||
<b class="fc"> if(player==null)</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> return model.totemChoice(player, Totems.valueOf(totem));</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the game due to forfeit: all remaining players are absent,
|
||||
* so the game is terminated and final scores are computed.
|
||||
*/
|
||||
public synchronized void endGameForfeit() {
|
||||
<b class="nc"> model.endGameForfeit();</b>
|
||||
}
|
||||
}
|
||||
</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>
|
||||
Reference in New Issue
Block a user