Add: Added Coverage Screenshots And htlmReport.
This commit is contained in:
@@ -0,0 +1,274 @@
|
||||
|
||||
|
||||
|
||||
<!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"> package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Building effect that grants 3 food for each new pair of identical inventors
|
||||
* obtained after purchasing this building.
|
||||
*
|
||||
* <p>Pairs of identical inventors already owned at the moment of purchase
|
||||
* are stored during initialization and do not provide food.
|
||||
*/
|
||||
public class Building4 extends BuildingCard {
|
||||
|
||||
/** Food units granted per newly completed inventor pair. */
|
||||
private static final int FOOD_PER_INVENTOR_PAIR = 3;
|
||||
|
||||
/**
|
||||
* Indicates whether the building effect has already been initialized
|
||||
* after purchase.
|
||||
*/
|
||||
private boolean purchased;
|
||||
|
||||
/**
|
||||
* Number of inventor pairs already counted by this building effect.
|
||||
*/
|
||||
private int numPair;
|
||||
|
||||
/**
|
||||
* Creates a building with the specified era, price and prestige value.
|
||||
*
|
||||
* @param era The game era of the building.
|
||||
* @param price The price (in food) of the building.
|
||||
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
|
||||
*/
|
||||
public Building4(int era, int price,int prestigeValue) {
|
||||
<b class="fc"> super(era,price,prestigeValue);</b>
|
||||
<b class="fc"> effectType= EffectType.INVENTOR_PAIR;</b>
|
||||
<b class="fc"> effectId=4;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a building with the specified image identifier, era, price
|
||||
* and prestige value.
|
||||
*
|
||||
* @param idIMG the image identifier of the building.
|
||||
* @param era the game era of the building.
|
||||
* @param price the price in food of the building.
|
||||
* @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
|
||||
*/
|
||||
public Building4(String idIMG,int era, int price,int prestigeValue) {
|
||||
<b class="fc"> super(idIMG,era,price,prestigeValue);</b>
|
||||
<b class="fc"> effectType= EffectType.INVENTOR_PAIR;</b>
|
||||
<b class="fc"> effectId=4;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the building effect by storing the number of pairs of identical
|
||||
* inventors already owned by the player at the moment of purchase.
|
||||
*
|
||||
* <p>The initialization is performed only once.
|
||||
*
|
||||
* @param player the player who owns the building.
|
||||
*/
|
||||
public void initialize(Player player)
|
||||
{
|
||||
<b class="pc"> if(purchased)</b>
|
||||
{
|
||||
return;
|
||||
}
|
||||
<b class="fc"> HashMap<Integer,Integer> map = new HashMap<>();</b>
|
||||
<b class="fc"> for(int i=0;i<10;i++)</b>
|
||||
{
|
||||
<b class="fc"> map.put(i,0);</b>
|
||||
}
|
||||
<b class="fc"> for(Inventor inv : player.getInventors())</b>
|
||||
{
|
||||
<b class="fc"> map.merge(inv.getIcon(),1,Integer::sum);</b>
|
||||
}
|
||||
<b class="fc"> numPair=0;</b>
|
||||
<b class="fc"> for(Integer i : map.values())</b>
|
||||
{
|
||||
<b class="fc"> numPair+=(i/2);</b>
|
||||
}
|
||||
<b class="fc"> purchased = true;</b>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to purchase the building and initializes its effect if the
|
||||
* purchase succeeds.
|
||||
*
|
||||
* @param player The player who buys the building.
|
||||
* @return {@code true} if the building is successfully purchased and initialized,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean buy(Player player)
|
||||
{
|
||||
<b class="fc"> if(!super.buy(player))</b>
|
||||
<b class="fc"> return false;</b>
|
||||
<b class="fc"> initialize(player);</b>
|
||||
<b class="fc"> return true;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new building instance with the same configuration values
|
||||
* as this card.
|
||||
*
|
||||
* <p>The runtime state of the effect, such as initialization status and
|
||||
* counted inventor pairs, is not copied.
|
||||
*
|
||||
* @return a new building card with the same base properties.
|
||||
*/
|
||||
@Override
|
||||
public BuildingCard clone() {
|
||||
<b class="fc"> return new Building4(getIdIMG(),getEra(),getPrice(),getPrestigeValue());</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the building effect to the specified player.
|
||||
*
|
||||
* <p>The method counts the current number of pairs of identical inventors
|
||||
* and grants 3 food for each pair obtained since the last stored value.
|
||||
*
|
||||
* @param player The player who owns the building.
|
||||
* @throws IllegalArgumentException Thrown if the specified player does not own this card.
|
||||
*/
|
||||
@Override
|
||||
public void applyEffect(Player player) throws IllegalArgumentException {
|
||||
<b class="fc"> if(!player.getBuildingCards().contains(this))</b>
|
||||
<b class="fc"> throw new IllegalArgumentException();</b>
|
||||
<b class="fc"> HashMap<Integer,Integer> map = new HashMap<>();</b>
|
||||
<b class="fc"> for(int i=0;i<10;i++)</b>
|
||||
{
|
||||
<b class="fc"> map.put(i,0);</b>
|
||||
}
|
||||
<b class="fc"> for(Inventor inv : player.getInventors())</b>
|
||||
{
|
||||
<b class="fc"> map.merge(inv.getIcon(),1,Integer::sum);</b>
|
||||
}
|
||||
<b class="fc"> int temp=0;</b>
|
||||
<b class="fc"> for(Integer i : map.values())</b>
|
||||
{
|
||||
<b class="fc"> temp+=(i/2);</b>
|
||||
}
|
||||
<b class="fc"> if(temp<= numPair)</b>
|
||||
{
|
||||
return;
|
||||
}
|
||||
<b class="fc"> player.addFood(FOOD_PER_INVENTOR_PAIR *(temp-numPair));</b>
|
||||
<b class="fc"> numPair = temp;</b>
|
||||
}
|
||||
}
|
||||
</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>
|
||||
Reference in New Issue
Block a user