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,365 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > BuildingCard</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.Cards</a>
</div>
<h1>Coverage Summary for Class: BuildingCard (it.polimi.ingsw.gc14.Model.Cards)</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">BuildingCard</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">
(14/14)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(25/25)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(47/47)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model.Cards;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.Building.BuildingEffect;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
&nbsp;import it.polimi.ingsw.gc14.Model.PlayableCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Player;
&nbsp;
&nbsp;import java.io.Serializable;
&nbsp;
&nbsp;/**
&nbsp; * Represents a generic building card in the game.
&nbsp; *
&nbsp; * &lt;p&gt;A building card is a playable card with a price and a specific building
&nbsp; * effect. Concrete building cards extend this class to define their own
&nbsp; * behavior.
&nbsp; */
&nbsp;public class BuildingCard extends PlayableCard implements Cloneable , BuildingEffect, Serializable {
&nbsp;
&nbsp; /**
&nbsp; * The price of this building card.
&nbsp; */
&nbsp; private int price;
&nbsp;
&nbsp; /**
&nbsp; * Returns the price of this building card.
&nbsp; *
&nbsp; * @return the price of this building card.
&nbsp; */
&nbsp; public int getPrice() {
<b class="fc">&nbsp; return price;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Indicates whether this building card has already been bought.
&nbsp; */
&nbsp; private boolean bought;
&nbsp;
&nbsp; /**
&nbsp; * The type of effect associated with this building card.
&nbsp; */
&nbsp; protected EffectType effectType;
&nbsp;
&nbsp; /**
&nbsp; * The identifier of the effect associated with this building card.
&nbsp; */
&nbsp; protected int effectId;
&nbsp;
&nbsp; /**
&nbsp; * The prestige value of this building card.
&nbsp; */
&nbsp; private int prestigeValue;
&nbsp;
&nbsp; /**
&nbsp; * Returns the prestige value of this building card.
&nbsp; *
&nbsp; * @return the prestige value of this building card.
&nbsp; */
&nbsp; public int getPrestigeValue() {
<b class="fc">&nbsp; return prestigeValue;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the identifier of the effect associated with this building card.
&nbsp; *
&nbsp; * @return the effect identifier of this building card.
&nbsp; */
&nbsp; public int getEffectId() {
<b class="fc">&nbsp; return effectId;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns the type of effect associated with this building card.
&nbsp; *
&nbsp; * @return the effect type of this building card.
&nbsp; */
&nbsp; public EffectType getEffectType() {
<b class="fc">&nbsp; return effectType;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a building card with the specified era, price, and prestige value.
&nbsp; *
&nbsp; * @param era the era of the building card.
&nbsp; * @param price the price of the building card.
&nbsp; * @param prestigeValue the prestige value of the building card.
&nbsp; * @throws IllegalArgumentException if {@code price &lt;= 0} or {@code prestigeValue &lt; 0}
&nbsp; */
&nbsp; protected BuildingCard(int era,int price,int prestigeValue) throws IllegalArgumentException{
<b class="fc">&nbsp; super(era);</b>
<b class="fc">&nbsp; if (price &gt; 0) {</b>
<b class="fc">&nbsp; this.price = price;</b>
&nbsp; } else {
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
<b class="fc">&nbsp; if (prestigeValue &gt;= 0) {</b>
<b class="fc">&nbsp; this.prestigeValue = prestigeValue;</b>
&nbsp; } else {
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; bought = false;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a building card with the specified image identifier, era, price,
&nbsp; * and prestige value.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the building card.
&nbsp; * @param era the era of the building card.
&nbsp; * @param price the price of the building card.
&nbsp; * @param prestigeValue the prestige value of the building card.
&nbsp; * @throws IllegalArgumentException if {@code price &lt;= 0} or {@code prestigeValue &lt; 0}
&nbsp; */
&nbsp; protected BuildingCard(String idIMG,int era,int price,int prestigeValue) throws IllegalArgumentException{
<b class="fc">&nbsp; super(idIMG,era);</b>
<b class="fc">&nbsp; if (price &gt; 0) {</b>
<b class="fc">&nbsp; this.price = price;</b>
&nbsp; } else {
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
<b class="fc">&nbsp; if (prestigeValue &gt;= 0) {</b>
<b class="fc">&nbsp; this.prestigeValue = prestigeValue;</b>
&nbsp; } else {
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; bought = false;</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /**
&nbsp; * Creates a building card with the specified effect identifier, era, price,
&nbsp; * and prestige value.
&nbsp; * The effect type is determined from the given effect identifier.
&nbsp; *
&nbsp; * @param effectId the identifier of the effect associated with the building card.
&nbsp; * @param era the era of the building card.
&nbsp; * @param price the price of the building card.
&nbsp; * @param prestigeValue the prestige value of the building card.
&nbsp; * @throws IllegalArgumentException if the effect identifier is not valid,
&nbsp; * if {@code price &lt;= 0}, or if {@code prestigeValue &lt; 0}
&nbsp; */
&nbsp; public BuildingCard(int effectId, int era, int price, int prestigeValue) throws IllegalArgumentException {
<b class="fc">&nbsp; this(era, price, prestigeValue);</b>
<b class="fc">&nbsp; this.effectType = effectTypeFromId(effectId);</b>
<b class="fc">&nbsp; this.effectId = effectId;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a building card with the specified image id, effect identifier, era,
&nbsp; * price, and prestige value.
&nbsp; *
&nbsp; * &lt;p&gt;The effect type is determined from the given effect identifier.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the building card.
&nbsp; * @param effectId the identifier of the effect associated with the building card.
&nbsp; * @param era the era of the building card.
&nbsp; * @param price the price of the building card.
&nbsp; * @param prestigeValue the prestige value of the building card.
&nbsp; * @throws IllegalArgumentException if the effect identifier is not valid,
&nbsp; * if {@code price &lt;= 0}, or if {@code prestigeValue &lt; 0}.
&nbsp; */
&nbsp; public BuildingCard(String idIMG, int effectId, int era, int price, int prestigeValue) throws IllegalArgumentException {
<b class="fc">&nbsp; this(idIMG, era, price, prestigeValue);</b>
<b class="fc">&nbsp; this.effectType = effectTypeFromId(effectId);</b>
<b class="fc">&nbsp; this.effectId = effectId;</b>
&nbsp; }
&nbsp;
&nbsp; private static EffectType effectTypeFromId(int effectId) {
<b class="fc">&nbsp; switch (effectId) {</b>
<b class="fc">&nbsp; case 2: return EffectType.ON_EVENT;</b>
<b class="fc">&nbsp; case 3: return EffectType.ON_END_TURN;</b>
<b class="fc">&nbsp; case 5: return EffectType.ON_EVENT;</b>
<b class="fc">&nbsp; case 6: return EffectType.ON_EVENT;</b>
<b class="fc">&nbsp; case 7: return EffectType.ON_EVENT;</b>
<b class="fc">&nbsp; case 9: return EffectType.ON_EVENT;</b>
<b class="fc">&nbsp; case 12: return EffectType.ON_ROUND_END;</b>
<b class="fc">&nbsp; default: throw new IllegalArgumentException();</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates and returns a copy of this building card.
&nbsp; *
&nbsp; * @return a clone of this building card.
&nbsp; */
&nbsp; @Override
&nbsp; public BuildingCard clone()
&nbsp; {
<b class="fc">&nbsp; return new BuildingCard(getIdIMG(),effectId,getEra(),getPrice(),getPrestigeValue());</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to buy this building card for the specified player.
&nbsp; *
&nbsp; * &lt;p&gt;The effective cost is reduced by the total reduction value provided
&nbsp; * by the player&#39;s Builder cards, without dropping below zero. The purchase
&nbsp; * succeeds only if the card has not already been bought and the player can
&nbsp; * pay the resulting amount of Food. If successful, the card is added to
&nbsp; * the player&#39;s building cards and marked as bought.
&nbsp; *
&nbsp; * @param player the player attempting to buy the building card.
&nbsp; * @return {@code true} if the building card is successfully bought,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; public boolean buy(Player player) {
<b class="fc">&nbsp; int discount = player.getBuilders().stream().mapToInt(x -&gt; x.getReductionValue()).sum();</b>
&nbsp;
<b class="fc">&nbsp; if(discount &gt; this.price){</b>
<b class="fc">&nbsp; discount = this.price;</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; if(bought || !player.removeFood(this.price - discount))</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; player.getBuildingCards().add(this);</b>
<b class="fc">&nbsp; bought=true;</b>
<b class="fc">&nbsp; return true;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Default implementation of the building effect.
&nbsp; *
&nbsp; * &lt;p&gt;This method does not perform any operation and can be overridden
&nbsp; * by specific building cards that define an active effect.
&nbsp; *
&nbsp; * @param player the player to whom the effect may be applied.
&nbsp; */
&nbsp; @Override
<b class="fc">&nbsp; public void applyEffect(Player player) {}</b>
&nbsp;
&nbsp; /**
&nbsp; * Returns the string representation of this building card.
&nbsp; *
&nbsp; * @return the string representation of this building card.
&nbsp; */
&nbsp; @Override
&nbsp; public String toString() {
<b class="fc">&nbsp; return &quot;:&quot; + &quot; ID:&quot; + getEffectId() + &quot; \uD83C\uDF56:&quot; + getPrice() + &quot; \uD83C\uDFC5:&quot; + getPrestigeValue();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Returns a compact player-view string representation of this building card.
&nbsp; *
&nbsp; * @return a compact string showing the effect identifier.
&nbsp; */
&nbsp; public String toStringPlayer() {
<b class="fc">&nbsp; return &quot;ID:&quot; + getEffectId();</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,206 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > TribeCard</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.Cards</a>
</div>
<h1>Coverage Summary for Class: TribeCard (it.polimi.ingsw.gc14.Model.Cards)</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">TribeCard</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">
(11/11)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model.Cards;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
&nbsp;import it.polimi.ingsw.gc14.Model.PlayableCard;
&nbsp;import java.io.Serializable;
&nbsp;
&nbsp;
&nbsp;/**
&nbsp; * Abstract base class for all tribe cards.
&nbsp; * A TribeCard is a {@link PlayableCard} that may either be an event card
&nbsp; * or a non-event card, and may optionally specify a minimum number of players.
&nbsp; */
&nbsp;public abstract class TribeCard extends PlayableCard implements Serializable {
&nbsp;
&nbsp; /**
&nbsp; * Indicates whether this tribe card is an event card.
&nbsp; */
&nbsp; private boolean isEventCard;
&nbsp;
&nbsp; /**
&nbsp; * Returns whether this tribe card is an event card.
&nbsp; *
&nbsp; * @return {@code true} if this card is an event card, {@code false} otherwise.
&nbsp; */
&nbsp; public boolean isEventCard() {
<b class="fc">&nbsp; return isEventCard;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * The minimum number of players required for this tribe card.
&nbsp; */
<b class="fc">&nbsp; private int nMin=0;</b>
&nbsp;
&nbsp; /**
&nbsp; * Returns the minimum number of players required for this tribe card.
&nbsp; *
&nbsp; * @return the minimum number of players required for this tribe card.
&nbsp; */
&nbsp; public int getNMin() {
<b class="fc">&nbsp; return nMin;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a tribe card with the specified era and event-card flag.
&nbsp; * The minimum number of players is set to 0.
&nbsp; *
&nbsp; * @param Era the era of the tribe card.
&nbsp; * @param isEventCard whether the card is an event card.
&nbsp; */
&nbsp; public TribeCard(int Era,boolean isEventCard) {
<b class="fc">&nbsp; this(Era,isEventCard,0);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a tribe card with the specified image id, era and event-card flag.
&nbsp; * The minimum number of players is set to 0.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the tribe card.
&nbsp; * @param Era the era of the tribe card.
&nbsp; * @param isEventCard whether the card is an event card.
&nbsp; */
&nbsp; public TribeCard(String idIMG,int Era,boolean isEventCard) {
<b class="fc">&nbsp; this(idIMG,Era,isEventCard,0);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a tribe card with the specified era, event-card flag,
&nbsp; * and minimum number of players.
&nbsp; *
&nbsp; * @param Era the era of the tribe card.
&nbsp; * @param isEventCard whether the card is an event card.
&nbsp; * @param nMin the minimum number of players required for the card.
&nbsp; */
&nbsp; public TribeCard(int Era,boolean isEventCard,int nMin) {
<b class="fc">&nbsp; super(Era);</b>
<b class="fc">&nbsp; this.nMin=nMin;</b>
<b class="fc">&nbsp; this.isEventCard=isEventCard;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a tribe card with the specified image id, era, event-card flag,
&nbsp; * and minimum number of players.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the tribe card.
&nbsp; * @param Era the era of the tribe card.
&nbsp; * @param isEventCard whether the card is an event card.
&nbsp; * @param nMin the minimum number of players required for the card.
&nbsp; */
&nbsp; public TribeCard(String idIMG, int Era,boolean isEventCard,int nMin) {
<b class="fc">&nbsp; super(idIMG,Era);</b>
<b class="fc">&nbsp; this.nMin=nMin;</b>
<b class="fc">&nbsp; this.isEventCard=isEventCard;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates and returns a copy of this tribe card.
&nbsp; *
&nbsp; * @return a clone of this tribe card.
&nbsp; */
&nbsp; @Override
&nbsp; public abstract TribeCard clone();
&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>