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,405 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > DecksCreator</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.Model</a>
</div>
<h1>Coverage Summary for Class: DecksCreator (it.polimi.ingsw.gc14.Model)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Branch, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">DecksCreator</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(7/7)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(57/57)
</span>
</td>
<td class="coverageStat">
<span class="percent">
88.6%
</span>
<span class="absValue">
(70/79)
</span>
</td>
</tr>
<tr>
<td class="name">DecksCreator$1</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
</tr>
<tr>
<td class="name">DecksCreator$2</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
</tr>
<tr>
<td class="name">DecksCreator$BuildingCardDefinition</td>
</tr>
<tr>
<td class="name">DecksCreator$TribeCardDefinition</td>
</tr>
<tr>
<td class="name"><strong>Total</strong></td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(9/9)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(57/57)
</span>
</td>
<td class="coverageStat">
<span class="percent">
88.9%
</span>
<span class="absValue">
(72/81)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;
&nbsp;import com.google.gson.*;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.*;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.CavePaintings;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Sustenance;
&nbsp;
&nbsp;import java.io.*;
&nbsp;import java.lang.reflect.Type;
&nbsp;import java.util.*;
&nbsp;
&nbsp;/**
&nbsp; * Utility class responsible for loading and creating decks of cards and slots for the game.
&nbsp; * Cards are loaded from JSON resource files and instantiated according to their type and parameters.
&nbsp; */
&nbsp;public class DecksCreator {
&nbsp;
&nbsp; private DecksCreator() {}
&nbsp;
&nbsp; /**
&nbsp; * Loads the tribe card deck for the specified era from the corresponding JSON resource file.
&nbsp; *
&nbsp; * @param era the era number (1, 2, or 3).
&nbsp; * @return a list of {@link TribeCard} objects for the specified era.
&nbsp; * @throws IllegalArgumentException if {@code era} is not 1, 2, or 3.
&nbsp; */
&nbsp; public static List&lt;TribeCard&gt; loadTribeDeckByEra(int era) throws IllegalArgumentException
&nbsp; {
<b class="fc">&nbsp; return switch (era) {</b>
<b class="fc">&nbsp; case 1 -&gt; loadTribeDeck(&quot;/Cards/tribe_era1.json&quot;);</b>
<b class="fc">&nbsp; case 2 -&gt; loadTribeDeck(&quot;/Cards/tribe_era2.json&quot;);</b>
<b class="fc">&nbsp; case 3 -&gt; loadTribeDeck(&quot;/Cards/tribe_era3.json&quot;);</b>
<b class="fc">&nbsp; default -&gt; throw new IllegalArgumentException();</b>
&nbsp; };
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Loads a tribe card deck from the specified JSON resource file path.
&nbsp; *
&nbsp; * @param resourcePath the path to the JSON resource file.
&nbsp; * @return a list of {@link TribeCard} objects defined in the resource file.
&nbsp; * @throws RuntimeException if the resource file is not found or an error occurs while reading it.
&nbsp; */
&nbsp; public static List&lt;TribeCard&gt; loadTribeDeck(String resourcePath) {
<b class="fc">&nbsp; Gson gson = new Gson();</b>
<b class="fc">&nbsp; Type listType = new com.google.gson.reflect.TypeToken&lt;List&lt;TribeCardDefinition&gt;&gt;(){}.getType();</b>
&nbsp;
<b class="fc">&nbsp; InputStream is = DecksCreator.class.getResourceAsStream(resourcePath);</b>
<b class="fc">&nbsp; if (is == null) {</b>
<b class="fc">&nbsp; throw new RuntimeException(&quot;Resource file not found: &quot; + resourcePath);</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; try (Reader reader = new InputStreamReader(is)) {</b>
<b class="fc">&nbsp; List&lt;TribeCardDefinition&gt; definitions = gson.fromJson(reader, listType);</b>
<b class="fc">&nbsp; List&lt;TribeCard&gt; cards = new ArrayList&lt;&gt;();</b>
<b class="fc">&nbsp; for (TribeCardDefinition def : definitions) {</b>
<b class="fc">&nbsp; cards.add(createCard(def));</b>
&nbsp; }
<b class="fc">&nbsp; return cards;</b>
&nbsp; } catch (IOException e) {
<b class="nc">&nbsp; throw new RuntimeException(&quot;Error loading deck: &quot; + resourcePath, e);</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Loads the building card deck for the specified era, filtering cards from the global building deck.
&nbsp; *
&nbsp; * @param era the era number (1, 2, or 3).
&nbsp; * @return a list of {@link BuildingCard} objects belonging to the specified era.
&nbsp; * @throws IllegalArgumentException if {@code era} is not 1, 2, or 3.
&nbsp; */
&nbsp; public static List&lt;BuildingCard&gt; loadBuildingDeckByEra(int era) throws IllegalArgumentException
&nbsp; {
<b class="fc">&nbsp; if(era&lt;=0 || era&gt;3) throw new IllegalArgumentException();</b>
<b class="fc">&nbsp; return loadBuildingDeck(&quot;/Cards/buildingCards.json&quot;).stream().filter(x-&gt;x.getEra()==era).toList();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Loads the full building card deck from the specified JSON resource file path.
&nbsp; *
&nbsp; * @param resourcePath the path to the JSON resource file.
&nbsp; * @return a list of {@link BuildingCard} objects defined in the resource file.
&nbsp; * @throws RuntimeException if the resource file is not found or an error occurs while reading it.
&nbsp; */
&nbsp; public static List&lt;BuildingCard&gt; loadBuildingDeck(String resourcePath) {
<b class="fc">&nbsp; Gson gson = new Gson();</b>
<b class="fc">&nbsp; Type listType = new com.google.gson.reflect.TypeToken&lt;List&lt;BuildingCardDefinition&gt;&gt;(){}.getType();</b>
&nbsp;
<b class="fc">&nbsp; InputStream is = DecksCreator.class.getResourceAsStream(resourcePath);</b>
<b class="fc">&nbsp; if (is == null) {</b>
<b class="fc">&nbsp; throw new RuntimeException(&quot;Resource file not found: &quot; + resourcePath);</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; try (Reader reader = new InputStreamReader(is)) {</b>
<b class="fc">&nbsp; List&lt;BuildingCardDefinition&gt; definitions = gson.fromJson(reader, listType);</b>
<b class="fc">&nbsp; List&lt;BuildingCard&gt; cards = new ArrayList&lt;&gt;();</b>
<b class="fc">&nbsp; for (BuildingCardDefinition def : definitions) {</b>
<b class="fc">&nbsp; cards.add(createCard(def));</b>
&nbsp; }
<b class="fc">&nbsp; return cards;</b>
&nbsp; } catch (IOException e) {
<b class="nc">&nbsp; throw new RuntimeException(&quot;Error loading deck: &quot; + resourcePath, e);</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates and returns the list of slots used as the game board.
&nbsp; * Slots are labeled with the letters A through G.
&nbsp; *
&nbsp; * @return a list of {@link Slot} objects representing the game board.
&nbsp; */
&nbsp; public static List&lt;Slot&gt; loadSlotDeck()
&nbsp; {
<b class="fc">&nbsp; List&lt;Slot&gt; slots = new ArrayList&lt;&gt;();</b>
<b class="fc">&nbsp; char[]chars={&#39;A&#39;,&#39;B&#39;,&#39;C&#39;,&#39;D&#39;,&#39;E&#39;,&#39;F&#39;,&#39;G&#39;};</b>
<b class="fc">&nbsp; for(char c : chars)</b>
<b class="fc">&nbsp; slots.add(new Slot(c));</b>
<b class="fc">&nbsp; return slots;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Instantiates a {@link TribeCard} from the given definition.
&nbsp; * Depending on whether the card is an event or a character, the appropriate subclass is created
&nbsp; * using the type and parameters specified in the definition.
&nbsp; *
&nbsp; * @param def the {@link TribeCardDefinition} containing the card&#39;s type, era, and parameters.
&nbsp; * @return the instantiated {@link TribeCard}.
&nbsp; * @throws IllegalArgumentException if the card type is unknown or the parameters are invalid.
&nbsp; */
&nbsp; private static TribeCard createCard(TribeCardDefinition def) {
<b class="fc">&nbsp; int era = def.era;</b>
<b class="fc">&nbsp; int[] p = def.params.stream().mapToInt(d -&gt; ((Double) d).intValue()).toArray();</b>
<b class="fc">&nbsp; if(def.isEvent)</b>
&nbsp; {
<b class="pc">&nbsp; return switch (def.type) {</b>
<b class="fc">&nbsp; case &quot;Sustenance&quot; -&gt; new Sustenance(def.id,era,p[0]);</b>
<b class="fc">&nbsp; case &quot;Hunt&quot; -&gt; new Hunt(def.id,era,p[0]);</b>
<b class="fc">&nbsp; case &quot;CavePaintings&quot; -&gt; new CavePaintings(def.id,era,p[0],p[1],p[2]);</b>
<b class="fc">&nbsp; case &quot;ShamanicRitual&quot; -&gt; new ShamanicRitual(def.id,era,p[0],p[1]);</b>
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Unknown event type: &quot; + def.type);</b>
&nbsp; };
&nbsp; }
<b class="pc">&nbsp; return switch (def.type) {</b>
<b class="fc">&nbsp; case &quot;Hunter&quot; -&gt; p.length == 0</b>
<b class="fc">&nbsp; ? new Hunter(def.id,era, def.armed)</b>
<b class="fc">&nbsp; : new Hunter(def.id,era, def.armed, p[0]);</b>
<b class="pc">&nbsp; case &quot;Builder&quot; -&gt; switch (p.length) {</b>
<b class="fc">&nbsp; case 2 -&gt; new Builder(def.id,era, p[0], p[1]);</b>
<b class="fc">&nbsp; case 3 -&gt; new Builder(def.id,era, p[0], p[1], p[2]);</b>
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Builder: invalid parameters&quot;);</b>
&nbsp; };
<b class="pc">&nbsp; case &quot;Gatherer&quot; -&gt; switch (p.length) {</b>
<b class="fc">&nbsp; case 0 -&gt; new Gatherer(def.id,era);</b>
<b class="fc">&nbsp; case 1 -&gt; new Gatherer(def.id,era, p[0]);</b>
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Gatherer: invalid parameters&quot;);</b>
&nbsp; };
<b class="pc">&nbsp; case &quot;Artist&quot; -&gt; switch (p.length) {</b>
<b class="fc">&nbsp; case 0 -&gt; new Artist(def.id,era);</b>
<b class="fc">&nbsp; case 1 -&gt; new Artist(def.id,era, p[0]);</b>
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Artist: invalid parameters&quot;);</b>
&nbsp; };
<b class="pc">&nbsp; case &quot;Inventor&quot; -&gt; switch (p.length) {</b>
<b class="fc">&nbsp; case 1 -&gt; new Inventor(def.id,era, p[0]);</b>
<b class="fc">&nbsp; case 2 -&gt; new Inventor(def.id,era, p[0], p[1]);</b>
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Inventor: invalid parameters&quot;);</b>
&nbsp; };
<b class="pc">&nbsp; case &quot;Shaman&quot; -&gt; switch (p.length) {</b>
<b class="fc">&nbsp; case 1 -&gt; new Shaman(def.id,era, p[0]);</b>
<b class="fc">&nbsp; case 2 -&gt; new Shaman(def.id,era, p[0], p[1]);</b>
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Shaman: invalid parameters&quot;);</b>
&nbsp; };
<b class="nc">&nbsp; default -&gt; throw new IllegalArgumentException(&quot;Unknown card type: &quot; + def.type);</b>
&nbsp; };
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Instantiates a {@link BuildingCard} from the given definition.
&nbsp; * The appropriate subclass is selected based on the effect ID specified in the definition.
&nbsp; * If no specific subclass matches the effect ID, a base {@link BuildingCard} is created.
&nbsp; *
&nbsp; * @param def the {@link BuildingCardDefinition} containing the card&#39;s effect ID, era, price, prestige value, and parameters.
&nbsp; * @return the instantiated {@link BuildingCard}.
&nbsp; */
&nbsp; private static BuildingCard createCard(BuildingCardDefinition def) {
<b class="pc">&nbsp; return switch (def.effectId) {</b>
<b class="fc">&nbsp; case 0 -&gt; new Building0(def.id,def.era, def.price, def.prestigeValue);</b>
<b class="fc">&nbsp; case 1 -&gt; new Building1(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()));</b>
<b class="fc">&nbsp; case 4 -&gt; new Building4(def.id,def.era, def.price, def.prestigeValue);</b>
<b class="fc">&nbsp; case 8 -&gt; new Building8(def.id,def.era, def.price, def.prestigeValue);</b>
<b class="fc">&nbsp; case 10 -&gt; new Building10(def.id,def.era, def.price, def.prestigeValue);</b>
<b class="fc">&nbsp; case 11 -&gt; new Building11(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()), ((Double) def.params.get(1)).intValue());</b>
<b class="fc">&nbsp; case 13 -&gt; new Building13(def.id,def.era, def.price, def.prestigeValue);</b>
<b class="fc">&nbsp; default -&gt; new BuildingCard(def.id,def.effectId, def.era, def.price, def.prestigeValue);</b>
&nbsp; };
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Internal data class representing the raw definition of a tribe card as loaded from a JSON file.
&nbsp; * Contains the card identifier, type, era, whether it is armed, whether it is an event card,
&nbsp; * and a list of additional parameters.
&nbsp; */
&nbsp; private static class TribeCardDefinition {
&nbsp; String id;
&nbsp; String type;
&nbsp; int era;
&nbsp; boolean armed;
&nbsp; boolean isEvent;
&nbsp; List&lt;Object&gt; params; // Object to support mixed boolean and numeric parameters from JSON
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Internal data class representing the raw definition of a building card as loaded from a JSON file.
&nbsp; * Contains the card identifier, effect ID, era, price, prestige value, and a list of additional parameters.
&nbsp; */
&nbsp; private static class BuildingCardDefinition {
&nbsp; String id;
&nbsp; int effectId;
&nbsp; int era;
&nbsp; int price;
&nbsp; int prestigeValue;
&nbsp; List&lt;Object&gt; params; // Object to support mixed boolean and numeric parameters from JSON
&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>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,413 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > MiniModel</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.Model</a>
</div>
<h1>Coverage Summary for Class: MiniModel (it.polimi.ingsw.gc14.Model)</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">MiniModel</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/21)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/14)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/44)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
&nbsp;import it.polimi.ingsw.gc14.Model.GamePackage.Board;
&nbsp;import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
&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.*;
&nbsp;
&nbsp;/**
&nbsp; * Lightweight representation of the game model shared with clients.
&nbsp; *
&nbsp; * &lt;p&gt;The mini model contains only the information required by the client-side
&nbsp; * view and controllers to render the current match state and process incoming
&nbsp; * network updates.
&nbsp; */
&nbsp;public class MiniModel implements Serializable {
&nbsp;
&nbsp; /** Upper row of tribe cards currently on the board. */
&nbsp; public ArrayList&lt;TribeCard&gt; upperListTribeCards;
&nbsp; /** Lower row of tribe cards currently on the board. */
&nbsp; public ArrayList&lt;TribeCard&gt; lowerListTribeCards;
&nbsp; /** Upper row of building cards currently on the board. */
&nbsp; public ArrayList&lt;BuildingCard&gt; upperListBuildingCards;
&nbsp; /** Lower row of building cards currently on the board. */
&nbsp; public ArrayList&lt;BuildingCard&gt; lowerListBuildingCards;
&nbsp; /** Usernames of players currently disconnected from the game. */
&nbsp; public ArrayList&lt;String&gt; disconnectedPlayers;
&nbsp; /** The most recent network event applied to this model. */
&nbsp; public NetworkEvent lastEvent;
&nbsp;
&nbsp; /**
&nbsp; * Map associating each occupied slot with the corresponding player.
&nbsp; */
&nbsp; public Map&lt;Slot, Player&gt; slotPlayerMap;
&nbsp;
&nbsp; /**
&nbsp; * Card used to manage the player turn order.
&nbsp; */
&nbsp; public OrderLogicCard orderLogicCard;
&nbsp;
&nbsp; /**
&nbsp; * Current state of the game.
&nbsp; */
&nbsp; public CurrentState currentState;
&nbsp;
&nbsp; /**
&nbsp; * Map of players indexed by username.
&nbsp; */
&nbsp; public Map&lt;String, Player&gt; players;
&nbsp;
&nbsp; /**
&nbsp; * List of totems still available for selection.
&nbsp; */
&nbsp; public List&lt;Totems&gt; availableTotems;
&nbsp;
&nbsp; /**
&nbsp; * Final standing of the players at the end of the game.
&nbsp; */
&nbsp; public List&lt;Player&gt; standingPlayers;
&nbsp;
&nbsp; /**
&nbsp; * Constructs an empty mini model.
&nbsp; */
<b class="nc">&nbsp; public MiniModel() {</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Constructs a mini model with only the card lists populated.
&nbsp; *
&nbsp; * @param upperListTribeCards the upper row of tribe cards on the board.
&nbsp; * @param lowerListTribeCards the lower row of tribe cards on the board.
&nbsp; * @param upperListBuildingCards the upper row of building cards on the board.
&nbsp; * @param lowerListBuildingCards the lower row of building cards on the board.
&nbsp; */
<b class="nc">&nbsp; public MiniModel(ArrayList&lt;TribeCard&gt; upperListTribeCards,ArrayList&lt;TribeCard&gt;lowerListTribeCards,ArrayList&lt;BuildingCard&gt; upperListBuildingCards,ArrayList&lt;BuildingCard&gt;lowerListBuildingCards) {</b>
<b class="nc">&nbsp; this.upperListTribeCards = upperListTribeCards;</b>
<b class="nc">&nbsp; this.lowerListTribeCards = lowerListTribeCards;</b>
<b class="nc">&nbsp; this.upperListBuildingCards = upperListBuildingCards;</b>
<b class="nc">&nbsp; this.lowerListBuildingCards = lowerListBuildingCards;</b>
<b class="nc">&nbsp; this.disconnectedPlayers = new ArrayList&lt;&gt;();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Constructs a complete mini model from the current server-side game data.
&nbsp; *
&nbsp; * @param slotPlayerMap the map associating occupied slots with players.
&nbsp; * @param orderLogicCard the card managing player turn order.
&nbsp; * @param currentState the current state of the game.
&nbsp; * @param players the list of players in the match.
&nbsp; * @param availableTotems the list of totems still available for selection.
&nbsp; * @param upperListTribeCards the upper row of tribe cards on the board.
&nbsp; * @param lowerListTribeCards the lower row of tribe cards on the board.
&nbsp; * @param upperListBuildingCards the upper row of building cards on the board.
&nbsp; * @param lowerListBuildingCards the lower row of building cards on the board.
&nbsp; * @param disconnectedPlayers the list of usernames of currently disconnected players.
&nbsp; */
&nbsp; public MiniModel(Map&lt;Slot, Player&gt; slotPlayerMap,
&nbsp; OrderLogicCard orderLogicCard,
&nbsp; CurrentState currentState,
&nbsp; List&lt;Player&gt; players,
<b class="nc">&nbsp; List&lt;Totems&gt; availableTotems,ArrayList&lt;TribeCard&gt; upperListTribeCards,ArrayList&lt;TribeCard&gt;lowerListTribeCards,ArrayList&lt;BuildingCard&gt; upperListBuildingCards,ArrayList&lt;BuildingCard&gt;lowerListBuildingCards, ArrayList&lt;String&gt; disconnectedPlayers) {</b>
&nbsp;
<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.players = new LinkedHashMap&lt;&gt;();</b>
<b class="nc">&nbsp; this.availableTotems = availableTotems;</b>
<b class="nc">&nbsp; this.standingPlayers = new ArrayList&lt;&gt;();</b>
<b class="nc">&nbsp; this.upperListTribeCards = upperListTribeCards;</b>
<b class="nc">&nbsp; this.lowerListTribeCards = lowerListTribeCards;</b>
<b class="nc">&nbsp; this.upperListBuildingCards = upperListBuildingCards;</b>
<b class="nc">&nbsp; this.lowerListBuildingCards = lowerListBuildingCards;</b>
<b class="nc">&nbsp; this.disconnectedPlayers = disconnectedPlayers;</b>
<b class="nc">&nbsp; setPlayers(players);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the last network event applied to the game state.
&nbsp; *
&nbsp; * @param lastEvent the most recent event received from the server.
&nbsp; */
&nbsp; public void setLastEvent(NetworkEvent lastEvent) {
<b class="nc">&nbsp; this.lastEvent = lastEvent;</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Sets the list of totems still available for selection.
&nbsp; *
&nbsp; * @param availableTotems the available totems.
&nbsp; */
&nbsp; public void setAvailableTotems(List&lt;Totems&gt; availableTotems) {
<b class="nc">&nbsp; this.availableTotems = availableTotems;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the map associating occupied slots with players.
&nbsp; *
&nbsp; * @param slotPlayerMap the slot-player map to assign.
&nbsp; */
&nbsp; public void setSlotPlayerMap(Map&lt;Slot, Player&gt; slotPlayerMap) {
<b class="nc">&nbsp; this.slotPlayerMap = slotPlayerMap;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the card used to manage the player turn order.
&nbsp; *
&nbsp; * @param orderLogicCard the order logic card to assign.
&nbsp; */
&nbsp; public void setOrderLogicCard(OrderLogicCard orderLogicCard) {
<b class="nc">&nbsp; this.orderLogicCard = orderLogicCard;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the current state of the game.
&nbsp; *
&nbsp; * @param currentState the current game state.
&nbsp; */
&nbsp; public void setCurrentState(CurrentState currentState) {
<b class="nc">&nbsp; this.currentState = currentState;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Replaces or updates the players stored in the mini model.
&nbsp; *
&nbsp; * &lt;p&gt;Each player is indexed by username.
&nbsp; *
&nbsp; * @param players the list of players to store.
&nbsp; */
&nbsp; public void setPlayers(List&lt;Player&gt; players) {
<b class="nc">&nbsp; for (Player player : players) {</b>
<b class="nc">&nbsp; this.players.put(player.getUserName(), player);</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Adds or updates a single player in the mini model.
&nbsp; *
&nbsp; * @param player the player to store.
&nbsp; */
&nbsp; public void setPlayer(Player player) {
<b class="nc">&nbsp; players.put(player.getUserName(), player);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the final standing of the players.
&nbsp; *
&nbsp; * @param standingPlayers the final ordered list of players.
&nbsp; */
&nbsp; public void setStandingPlayers(List&lt;Player&gt; standingPlayers) {
<b class="nc">&nbsp; this.standingPlayers = standingPlayers;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Replaces the upper row of tribe cards on the board.
&nbsp; *
&nbsp; * @param cards the new upper tribe card list.
&nbsp; */
&nbsp; public void setUpperListTribeCards(ArrayList&lt;TribeCard&gt; cards) {
<b class="nc">&nbsp; this.upperListTribeCards = cards;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Replaces the lower row of tribe cards on the board.
&nbsp; *
&nbsp; * @param cards the new lower tribe card list.
&nbsp; */
&nbsp; public void setLowerListTribeCards(ArrayList&lt;TribeCard&gt; cards) {
<b class="nc">&nbsp; this.lowerListTribeCards = cards;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Replaces the upper row of building cards on the board.
&nbsp; *
&nbsp; * @param cards the new upper building card list.
&nbsp; */
&nbsp; public void setUpperListBuildingCards(ArrayList&lt;BuildingCard&gt; cards) {
<b class="nc">&nbsp; this.upperListBuildingCards = cards;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Replaces the lower row of building cards on the board.
&nbsp; *
&nbsp; * @param cards the new lower building card list.
&nbsp; */
&nbsp; public void setLowerListBuildingCards(ArrayList&lt;BuildingCard&gt; cards) {
<b class="nc">&nbsp; this.lowerListBuildingCards = cards;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes the card at the given position from the upper tribe card list.
&nbsp; *
&nbsp; * @param pos the zero-based index of the card to remove.
&nbsp; */
&nbsp; public void removeUpperTribeCard(int pos) {
<b class="nc">&nbsp; if (upperListTribeCards != null) upperListTribeCards.remove(pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes the card at the given position from the lower tribe card list.
&nbsp; *
&nbsp; * @param pos the zero-based index of the card to remove.
&nbsp; */
&nbsp; public void removeLowerTribeCard(int pos) {
<b class="nc">&nbsp; if (lowerListTribeCards != null) lowerListTribeCards.remove(pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes the card at the given position from the upper building card list.
&nbsp; *
&nbsp; * @param pos the zero-based index of the card to remove.
&nbsp; */
&nbsp; public void removeUpperBuildingCard(int pos) {
<b class="nc">&nbsp; if (upperListBuildingCards != null) upperListBuildingCards.remove(pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes the card at the given position from the lower building card list.
&nbsp; *
&nbsp; * @param pos the zero-based index of the card to remove.
&nbsp; */
&nbsp; public void removeLowerBuildingCard(int pos) {
<b class="nc">&nbsp; if (lowerListBuildingCards != null) lowerListBuildingCards.remove(pos);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the position of the player with the specified username
&nbsp; * within the player collection.
&nbsp; *
&nbsp; * @param username the username of the player to search for.
&nbsp; * @return the zero-based position of the player, or {@code -1}
&nbsp; * if no matching username is found.
&nbsp; */
&nbsp; public int getPositionByUsername(String username) {
<b class="nc">&nbsp; int i = 0;</b>
<b class="nc">&nbsp; for (Player player : players.values()) {</b>
<b class="nc">&nbsp; if (player.getUserName().equals(username)) {</b>
<b class="nc">&nbsp; return i;</b>
&nbsp; }
<b class="nc">&nbsp; i++;</b>
&nbsp; }
<b class="nc">&nbsp; return -1;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the list of usernames of currently disconnected players.
&nbsp; *
&nbsp; * @param disconnectedPlayers the list of disconnected player usernames.
&nbsp; */
&nbsp; public void setDisconnectedPlayers (ArrayList&lt;String&gt; disconnectedPlayers){
<b class="nc">&nbsp; this.disconnectedPlayers=disconnectedPlayers;</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,297 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > OrderLogicCard</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.Model</a>
</div>
<h1>Coverage Summary for Class: OrderLogicCard (it.polimi.ingsw.gc14.Model)</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">OrderLogicCard</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
80%
</span>
<span class="absValue">
(8/10)
</span>
</td>
<td class="coverageStat">
<span class="percent">
91.7%
</span>
<span class="absValue">
(11/12)
</span>
</td>
<td class="coverageStat">
<span class="percent">
87.1%
</span>
<span class="absValue">
(27/31)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
&nbsp;import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
&nbsp;import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
&nbsp;
&nbsp;import java.io.Serializable;
&nbsp;import java.util.*;
&nbsp;import java.util.stream.Collectors;
&nbsp;
&nbsp;/**
&nbsp; * Abstract base class for all order logic cards.
&nbsp; *
&nbsp; * &lt;p&gt;An order logic card manages the turn order of the players and defines
&nbsp; * the behavior used to update the order during the game.
&nbsp; */
&nbsp;public abstract class OrderLogicCard implements Serializable {
&nbsp;
&nbsp; /**
&nbsp; * The queue of {@link Player Players} associated with this order logic card.
&nbsp; */
&nbsp; private Queue&lt;Player&gt; players;
&nbsp;
&nbsp; /**
&nbsp; * The list of {@link OrderPlayer} entries tracking turn order and played status.
&nbsp; * Protected so subclasses can read it for display purposes (e.g., {@link #toString()}).
&nbsp; */
&nbsp; protected List&lt;OrderPlayer&gt; playerList;
&nbsp;
&nbsp; /**
&nbsp; * Returns an unmodifiable view of the player order list.
&nbsp; *
&nbsp; * @return the list of {@link OrderPlayer} entries in turn order.
&nbsp; */
&nbsp; public List&lt;OrderPlayer&gt; getPlayerList() {
<b class="nc">&nbsp; return Collections.unmodifiableList(playerList);</b>
&nbsp; }
&nbsp;
&nbsp; /** Total number of players in this game. */
&nbsp; protected final int nPlayers;
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Creates an order logic card with the specified list of players.
&nbsp; *
&nbsp; * &lt;p&gt;The input list is shuffled in place to establish a random initial turn order.
&nbsp; * This is intentional: the caller&#39;s list (typically {@code Game.playersList}) is
&nbsp; * reordered so that the game&#39;s canonical player sequence reflects the randomised order.
&nbsp; *
&nbsp; * @param players the list of players associated with this order logic card.
&nbsp; * &lt;strong&gt;The list is mutated (shuffled) by this constructor.&lt;/strong&gt;
&nbsp; */
<b class="fc">&nbsp; public OrderLogicCard(ArrayList&lt;Player&gt; players) {</b>
<b class="fc">&nbsp; Collections.shuffle(players);</b>
<b class="fc">&nbsp; this.players = new LinkedList&lt;&gt;(players);</b>
<b class="fc">&nbsp; nPlayers = players.size();</b>
<b class="fc">&nbsp; this.playerList = new ArrayList&lt;&gt;(players.stream().map(x -&gt; new OrderPlayer(x, false)).toList());</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the effect associated with the current queue position of the player
&nbsp; * and then adds the player to the end of the queue.
&nbsp; *
&nbsp; * @param player the player to be pushed into the queue.
&nbsp; */
&nbsp; public void push(Player player) {
<b class="fc">&nbsp; effect(player, players.size());</b>
<b class="fc">&nbsp; if (players.size() == 0) {</b>
<b class="fc">&nbsp; playerList.clear();</b>
&nbsp; }
<b class="fc">&nbsp; playerList.add(new OrderPlayer(player, false));</b>
<b class="fc">&nbsp; players.add(player);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Moves the specified player to the end of the queue without applying effects.
&nbsp; *
&nbsp; * &lt;p&gt;Any previous occurrence of the player is removed from both the queue
&nbsp; * and the order list before the player is added again.
&nbsp; *
&nbsp; * @param player the player to be pushed into the queue.
&nbsp; */
&nbsp; public void pushNoEffect(Player player) {
<b class="fc">&nbsp; players.removeIf(x -&gt; player.getUserName().equals(x.getUserName()));</b>
<b class="fc">&nbsp; playerList.removeIf(x -&gt; player.getUserName().equals(x.getPlayer().getUserName()));</b>
<b class="fc">&nbsp; playerList.add(new OrderPlayer(player, false));</b>
<b class="fc">&nbsp; players.add(player);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes and returns the first player in the queue.
&nbsp; *
&nbsp; * &lt;p&gt;The first order entry that has not yet been marked as played
&nbsp; * is marked as played before removing the player from the queue.
&nbsp; *
&nbsp; * @return the first player in the queue, or {@code null} if the queue is empty.
&nbsp; */
&nbsp; public Player pull() {
<b class="fc">&nbsp; for (OrderPlayer p : playerList) {</b>
<b class="fc">&nbsp; if (!p.isPlayed()) {</b>
<b class="fc">&nbsp; p.markAsPlayed();</b>
&nbsp; break;
&nbsp; }
&nbsp; }
<b class="fc">&nbsp; return players.poll();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the first player in the queue without removing it.
&nbsp; *
&nbsp; * @return the first player in the queue, or {@code null} if the queue is empty.
&nbsp; */
&nbsp; public Player getFirst()
&nbsp; {
<b class="fc">&nbsp; return players.peek();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the effect associated with the specified player and queue position.
&nbsp; *
&nbsp; * @param player the player to whom the effect is applied.
&nbsp; * @param index the queue position index associated with the effect.
&nbsp; * @throws IndexOutOfBoundsException if the specified index is not valid.
&nbsp; */
&nbsp; protected abstract void effect(Player player, int index) throws IndexOutOfBoundsException;
&nbsp;
&nbsp; /**
&nbsp; * Applies the building-related effect to the specified player.
&nbsp; * For each building card owned by the player with effect id equal to 3,
&nbsp; * the player gains 1 Food.
&nbsp; *
&nbsp; * @param player the player to whom the building effect is applied.
&nbsp; */
&nbsp; protected void buildingEffect(Player player) {
<b class="fc">&nbsp; long count = player.getBuildingCards().stream().filter(x -&gt; x.getEffectId() == 3).count();</b>
<b class="fc">&nbsp; player.addFood((int) count);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns whether the given player is currently present in the turn queue.
&nbsp; *
&nbsp; * @param player the player to look up.
&nbsp; * @return {@code true} if the player is in the queue; {@code false} otherwise.
&nbsp; */
&nbsp; public boolean containsInQueue(Player player) {
<b class="fc">&nbsp; return players.contains(player);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes the given player from both the turn queue and the order list.
&nbsp; * No-op if the player is not present.
&nbsp; *
&nbsp; * @param player the player to remove.
&nbsp; */
&nbsp; public void removeFromQueue(Player player) {
<b class="nc">&nbsp; players.removeIf(x -&gt; x.equals(player));</b>
<b class="nc">&nbsp; playerList.removeIf(x -&gt; x.getPlayer().equals(player));</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the position of the player associated with the specified username
&nbsp; * within the current order list.
&nbsp; *
&nbsp; * @param username the username of the player whose position is requested.
&nbsp; * @return the player&#39;s position, or {@code -1} if no player with the specified
&nbsp; * username is present in the order list.
&nbsp; * @see Player
&nbsp; */
&nbsp; public int getPosition(String username) {
<b class="fc">&nbsp; int pos = 0;</b>
<b class="pc">&nbsp; for (OrderPlayer p : playerList) {</b>
<b class="fc">&nbsp; if (p.getPlayer().getUserName().equals(username))</b>
<b class="fc">&nbsp; return pos;</b>
<b class="fc">&nbsp; pos++;</b>
&nbsp; }
<b class="nc">&nbsp; return -1;</b>
&nbsp; }
&nbsp;
&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,204 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > PlayableCard</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.Model</a>
</div>
<h1>Coverage Summary for Class: PlayableCard (it.polimi.ingsw.gc14.Model)</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">PlayableCard</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(6/6)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(8/8)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(14/14)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;import java.io.Serializable;
&nbsp;
&nbsp;
&nbsp;/**
&nbsp; * Abstract base class for all playable cards.
&nbsp; * A PlayableCard is characterized by an era value.
&nbsp; */
&nbsp;public abstract class PlayableCard implements Serializable {
&nbsp;
&nbsp; /**
&nbsp; * The image identifier of the playable card.
&nbsp; */
&nbsp; private String idIMG;
&nbsp;
&nbsp; /**
&nbsp; * Returns the image identifier of this playable card.
&nbsp; *
&nbsp; * @return the image identifier of this playable card.
&nbsp; */
&nbsp; public String getIdIMG() {
<b class="fc">&nbsp; return idIMG;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The era associated with this playable card.
&nbsp; */
&nbsp; private int era;
&nbsp;
&nbsp; /**
&nbsp; * Returns the era of this playable card.
&nbsp; *
&nbsp; * @return the era of this playable card.
&nbsp; */
&nbsp; public int getEra(){
<b class="fc">&nbsp; return era;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a playable card with the specified era.
&nbsp; *
&nbsp; * @param era the era of the playable card.
&nbsp; * @throws IllegalArgumentException if {@code era &lt;= 0} or {@code era &gt;= 4}.
&nbsp; */
<b class="fc">&nbsp; public PlayableCard(int era) throws IllegalArgumentException {</b>
<b class="fc">&nbsp; idIMG = &quot;-1&quot;;</b>
<b class="fc">&nbsp; if (era &gt; 0 &amp;&amp; era &lt; 4) {</b>
<b class="fc">&nbsp; this.era = era;</b>
&nbsp; } else {
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a playable card with the specified image id and era.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the playable card.
&nbsp; * @param era the era of the playable card.
&nbsp; * @throws IllegalArgumentException if {@code era &lt;= 0} or {@code era &gt;= 4}.
&nbsp; */
<b class="fc">&nbsp; public PlayableCard(String idIMG, int era) throws IllegalArgumentException {</b>
<b class="fc">&nbsp; this.idIMG = idIMG;</b>
<b class="fc">&nbsp; if (era &gt; 0 &amp;&amp; era &lt; 4) {</b>
<b class="fc">&nbsp; this.era = era;</b>
&nbsp; } else {
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns a string representation of this playable card.
&nbsp; *
&nbsp; * @return a string representation of this playable card.
&nbsp; */
&nbsp; @Override
&nbsp; public String toString() {
<b class="fc">&nbsp; return &quot;&quot;;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns a compact string representation used when rendering the board in the TUI.
&nbsp; *
&nbsp; * @return a compact board representation of this card.
&nbsp; */
&nbsp; public String toStringBoard() {
<b class="fc">&nbsp; return &quot;:&quot;;</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,503 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > Player</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.Model</a>
</div>
<h1>Coverage Summary for Class: Player (it.polimi.ingsw.gc14.Model)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Branch, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">Player</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(22/22)
</span>
</td>
<td class="coverageStat">
<span class="percent">
96.6%
</span>
<span class="absValue">
(56/58)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(105/105)
</span>
</td>
</tr>
<tr>
<td class="name">Player$1</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
</tr>
<tr>
<td class="name"><strong>Total</strong></td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(23/23)
</span>
</td>
<td class="coverageStat">
<span class="percent">
96.6%
</span>
<span class="absValue">
(56/58)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(106/106)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
&nbsp;import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
&nbsp;
&nbsp;import java.io.Serializable;
&nbsp;import java.util.ArrayList;
&nbsp;import java.util.Arrays;
&nbsp;import java.util.Map;
&nbsp;import java.util.stream.Collectors;
&nbsp;
&nbsp;import static it.polimi.ingsw.gc14.View.TUI.BorderStyle.*;
&nbsp;
&nbsp;/**
&nbsp; * Default Player class; contains all identifiers and methods needed.
&nbsp; */
&nbsp;public class Player implements Serializable {
&nbsp; /**
&nbsp; * The maximum length allowed for the username string.
&nbsp; */
&nbsp; private static final int MAX_USERNAME_LENGTH = 32;
&nbsp;
&nbsp; /**
&nbsp; * Identifier for the {@code Player} when displaying the game through the GUI.
&nbsp; * @see Totems
&nbsp; */
&nbsp; private Totems totem;
&nbsp;
&nbsp; // region Getters
&nbsp; /**
&nbsp; * Unique string identifier for players; must not be {@code null} and must not
&nbsp; * exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
&nbsp; * when the {@link #Player(String) constructor} is called.
&nbsp; */
&nbsp; private final String userName;
&nbsp;
&nbsp; /**
&nbsp; * Getter for the private attribute {@link #userName}.
&nbsp; * @return {@code String} - The UserName
&nbsp; */
&nbsp; public String getUserName() {
<b class="fc">&nbsp; return userName;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the totem assigned to this player.
&nbsp; *
&nbsp; * @return this player&#39;s totem.
&nbsp; */
&nbsp; public Totems getTotem() {
<b class="fc">&nbsp; return totem;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Counts the total {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character Character Cards}
&nbsp; * the player currently possesses.
&nbsp; * @return {@code int} - Total Character Cards.
&nbsp; */
&nbsp; public int getTotCharacters() {
<b class="fc">&nbsp; return Arrays.stream(CharacterType.values())</b>
<b class="fc">&nbsp; .mapToInt(this::getNType)</b>
<b class="fc">&nbsp; .sum();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Counts the total number of cards of the specified {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType Character Type}.
&nbsp; * Character Type must not be {@code null}
&nbsp; * @param type the Character Type to be Counted.
&nbsp; * @return {@code int} - Total number of cards of given {@code type}.
&nbsp; */
&nbsp; public int getNType(CharacterType type) {
<b class="pc">&nbsp; return switch (type) {</b>
<b class="fc">&nbsp; case ARTIST -&gt; artists.size();</b>
<b class="fc">&nbsp; case INVENTOR -&gt; inventors.size();</b>
<b class="fc">&nbsp; case HUNTER -&gt; hunters.size();</b>
<b class="fc">&nbsp; case BUILDER -&gt; builders.size();</b>
<b class="fc">&nbsp; case SHAMAN -&gt; shamans.size();</b>
<b class="fc">&nbsp; case GATHERER -&gt; gatherers.size();</b>
&nbsp; };
&nbsp; }
&nbsp; private ArrayList&lt;BuildingCard&gt; buildingCards;
&nbsp; private ArrayList&lt;Artist&gt; artists;
&nbsp; private ArrayList&lt;Builder&gt; builders;
&nbsp; private ArrayList&lt;Inventor&gt; inventors;
&nbsp; private ArrayList&lt;Gatherer&gt; gatherers;
&nbsp; private ArrayList&lt;Shaman&gt; shamans;
&nbsp; private ArrayList&lt;Hunter&gt; hunters;
&nbsp;
&nbsp; /** @return this player&#39;s building cards. */
<b class="fc">&nbsp; public ArrayList&lt;BuildingCard&gt; getBuildingCards() { return buildingCards; }</b>
&nbsp; /** @return this player&#39;s Artist character cards. */
<b class="fc">&nbsp; public ArrayList&lt;Artist&gt; getArtists() { return artists; }</b>
&nbsp; /** @return this player&#39;s Builder character cards. */
<b class="fc">&nbsp; public ArrayList&lt;Builder&gt; getBuilders() { return builders; }</b>
&nbsp; /** @return this player&#39;s Inventor character cards. */
<b class="fc">&nbsp; public ArrayList&lt;Inventor&gt; getInventors() { return inventors; }</b>
&nbsp; /** @return this player&#39;s Gatherer character cards. */
<b class="fc">&nbsp; public ArrayList&lt;Gatherer&gt; getGatherers() { return gatherers; }</b>
&nbsp; /** @return this player&#39;s Shaman character cards. */
<b class="fc">&nbsp; public ArrayList&lt;Shaman&gt; getShamans() { return shamans; }</b>
&nbsp; /** @return this player&#39;s Hunter character cards. */
<b class="fc">&nbsp; public ArrayList&lt;Hunter&gt; getHunters() { return hunters; }</b>
&nbsp;
&nbsp; /**
&nbsp; * The current amount of {@code Food} the Player possesses.
&nbsp; * Cannot be negative.
&nbsp; */
&nbsp; private int foodValue;
&nbsp;
&nbsp; /**
&nbsp; * Getter for the private attribute {@link #foodValue}.
&nbsp; * @return {@code int} - The amount of Food the player possesses.
&nbsp; */
&nbsp; public int getFoodValue() {
<b class="fc">&nbsp; return foodValue;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The current amount of {@code Prestige} the Player possesses.
&nbsp; */
&nbsp; private int prestigeValue;
&nbsp;
&nbsp; /**
&nbsp; * Getter for the private attribute {@link #prestigeValue}.
&nbsp; * @return {@code int} - The amount of Prestige the Player possesses.
&nbsp; */
&nbsp; public int getPrestigeValue() {
<b class="fc">&nbsp; return prestigeValue;</b>
&nbsp; }
&nbsp;
&nbsp; // endregion getters
&nbsp;
&nbsp; // region Setters
&nbsp;
&nbsp; /**
&nbsp; * Adds {@code value} amount of Food to the Player.
&nbsp; * @param value The amount of Food to be added. Should be non-negative.
&nbsp; * @see #foodValue
&nbsp; */
&nbsp; public void addFood(int value){
<b class="fc">&nbsp; this.foodValue += value;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Sets the totem for this player.
&nbsp; *
&nbsp; * @param totem the totem to assign.
&nbsp; */
&nbsp; public void setTotem(Totems totem) {
<b class="fc">&nbsp; this.totem = totem;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes {@code value} amount of Food from the Player.
&nbsp; * {@link #foodValue} cannot go negative: returns {@code false} if
&nbsp; * {@code value} exceeds the current food and leaves the value unchanged.
&nbsp; *
&nbsp; * @param value The amount of Food to be removed. Should be non-negative.
&nbsp; * @return {@code true} if the Food is successfully removed, {@code false} otherwise.
&nbsp; * @see #foodValue
&nbsp; */
&nbsp; public boolean removeFood(int value){
<b class="fc">&nbsp; if(value &gt; this.foodValue){</b>
<b class="fc">&nbsp; return false;</b>
&nbsp; }
<b class="fc">&nbsp; this.foodValue -= value;</b>
<b class="fc">&nbsp; return true;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Adds {@code value} amount of Prestige to the Player.
&nbsp; * @param value The amount of Prestige to be added. Should be non-negative.
&nbsp; * @see #prestigeValue
&nbsp; */
&nbsp; public void addPrestige(int value){
<b class="fc">&nbsp; this.prestigeValue += value;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Removes {@code value} amount of Prestige from the Player.
&nbsp; * @param value The amount of Prestige to be removed. Should be non-negative.
&nbsp; * @see #prestigeValue
&nbsp; */
&nbsp; public void removePrestige(int value){
<b class="fc">&nbsp; this.prestigeValue -= value;</b>
&nbsp; }
&nbsp;
&nbsp; // endregion setters
&nbsp;
&nbsp; // region Constructors
&nbsp;
&nbsp; /**
&nbsp; * Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #userName}.
&nbsp; *
&nbsp; * @param userName Unique String identifier for a Player.
&nbsp; * @throws IllegalArgumentException when {@code userName} is empty or exceeds {@link #MAX_USERNAME_LENGTH},
&nbsp; * with message:
&nbsp; * &lt;pre&gt;{@code UserName is empty or exceeds maximum permitted length.}&lt;/pre&gt;
&nbsp; *
&nbsp; * @see #userName
&nbsp; * @see #MAX_USERNAME_LENGTH
&nbsp; */
<b class="fc">&nbsp; public Player(String userName) throws IllegalArgumentException {</b>
<b class="fc">&nbsp; if(userName.isEmpty() || userName.length() &gt; MAX_USERNAME_LENGTH) {</b>
<b class="fc">&nbsp; throw new IllegalArgumentException(&quot;UserName is empty or exceeds maximum permitted length.&quot;);</b>
&nbsp; }
<b class="fc">&nbsp; this.userName = userName;</b>
&nbsp;
<b class="fc">&nbsp; this.inventors = new ArrayList &lt;&gt;();</b>
<b class="fc">&nbsp; this.builders = new ArrayList &lt;&gt;();</b>
<b class="fc">&nbsp; this.gatherers = new ArrayList &lt;&gt;();</b>
<b class="fc">&nbsp; this.shamans = new ArrayList &lt;&gt;();</b>
<b class="fc">&nbsp; this.hunters = new ArrayList &lt;&gt;();</b>
<b class="fc">&nbsp; this.artists = new ArrayList&lt;&gt;();</b>
&nbsp;
<b class="fc">&nbsp; this.buildingCards = new ArrayList&lt;&gt;();</b>
<b class="fc">&nbsp; this.foodValue = 0;</b>
<b class="fc">&nbsp; this.prestigeValue = 0;</b>
<b class="fc">&nbsp; this.totem = null;</b>
&nbsp; }
&nbsp; // endregion constructors
&nbsp;
&nbsp; // region Functions
&nbsp;
&nbsp; // TODO
&nbsp; @Override
&nbsp; public boolean equals(Object obj) {
<b class="fc">&nbsp; if (this == obj) return true;</b>
<b class="pc">&nbsp; if (!(obj instanceof Player)) return false;</b>
<b class="fc">&nbsp; return userName.equals(((Player) obj).userName);</b>
&nbsp; }
&nbsp;
&nbsp; @Override
&nbsp; public int hashCode() {
<b class="fc">&nbsp; return userName.hashCode();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Prints the {@code Player}&#39;s attributes for the {@code Board}&#39;s representation.
&nbsp; * Uses the {@code UNICODE} border style.
&nbsp; * &lt;p&gt;&lt;b&gt;Includes:&lt;/b&gt;
&nbsp; * &lt;li&gt;{@link #foodValue Food}
&nbsp; * &lt;li&gt;{@link #prestigeValue Prestige}
&nbsp; * &lt;li&gt;{@link #artists Artists}
&nbsp; * &lt;li&gt;{@link #builders Builders}
&nbsp; * &lt;li&gt;{@link #gatherers Gatherers}
&nbsp; * &lt;li&gt;{@link #shamans Shamans}
&nbsp; * &lt;li&gt;{@link #inventors Inventors}
&nbsp; * &lt;li&gt;{@link #hunters Hunters}
&nbsp; * &lt;li&gt;{@link #buildingCards Buildings}
&nbsp; * &lt;/p&gt;
&nbsp; * @return {@code String} - A string representation of the {@code Player}&#39;s attributes.
&nbsp; * @see it.polimi.ingsw.gc14.View.TUI.BorderStyle BorderStyle
&nbsp; */
&nbsp; @Override
&nbsp; public String toString() {
<b class="fc">&nbsp; int last = -1;</b>
&nbsp;
<b class="fc">&nbsp; var table = new AsciiTable(ROUNDED, 1);</b>
&nbsp;
<b class="pc">&nbsp; String totemStr = (this.totem != null) ? &quot; (&quot; + this.totem.toString() + &quot;)&quot; : &quot;&quot;;</b>
<b class="fc">&nbsp; table.addHeader(this.getUserName() + totemStr + &quot; | \uD83C\uDF56:&quot; + this.getFoodValue() + &quot; | \uD83C\uDFC5:&quot; + this.getPrestigeValue());</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp;
<b class="fc">&nbsp; if(!this.hunters.isEmpty()){</b>
<b class="fc">&nbsp; last = 6;</b>
&nbsp; }
<b class="fc">&nbsp; else if(!this.inventors.isEmpty()){</b>
<b class="fc">&nbsp; last = 5;</b>
&nbsp; }
<b class="fc">&nbsp; else if(!this.shamans.isEmpty()){</b>
<b class="fc">&nbsp; last = 4;</b>
&nbsp; }
<b class="fc">&nbsp; else if(!this.gatherers.isEmpty()){</b>
<b class="fc">&nbsp; last = 3;</b>
&nbsp; }
<b class="fc">&nbsp; else if(!this.builders.isEmpty()){</b>
<b class="fc">&nbsp; last = 2;</b>
&nbsp; }
<b class="fc">&nbsp; else if(!this.artists.isEmpty()){</b>
<b class="fc">&nbsp; last = 1;</b>
&nbsp; }
&nbsp; else{
<b class="fc">&nbsp; last = 0;</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; if(last == 0){</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
<b class="fc">&nbsp; table.addRow(&quot;CHARACTERS&quot;);</b>
<b class="fc">&nbsp; if(!this.artists.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.artists.size() + &quot; Artists: \uD83C\uDFA8:&quot; + this.artists.size());</b>
<b class="fc">&nbsp; if(last == 1){</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
&nbsp; }
&nbsp;
<b class="fc">&nbsp; if(!this.builders.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.builders.size() + &quot; Builders: &quot; + &quot;\uD83D\uDD28:&quot; + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + &quot; \uD83C\uDFC5:&quot; + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());</b>
<b class="fc">&nbsp; if(last == 2){</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
&nbsp; }
&nbsp;
<b class="fc">&nbsp; if(!this.gatherers.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.gatherers.size() + &quot; Gatherers: -\uD83E\uDD57:&quot; + 3*this.gatherers.size());</b>
<b class="fc">&nbsp; if(last == 3){</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
&nbsp; }
&nbsp;
<b class="fc">&nbsp; if(!this.shamans.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.shamans.size() + &quot; Shamans: &quot; + &quot;\uD83C\uDF1F:&quot; + this.shamans.stream().mapToInt(Shaman::getIcon).sum());</b>
<b class="fc">&nbsp; if(last == 4){</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
&nbsp; }
&nbsp;
<b class="fc">&nbsp; if(!this.inventors.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.inventors.size() + &quot; Inventors: &quot; + this.inventors.stream()</b>
<b class="fc">&nbsp; .collect(Collectors.groupingBy(</b>
&nbsp; Inventor::getIcon,
<b class="fc">&nbsp; Collectors.counting()</b>
&nbsp; ))
<b class="fc">&nbsp; .entrySet().stream()</b>
<b class="fc">&nbsp; .sorted(Map.Entry.comparingByKey())</b>
<b class="fc">&nbsp; .map(e -&gt; e.getKey() + &quot;:&quot; + e.getValue())</b>
<b class="fc">&nbsp; .collect(Collectors.joining(&quot;, &quot;)));</b>
<b class="fc">&nbsp; if(last == 5){</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp;
<b class="fc">&nbsp; if(!this.hunters.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.hunters.size() + &quot; Hunters: \uD83C\uDF56&quot; + this.hunters.stream().filter(Hunter::getIcon).count());</b>
<b class="fc">&nbsp; table.addSeparator();</b>
&nbsp; }
<b class="fc">&nbsp; table.addSeparator();</b>
<b class="fc">&nbsp; table.addRow(&quot;BUILDING CARDS&quot; +</b>
<b class="fc">&nbsp; (this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum() != 0</b>
<b class="fc">&nbsp; ? &quot; 🏅:&quot; + this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum()</b>
<b class="fc">&nbsp; : &quot;&quot;));</b>
<b class="fc">&nbsp; if(!this.buildingCards.isEmpty()){</b>
<b class="fc">&nbsp; table.addRow(this.buildingCards.size() + &quot; Buildings: &quot; + this.buildingCards.stream().map(BuildingCard::toStringPlayer).collect(Collectors.joining(&quot;, &quot;)));</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; return table.build();</b>
&nbsp; }
&nbsp; // endregion functions
&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,312 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > Slot</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.Model</a>
</div>
<h1>Coverage Summary for Class: Slot (it.polimi.ingsw.gc14.Model)</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">Slot</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
90%
</span>
<span class="absValue">
(9/10)
</span>
</td>
<td class="coverageStat">
<span class="percent">
42.1%
</span>
<span class="absValue">
(8/19)
</span>
</td>
<td class="coverageStat">
<span class="percent">
82.2%
</span>
<span class="absValue">
(37/45)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;import java.io.Serializable;
&nbsp;
&nbsp;/**
&nbsp; * Represents a slot with a specific identifier and associated values
&nbsp; * for upper cards, lower cards, food, and minimum number of players.
&nbsp; * The slot configuration depends on the specified slot identifier.
&nbsp; */
&nbsp;public class Slot implements Serializable {
&nbsp; // Getters
&nbsp;
&nbsp; /**
&nbsp; * The identifier of this slot.
&nbsp; */
&nbsp; private char slotId;
&nbsp;
&nbsp; /**
&nbsp; * Returns the identifier of this slot.
&nbsp; *
&nbsp; * @return the identifier of this slot.
&nbsp; */
&nbsp; public char getSlotId() {
<b class="fc">&nbsp; return slotId;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The number of upper cards associated with this slot.
&nbsp; */
&nbsp; private int nUpper;
&nbsp; /**
&nbsp; * Returns the number of upper cards associated with this slot.
&nbsp; *
&nbsp; * @return the number of upper cards associated with this slot.
&nbsp; */
&nbsp; public int getNUpper(){
<b class="fc">&nbsp; return nUpper;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The minimum number of players required for this slot.
&nbsp; */
&nbsp; private int nMinPlayer;
&nbsp;
&nbsp; /**
&nbsp; * Returns the minimum number of players required for this slot.
&nbsp; *
&nbsp; * @return the minimum number of players required for this slot.
&nbsp; */
&nbsp; public int getNMinPlayer()
&nbsp; {
<b class="fc">&nbsp; return nMinPlayer;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The number of lower cards associated with this slot.
&nbsp; */
&nbsp; private int nLower;
&nbsp;
&nbsp; /**
&nbsp; * Returns the number of lower cards associated with this slot.
&nbsp; *
&nbsp; * @return the number of lower cards associated with this slot.
&nbsp; */
&nbsp; public int getNLower(){
<b class="fc">&nbsp; return nLower;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The amount of Food associated with this slot.
&nbsp; */
&nbsp; private int food;
&nbsp;
&nbsp; /**
&nbsp; * Returns the amount of Food associated with this slot.
&nbsp; *
&nbsp; * @return the amount of Food associated with this slot.
&nbsp; */
&nbsp; public int getFood(){
<b class="fc">&nbsp; return food;</b>
&nbsp; }
&nbsp; // End getters
&nbsp;
&nbsp; // Constructors
&nbsp;
&nbsp; /**
&nbsp; * Creates a slot with the specified identifier.
&nbsp; * The slot values for Food, NLower, NUpper, and minimum number of players
&nbsp; * are determined by the given slot identifier.
&nbsp; *
&nbsp; * @param slotId the identifier of the slot.
&nbsp; * @throws IllegalArgumentException if the specified slot identifier is not valid.
&nbsp; */
&nbsp; public Slot(char slotId) throws IllegalArgumentException
<b class="fc">&nbsp; {</b>
<b class="fc">&nbsp; this.slotId = slotId;</b>
<b class="fc">&nbsp; this.nMinPlayer=0;</b>
<b class="fc">&nbsp; switch(slotId)</b>
&nbsp; {
&nbsp; case &#39;A&#39;:
<b class="fc">&nbsp; this.food = 3;</b>
<b class="fc">&nbsp; this.nLower = 0;</b>
<b class="fc">&nbsp; this.nUpper = 0;</b>
<b class="fc">&nbsp; this.nMinPlayer=5;</b>
&nbsp; break;
&nbsp; case &#39;B&#39;:
<b class="fc">&nbsp; this.food = 0;</b>
<b class="fc">&nbsp; this.nLower = 1;</b>
<b class="fc">&nbsp; this.nUpper = 0;</b>
&nbsp; break;
&nbsp; case &#39;C&#39;:
<b class="fc">&nbsp; this.food = 0;</b>
<b class="fc">&nbsp; this.nLower = 0;</b>
<b class="fc">&nbsp; this.nUpper = 1;</b>
&nbsp; break;
&nbsp; case &#39;D&#39;:
<b class="fc">&nbsp; this.food = 0;</b>
<b class="fc">&nbsp; this.nLower = 2;</b>
<b class="fc">&nbsp; this.nUpper = 0;</b>
<b class="fc">&nbsp; this.nMinPlayer = 3;</b>
&nbsp; break;
&nbsp; case &#39;E&#39;:
<b class="fc">&nbsp; this.food = 0;</b>
<b class="fc">&nbsp; this.nLower = 1;</b>
<b class="fc">&nbsp; this.nUpper = 1;</b>
&nbsp; break;
&nbsp; case &#39;F&#39;:
<b class="fc">&nbsp; this.food = 0;</b>
<b class="fc">&nbsp; this.nLower = 0;</b>
<b class="fc">&nbsp; this.nUpper = 2;</b>
&nbsp; break;
&nbsp; case &#39;G&#39;:
<b class="fc">&nbsp; this.food = 0;</b>
<b class="fc">&nbsp; this.nLower = 1;</b>
<b class="fc">&nbsp; this.nUpper = 2;</b>
<b class="fc">&nbsp; this.nMinPlayer = 4;</b>
&nbsp; break;
&nbsp; default:
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Returns the string representation of this slot.
&nbsp; * The returned string includes the slot identifier, number of upper cards,
&nbsp; * number of lower cards, food value, and minimum number of players.
&nbsp; *
&nbsp; * @return the string representation of this slot.
&nbsp; */
&nbsp; @Override
&nbsp; public String toString() {
<b class="fc">&nbsp; return (&quot;SlotID: &quot;+this.getSlotId()+&quot;\nNUpper: &quot;+this.getNUpper()+&quot;\nNLower: &quot;+this.getNLower()+&quot;\nFood: &quot;+this.getFood()+&quot;\n&quot;);</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Returns a compact string representation of this {@code Slot} for the TUI.
&nbsp; * &lt;p&gt;Includes:
&nbsp; * &lt;ul&gt;
&nbsp; * &lt;li&gt;{@link #slotId}&lt;/li&gt;
&nbsp; * &lt;li&gt;{@link #nUpper} (shown as ▲ symbols)&lt;/li&gt;
&nbsp; * &lt;li&gt;{@link #nLower} (shown as ▼ symbols)&lt;/li&gt;
&nbsp; * &lt;li&gt;{@link #food} (if non-zero)&lt;/li&gt;
&nbsp; * &lt;/ul&gt;
&nbsp; * @return a compact TUI string representation of this {@code Slot}.
&nbsp; * @see it.polimi.ingsw.gc14.Model.Game Game
&nbsp; * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
&nbsp; */
&nbsp; public String toStringTUI()
&nbsp; {
<b class="nc">&nbsp; StringBuilder s = new StringBuilder(&quot; &quot;);</b>
<b class="nc">&nbsp; for(int i=0;i&lt;this.getNUpper();i++) s.append(&quot;&quot;);</b>
<b class="nc">&nbsp; for(int i=0;i&lt;this.getNLower();i++) s.append(&quot;&quot;);</b>
<b class="nc">&nbsp; if(getFood()!=0) s.append(&quot;+&quot;+getFood()+&quot; \uD83C\uDF56&quot;);</b>
<b class="nc">&nbsp; s.append(&quot; &quot;);</b>
<b class="nc">&nbsp; return s.toString();</b>
&nbsp; }
&nbsp;
&nbsp; // Functions
&nbsp;
&nbsp; // TODO
&nbsp; @Override
&nbsp; public boolean equals(Object obj) {
<b class="pc">&nbsp; if (this == obj) return true;</b>
<b class="nc">&nbsp; if (!(obj instanceof Slot)) return false;</b>
<b class="nc">&nbsp; return slotId == ((Slot) obj).slotId;</b>
&nbsp; }
&nbsp;
&nbsp; // TODO
&nbsp; @Override
&nbsp; public int hashCode() {
<b class="fc">&nbsp; return Character.hashCode(slotId);</b>
&nbsp; }
&nbsp;
&nbsp; // End functions
&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,136 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > Totems</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.Model</a>
</div>
<h1>Coverage Summary for Class: Totems (it.polimi.ingsw.gc14.Model)</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">Totems</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(2/2)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(6/6)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model;
&nbsp;
&nbsp;/**
&nbsp; * Represents the different totem colors available in the game.
&nbsp; */
<b class="fc">&nbsp;public enum Totems {</b>
&nbsp;
&nbsp; /**
&nbsp; * Yellow totem.
&nbsp; */
<b class="fc">&nbsp; YELLOW,</b>
&nbsp;
&nbsp; /**
&nbsp; * Blue totem.
&nbsp; */
<b class="fc">&nbsp; BLUE,</b>
&nbsp;
&nbsp; /**
&nbsp; * Orange totem.
&nbsp; */
<b class="fc">&nbsp; ORANGE,</b>
&nbsp;
&nbsp; /**
&nbsp; * White totem.
&nbsp; */
<b class="fc">&nbsp; WHITE,</b>
&nbsp;
&nbsp; /**
&nbsp; * Purple totem.
&nbsp; */
<b class="fc">&nbsp; PURPLE</b>
&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>