Files
Progetto-ingegneria-del-sof…/deliverables/Coverage/htmlReport/ns-d/sources/source-c.html
T
2026-06-19 21:50:38 +02:00

211 lines
5.9 KiB
HTML

<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > TotemChoice</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.NetworkEvents</a>
</div>
<h1>Coverage Summary for Class: TotemChoice (it.polimi.ingsw.gc14.Network.NetworkEvents)</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">TotemChoice</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/5)
</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/17)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Network.NetworkEvents;
&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.MiniModel;
&nbsp;import it.polimi.ingsw.gc14.Model.Totems;
&nbsp;import it.polimi.ingsw.gc14.Network.EventType;
&nbsp;import it.polimi.ingsw.gc14.Network.NetworkEvent;
&nbsp;
&nbsp;import java.io.Serializable;
&nbsp;import java.util.ArrayList;
&nbsp;import java.util.List;
&nbsp;
&nbsp;/**
&nbsp; * Network event used to handle a player&#39;s totem choice.
&nbsp; */
&nbsp;public class TotemChoice extends NetworkEvent implements Serializable {
&nbsp;
&nbsp; /**
&nbsp; * Name of the totem selected by the player.
&nbsp; */
&nbsp; private String totem;
&nbsp;
&nbsp; /**
&nbsp; * List of totems still available after the choice has been processed.
&nbsp; */
&nbsp; private List&lt;Totems&gt; availableTotems;
&nbsp;
&nbsp; /**
&nbsp; * Sets the list of currently available totems.
&nbsp; *
&nbsp; * @param availableTotems the totems still available for selection.
&nbsp; */
&nbsp; public void setAvailableTotems(List&lt;Totems&gt; availableTotems) {
<b class="nc">&nbsp; this.availableTotems = availableTotems;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Constructs a totem choice event for the specified player.
&nbsp; *
&nbsp; * @param username the username of the player making the choice.
&nbsp; * @param totem the name of the selected totem.
&nbsp; */
&nbsp; public TotemChoice(String username, String totem) {
<b class="nc">&nbsp; super(username, EventType.TOTEM_CHOICE, false, ErrorType.WRONG_ACTION);</b>
<b class="nc">&nbsp; this.totem = totem;</b>
&nbsp; }
&nbsp;
&nbsp; @Override
&nbsp; public void enrichWithGameState(Game game, ArrayList&lt;String&gt; disconnectedUsernames) {
<b class="nc">&nbsp; super.enrichWithGameState(game, disconnectedUsernames);</b>
<b class="nc">&nbsp; this.availableTotems = game.getAvailableTotems();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the totem choice event to the server-side game controller.
&nbsp; *
&nbsp; * @param gameController the game controller on which to apply the event.
&nbsp; * @return {@code true} if the totem choice is handled successfully,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; @Override
&nbsp; public boolean apply(GameController gameController) {
<b class="nc">&nbsp; return gameController.totemChoice(username, totem);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the totem choice update to the client-side mini model.
&nbsp; *
&nbsp; * &lt;p&gt;If the event does not represent an error, the player data,
&nbsp; * turn order, current game state, slot assignments, and available
&nbsp; * totems are updated.
&nbsp; *
&nbsp; * @param miniModel the mini model on which to apply the event.
&nbsp; * @return {@code true} if the update is applied successfully,
&nbsp; * {@code false} if the event represents an error.
&nbsp; */
&nbsp; @Override
&nbsp; public boolean apply(MiniModel miniModel) {
<b class="nc">&nbsp; synchronized (miniModel) {</b>
<b class="nc">&nbsp; if (isError)</b>
<b class="nc">&nbsp; return false;</b>
&nbsp;
<b class="nc">&nbsp; miniModel.setPlayers(playerList);</b>
<b class="nc">&nbsp; miniModel.setOrderLogicCard(orderLogicCard);</b>
<b class="nc">&nbsp; miniModel.setCurrentState(currentState);</b>
<b class="nc">&nbsp; miniModel.setSlotPlayerMap(slotPlayerMap);</b>
<b class="nc">&nbsp; miniModel.setAvailableTotems(availableTotems);</b>
<b class="nc">&nbsp; miniModel.setLastEvent(this);</b>
<b class="nc">&nbsp; return true;</b>
<b class="nc">&nbsp; }</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>