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,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>