FIx: Fixed Coverage Screenshots And htmlRepot.

This commit is contained in:
GabrieleRadice
2026-06-19 22:57:43 +02:00
parent a4dc8b2540
commit 0129efe400
316 changed files with 4566 additions and 4497 deletions
@@ -0,0 +1,273 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > Building4</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.Building.Effects</a>
</div>
<h1>Coverage Summary for Class: Building4 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)</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">Building4</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">
95%
</span>
<span class="absValue">
(19/20)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(34/34)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
&nbsp;import it.polimi.ingsw.gc14.Model.Player;
&nbsp;
&nbsp;import java.util.HashMap;
&nbsp;
&nbsp;/**
&nbsp; * Building effect that grants 3 food for each new pair of identical inventors
&nbsp; * obtained after purchasing this building.
&nbsp; *
&nbsp; * &lt;p&gt;Pairs of identical inventors already owned at the moment of purchase
&nbsp; * are stored during initialization and do not provide food.
&nbsp; */
&nbsp;public class Building4 extends BuildingCard {
&nbsp;
&nbsp; /** Food units granted per newly completed inventor pair. */
&nbsp; private static final int FOOD_PER_INVENTOR_PAIR = 3;
&nbsp;
&nbsp; /**
&nbsp; * Indicates whether the building effect has already been initialized
&nbsp; * after purchase.
&nbsp; */
&nbsp; private boolean purchased;
&nbsp;
&nbsp; /**
&nbsp; * Number of inventor pairs already counted by this building effect.
&nbsp; */
&nbsp; private int numPair;
&nbsp;
&nbsp; /**
&nbsp; * Creates a building with the specified era, price and prestige value.
&nbsp; *
&nbsp; * @param era The game era of the building.
&nbsp; * @param price The price (in food) of the building.
&nbsp; * @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
&nbsp; */
&nbsp; public Building4(int era, int price,int prestigeValue) {
<b class="fc">&nbsp; super(era,price,prestigeValue);</b>
<b class="fc">&nbsp; effectType= EffectType.INVENTOR_PAIR;</b>
<b class="fc">&nbsp; effectId=4;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a building with the specified image identifier, era, price
&nbsp; * and prestige value.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the building.
&nbsp; * @param era the game era of the building.
&nbsp; * @param price the price in food of the building.
&nbsp; * @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
&nbsp; */
&nbsp; public Building4(String idIMG,int era, int price,int prestigeValue) {
<b class="fc">&nbsp; super(idIMG,era,price,prestigeValue);</b>
<b class="fc">&nbsp; effectType= EffectType.INVENTOR_PAIR;</b>
<b class="fc">&nbsp; effectId=4;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Initializes the building effect by storing the number of pairs of identical
&nbsp; * inventors already owned by the player at the moment of purchase.
&nbsp; *
&nbsp; * &lt;p&gt;The initialization is performed only once.
&nbsp; *
&nbsp; * @param player the player who owns the building.
&nbsp; */
&nbsp; public void initialize(Player player)
&nbsp; {
<b class="pc">&nbsp; if(purchased)</b>
&nbsp; {
&nbsp; return;
&nbsp; }
<b class="fc">&nbsp; HashMap&lt;Integer,Integer&gt; map = new HashMap&lt;&gt;();</b>
<b class="fc">&nbsp; for(int i=0;i&lt;10;i++)</b>
&nbsp; {
<b class="fc">&nbsp; map.put(i,0);</b>
&nbsp; }
<b class="fc">&nbsp; for(Inventor inv : player.getInventors())</b>
&nbsp; {
<b class="fc">&nbsp; map.merge(inv.getIcon(),1,Integer::sum);</b>
&nbsp; }
<b class="fc">&nbsp; numPair=0;</b>
<b class="fc">&nbsp; for(Integer i : map.values())</b>
&nbsp; {
<b class="fc">&nbsp; numPair+=(i/2);</b>
&nbsp; }
<b class="fc">&nbsp; purchased = true;</b>
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Attempts to purchase the building and initializes its effect if the
&nbsp; * purchase succeeds.
&nbsp; *
&nbsp; * @param player The player who buys the building.
&nbsp; * @return {@code true} if the building is successfully purchased and initialized,
&nbsp; * {@code false} otherwise.
&nbsp; */
&nbsp; @Override
&nbsp; public boolean buy(Player player)
&nbsp; {
<b class="fc">&nbsp; if(!super.buy(player))</b>
<b class="fc">&nbsp; return false;</b>
<b class="fc">&nbsp; initialize(player);</b>
<b class="fc">&nbsp; return true;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a new building instance with the same configuration values
&nbsp; * as this card.
&nbsp; *
&nbsp; * &lt;p&gt;The runtime state of the effect, such as initialization status and
&nbsp; * counted inventor pairs, is not copied.
&nbsp; *
&nbsp; * @return a new building card with the same base properties.
&nbsp; */
&nbsp; @Override
&nbsp; public BuildingCard clone() {
<b class="fc">&nbsp; return new Building4(getIdIMG(),getEra(),getPrice(),getPrestigeValue());</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the building effect to the specified player.
&nbsp; *
&nbsp; * &lt;p&gt;The method counts the current number of pairs of identical inventors
&nbsp; * and grants 3 food for each pair obtained since the last stored value.
&nbsp; *
&nbsp; * @param player The player who owns the building.
&nbsp; * @throws IllegalArgumentException Thrown if the specified player does not own this card.
&nbsp; */
&nbsp; public void applyEffect(Player player) throws IllegalArgumentException {
<b class="fc">&nbsp; if(!player.getBuildingCards().contains(this))</b>
<b class="fc">&nbsp; throw new IllegalArgumentException();</b>
<b class="fc">&nbsp; HashMap&lt;Integer,Integer&gt; map = new HashMap&lt;&gt;();</b>
<b class="fc">&nbsp; for(int i=0;i&lt;10;i++)</b>
&nbsp; {
<b class="fc">&nbsp; map.put(i,0);</b>
&nbsp; }
<b class="fc">&nbsp; for(Inventor inv : player.getInventors())</b>
&nbsp; {
<b class="fc">&nbsp; map.merge(inv.getIcon(),1,Integer::sum);</b>
&nbsp; }
<b class="fc">&nbsp; int temp=0;</b>
<b class="fc">&nbsp; for(Integer i : map.values())</b>
&nbsp; {
<b class="fc">&nbsp; temp+=(i/2);</b>
&nbsp; }
<b class="fc">&nbsp; if(temp&lt;= numPair)</b>
&nbsp; {
&nbsp; return;
&nbsp; }
<b class="fc">&nbsp; player.addFood(FOOD_PER_INVENTOR_PAIR *(temp-numPair));</b>
<b class="fc">&nbsp; numPair = temp;</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-19 22:53</div>
</div>
</body>
</html>